Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer Fricke <spencerfricke@gmail.com>2022-08-18 20:42:25 +0300
committerGitHub <noreply@github.com>2022-08-18 20:42:25 +0300
commit3c1a14b2b609ae5a352e39ef6b5baf8f64c32ec7 (patch)
tree0e5d9ec4e9a8e5c8b228e2e1b35f89fae3c26fb2
parent0073a1fa36f7c52ad3d58059cb5d5de8efa825ad (diff)
spirv-val: SBT Index for OpExecuteCallableKHR (#4900)
-rw-r--r--source/val/validate_ray_tracing.cpp7
-rw-r--r--test/val/val_ray_tracing.cpp28
2 files changed, 35 insertions, 0 deletions
diff --git a/source/val/validate_ray_tracing.cpp b/source/val/validate_ray_tracing.cpp
index 81fa59383..78bac19b5 100644
--- a/source/val/validate_ray_tracing.cpp
+++ b/source/val/validate_ray_tracing.cpp
@@ -174,6 +174,13 @@ spv_result_t RayTracingPass(ValidationState_t& _, const Instruction* inst) {
return true;
});
+ const uint32_t sbt_index = _.GetOperandTypeId(inst, 0);
+ if (!_.IsUnsignedIntScalarType(sbt_index) ||
+ _.GetBitWidth(sbt_index) != 32) {
+ return _.diag(SPV_ERROR_INVALID_DATA, inst)
+ << "SBT Index must be a 32-bit unsigned int scalar";
+ }
+
const auto callable_data = _.FindDef(inst->GetOperandAs<uint32_t>(1));
if (callable_data->opcode() != SpvOpVariable) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
diff --git a/test/val/val_ray_tracing.cpp b/test/val/val_ray_tracing.cpp
index 9486777a0..58b9356ce 100644
--- a/test/val/val_ray_tracing.cpp
+++ b/test/val/val_ray_tracing.cpp
@@ -334,6 +334,34 @@ OpFunctionEnd
"or IncomingCallableDataKHR"));
}
+TEST_F(ValidateRayTracing, ExecuteCallableSbtIndex) {
+ const std::string body = R"(
+OpCapability RayTracingKHR
+OpExtension "SPV_KHR_ray_tracing"
+OpMemoryModel Logical GLSL450
+OpEntryPoint CallableKHR %main "main"
+OpName %main "main"
+%void = OpTypeVoid
+%func = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%uint = OpTypeInt 32 0
+%uint_0 = OpConstant %uint 0
+%int_1 = OpConstant %int 1
+%data_ptr = OpTypePointer CallableDataKHR %int
+%data = OpVariable %data_ptr CallableDataKHR
+%main = OpFunction %void None %func
+%label = OpLabel
+OpExecuteCallableKHR %int_1 %data
+OpReturn
+OpFunctionEnd
+)";
+
+ CompileSuccessfully(body.c_str());
+ EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("SBT Index must be a 32-bit unsigned int scalar"));
+}
+
std::string GenerateRayTraceCode(
const std::string& body,
const std::string execution_model = "RayGenerationKHR") {