MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateMeshVariable

Function ValidateMeshVariable

source/val/validate_mesh_shading.cpp:170–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170spv_result_t ValidateMeshVariable(ValidationState_t& _,
171 const Instruction* inst) {
172 if (!_.HasCapability(spv::Capability::MeshShadingEXT)) {
173 return SPV_SUCCESS;
174 }
175 bool is_mesh_interface_var =
176 IsInterfaceVariable(_, inst, spv::ExecutionModel::MeshEXT);
177 bool is_frag_interface_var =
178 IsInterfaceVariable(_, inst, spv::ExecutionModel::Fragment);
179
180 const spv::StorageClass storage_class =
181 inst->GetOperandAs<spv::StorageClass>(2);
182 bool storage_output = (storage_class == spv::StorageClass::Output);
183 bool storage_input = (storage_class == spv::StorageClass::Input);
184
185 if (_.HasDecoration(inst->id(), spv::Decoration::PerPrimitiveEXT)) {
186 if (is_frag_interface_var && !storage_input) {
187 return _.diag(SPV_ERROR_INVALID_DATA, inst)
188 << "PerPrimitiveEXT decoration must be applied only to "
189 "variables in the Input Storage Class in the Fragment "
190 "Execution Model.";
191 }
192
193 if (is_mesh_interface_var && !storage_output) {
194 return _.diag(SPV_ERROR_INVALID_DATA, inst)
195 << _.VkErrorID(4336)
196 << "PerPrimitiveEXT decoration must be applied only to "
197 "variables in the Output Storage Class in the "
198 "Storage Class in the MeshEXT Execution Model.";
199 }
200 }
201
202 // This only applies to user interface variables, not built-ins (they
203 // are validated with the rest of the builtin)
204 if (is_mesh_interface_var && storage_output &&
205 !_.HasDecoration(inst->id(), spv::Decoration::BuiltIn)) {
206 const Instruction* pointer_inst = _.FindDef(inst->type_id());
207 if (pointer_inst->opcode() == spv::Op::OpTypePointer) {
208 if (!_.IsArrayType(pointer_inst->word(3))) {
209 return _.diag(SPV_ERROR_INVALID_DATA, inst)
210 << "In the MeshEXT Execution Mode, all Output Variables "
211 "must contain an Array.";
212 }
213 }
214 }
215
216 return SPV_SUCCESS;
217}
218
219spv_result_t MeshShadingPass(ValidationState_t& _, const Instruction* inst) {
220 const spv::Op opcode = inst->opcode();

Callers 1

MeshShadingPassFunction · 0.85

Calls 11

IsInterfaceVariableFunction · 0.85
diagMethod · 0.80
VkErrorIDMethod · 0.80
FindDefMethod · 0.80
IsArrayTypeMethod · 0.80
wordMethod · 0.80
HasCapabilityMethod · 0.45
HasDecorationMethod · 0.45
idMethod · 0.45
type_idMethod · 0.45
opcodeMethod · 0.45

Tested by

no test coverage detected