1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// Copyright 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// AUTOMATICALLY GENERATED from the SPIR-V JSON grammar:
//   external/spirv.core.grammar.json.
// DO NOT MODIFY!

impl Builder {
    /// Appends an OpTypeVoid instruction and returns the result id.
    pub fn type_void(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeVoid, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypeBool instruction and returns the result id.
    pub fn type_bool(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeBool, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypeInt instruction and returns the result id.
    pub fn type_int(&mut self, width: u32, signedness: u32) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeInt, None, Some(id), vec![mr::Operand::LiteralInt32(width), mr::Operand::LiteralInt32(signedness)]));
        id
    }

    /// Appends an OpTypeFloat instruction and returns the result id.
    pub fn type_float(&mut self, width: u32) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeFloat, None, Some(id), vec![mr::Operand::LiteralInt32(width)]));
        id
    }

    /// Appends an OpTypeVector instruction and returns the result id.
    pub fn type_vector(&mut self, component_type: spirv::Word, component_count: u32) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeVector, None, Some(id), vec![mr::Operand::IdRef(component_type), mr::Operand::LiteralInt32(component_count)]));
        id
    }

    /// Appends an OpTypeMatrix instruction and returns the result id.
    pub fn type_matrix(&mut self, column_type: spirv::Word, column_count: u32) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeMatrix, None, Some(id), vec![mr::Operand::IdRef(column_type), mr::Operand::LiteralInt32(column_count)]));
        id
    }

    /// Appends an OpTypeImage instruction and returns the result id.
    pub fn type_image(&mut self, sampled_type: spirv::Word, dim: spirv::Dim, depth: u32, arrayed: u32, ms: u32, sampled: u32, image_format: spirv::ImageFormat, access_qualifier: Option<spirv::AccessQualifier>) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeImage, None, Some(id), vec![mr::Operand::IdRef(sampled_type), mr::Operand::Dim(dim), mr::Operand::LiteralInt32(depth), mr::Operand::LiteralInt32(arrayed), mr::Operand::LiteralInt32(ms), mr::Operand::LiteralInt32(sampled), mr::Operand::ImageFormat(image_format)]));
        match access_qualifier {
            Some(v) => self.module.types_global_values.last_mut().expect("interal error").operands.push(mr::Operand::AccessQualifier(v)),
            None => (),
        };
        id
    }

    /// Appends an OpTypeSampler instruction and returns the result id.
    pub fn type_sampler(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeSampler, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypeSampledImage instruction and returns the result id.
    pub fn type_sampled_image(&mut self, image_type: spirv::Word) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeSampledImage, None, Some(id), vec![mr::Operand::IdRef(image_type)]));
        id
    }

    /// Appends an OpTypeArray instruction and returns the result id.
    pub fn type_array(&mut self, element_type: spirv::Word, length: spirv::Word) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeArray, None, Some(id), vec![mr::Operand::IdRef(element_type), mr::Operand::IdRef(length)]));
        id
    }

    /// Appends an OpTypeRuntimeArray instruction and returns the result id.
    pub fn type_runtime_array(&mut self, element_type: spirv::Word) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeRuntimeArray, None, Some(id), vec![mr::Operand::IdRef(element_type)]));
        id
    }

    /// Appends an OpTypeStruct instruction and returns the result id.
    pub fn type_struct(&mut self, field_types: Vec<spirv::Word>) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeStruct, None, Some(id), vec![]));
        for v in field_types {
            self.module.types_global_values.last_mut().expect("interal error").operands.push(mr::Operand::IdRef(v))
        };
        id
    }

    /// Appends an OpTypeOpaque instruction and returns the result id.
    pub fn type_opaque(&mut self, type_name: String) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeOpaque, None, Some(id), vec![mr::Operand::LiteralString(type_name)]));
        id
    }

    /// Appends an OpTypePointer instruction and returns the result id.
    pub fn type_pointer(&mut self, storage_class: spirv::StorageClass, pointee_type: spirv::Word) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypePointer, None, Some(id), vec![mr::Operand::StorageClass(storage_class), mr::Operand::IdRef(pointee_type)]));
        id
    }

    /// Appends an OpTypeFunction instruction and returns the result id.
    pub fn type_function(&mut self, return_type: spirv::Word, parameter_types: Vec<spirv::Word>) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeFunction, None, Some(id), vec![mr::Operand::IdRef(return_type)]));
        for v in parameter_types {
            self.module.types_global_values.last_mut().expect("interal error").operands.push(mr::Operand::IdRef(v))
        };
        id
    }

    /// Appends an OpTypeEvent instruction and returns the result id.
    pub fn type_event(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeEvent, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypeDeviceEvent instruction and returns the result id.
    pub fn type_device_event(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeDeviceEvent, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypeReserveId instruction and returns the result id.
    pub fn type_reserve_id(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeReserveId, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypeQueue instruction and returns the result id.
    pub fn type_queue(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeQueue, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypePipe instruction and returns the result id.
    pub fn type_pipe(&mut self, qualifier: spirv::AccessQualifier) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypePipe, None, Some(id), vec![mr::Operand::AccessQualifier(qualifier)]));
        id
    }

    /// Appends an OpTypeForwardPointer instruction and returns the result id.
    pub fn type_forward_pointer(&mut self, storage_class: spirv::StorageClass) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeForwardPointer, None, Some(id), vec![mr::Operand::StorageClass(storage_class)]));
        id
    }

    /// Appends an OpTypePipeStorage instruction and returns the result id.
    pub fn type_pipe_storage(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypePipeStorage, None, Some(id), vec![]));
        id
    }

    /// Appends an OpTypeNamedBarrier instruction and returns the result id.
    pub fn type_named_barrier(&mut self) -> spirv::Word {
        let id = self.id();
        self.module.types_global_values.push(mr::Instruction::new(spirv::Op::TypeNamedBarrier, None, Some(id), vec![]));
        id
    }
}