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

Function ValidateSetMeshOutputs

source/val/validate_mesh_shading.cpp:95–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95spv_result_t ValidateSetMeshOutputs(ValidationState_t& _,
96 const Instruction* inst) {
97 _.function(inst->function()->id())
98 ->RegisterExecutionModelLimitation([](spv::ExecutionModel model,
99 std::string* message) {
100 if (model != spv::ExecutionModel::MeshEXT) {
101 if (message) {
102 *message = "OpSetMeshOutputsEXT requires MeshEXT execution model";
103 }
104 return false;
105 }
106 return true;
107 });
108
109 const uint32_t vertex_count = _.GetOperandTypeId(inst, 0);
110 if (!_.IsUnsignedIntScalarType(vertex_count) ||
111 _.GetBitWidth(vertex_count) != 32) {
112 return _.diag(SPV_ERROR_INVALID_DATA, inst)
113 << "Vertex Count must be a 32-bit unsigned int scalar";
114 }
115
116 const uint32_t primitive_count = _.GetOperandTypeId(inst, 1);
117 if (!_.IsUnsignedIntScalarType(primitive_count) ||
118 _.GetBitWidth(primitive_count) != 32) {
119 return _.diag(SPV_ERROR_INVALID_DATA, inst)
120 << "Primitive Count must be a 32-bit unsigned int scalar";
121 }
122
123 // Will only validate if constants are used (or spec constant frozen)
124 uint64_t vertex_count_value = 0;
125 if (_.EvalConstantValUint64(inst->GetOperandAs<uint32_t>(0),
126 &vertex_count_value)) {
127 _.function(inst->function()->id())
128 ->RegisterLimitation(
129 [vertex_count_value](const ValidationState_t& state,
130 const Function* entry_point,
131 std::string* message) {
132 const uint32_t output_vertices =
133 state.GetOutputVertices(entry_point->id());
134 if (vertex_count_value > output_vertices) {
135 *message =
136 "OpSetMeshOutputsEXT Vertex Count (" +
137 std::to_string(vertex_count_value) +
138 ") is larger than the OutputVertices in OpExecutionMode (" +
139 std::to_string(output_vertices) + ").";
140 return false;
141 }
142 return true;
143 });
144 }
145 uint64_t primitive_count_value = 0;
146 if (_.EvalConstantValUint64(inst->GetOperandAs<uint32_t>(1),
147 &primitive_count_value)) {
148 _.function(inst->function()->id())
149 ->RegisterLimitation(
150 [primitive_count_value](const ValidationState_t& state,
151 const Function* entry_point,
152 std::string* message) {

Callers 1

MeshShadingPassFunction · 0.85

Calls 12

GetOperandTypeIdMethod · 0.80
GetBitWidthMethod · 0.80
diagMethod · 0.80
EvalConstantValUint64Method · 0.80
RegisterLimitationMethod · 0.80
GetOutputVerticesMethod · 0.80
to_stringFunction · 0.50
functionMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected