| 168 | } |
| 169 | |
| 170 | spv_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 | |
| 219 | spv_result_t MeshShadingPass(ValidationState_t& _, const Instruction* inst) { |
| 220 | const spv::Op opcode = inst->opcode(); |
no test coverage detected