| 155 | } |
| 156 | |
| 157 | spv_result_t ValidateExecuteCallable(ValidationState_t& _, |
| 158 | const Instruction* inst) { |
| 159 | _.function(inst->function()->id()) |
| 160 | ->RegisterExecutionModelLimitation( |
| 161 | [](spv::ExecutionModel model, std::string* message) { |
| 162 | if (model != spv::ExecutionModel::RayGenerationKHR && |
| 163 | model != spv::ExecutionModel::ClosestHitKHR && |
| 164 | model != spv::ExecutionModel::MissKHR && |
| 165 | model != spv::ExecutionModel::CallableKHR) { |
| 166 | if (message) { |
| 167 | *message = |
| 168 | "OpExecuteCallableKHR requires RayGenerationKHR, " |
| 169 | "ClosestHitKHR, MissKHR and CallableKHR execution models"; |
| 170 | } |
| 171 | return false; |
| 172 | } |
| 173 | return true; |
| 174 | }); |
| 175 | |
| 176 | const uint32_t sbt_index = _.GetOperandTypeId(inst, 0); |
| 177 | if (!_.IsUnsignedIntScalarType(sbt_index) || _.GetBitWidth(sbt_index) != 32) { |
| 178 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 179 | << "SBT Index must be a 32-bit unsigned int scalar"; |
| 180 | } |
| 181 | |
| 182 | const auto callable_data = _.FindDef(inst->GetOperandAs<uint32_t>(1)); |
| 183 | if (callable_data->opcode() != spv::Op::OpVariable) { |
| 184 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 185 | << "Callable Data must be the result of a OpVariable"; |
| 186 | } else if (callable_data->GetOperandAs<spv::StorageClass>(2) != |
| 187 | spv::StorageClass::CallableDataKHR && |
| 188 | callable_data->GetOperandAs<spv::StorageClass>(2) != |
| 189 | spv::StorageClass::IncomingCallableDataKHR) { |
| 190 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 191 | << "Callable Data must have storage class CallableDataKHR or " |
| 192 | "IncomingCallableDataKHR"; |
| 193 | } |
| 194 | return SPV_SUCCESS; |
| 195 | } |
| 196 | |
| 197 | spv_result_t RayTracingPass(ValidationState_t& _, const Instruction* inst) { |
| 198 | const spv::Op opcode = inst->opcode(); |
no test coverage detected