Skip to content

Commit 2ec8457

Browse files
authored
Update tools for spirv issue 373. (#6650)
Issue : KhronosGroup/SPIRV-Registry#373
1 parent 0539c81 commit 2ec8457

3 files changed

Lines changed: 67 additions & 2 deletions

File tree

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ vars = {
1414

1515
're2_revision': '972a15cedd008d846f1a39b2e88ce48d7f166cbd',
1616

17-
'spirv_headers_revision': 'ad9184e76a66b1001c29db9b0a3e87f646c64de0',
17+
'spirv_headers_revision': '1a22b167081842915a1c78a0b5b5a353a23284aa',
1818

1919
'mimalloc_revision': 'b1963961a5cdb1996c9ad2e356014089b7a94ea3',
2020
}

source/val/validate_ray_tracing_reorder.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,16 @@ spv_result_t RayReorderEXTPass(ValidationState_t& _, const Instruction* inst) {
991991
<< "Hit Object Attributes id must be a OpVariable of storage "
992992
"class HitObjectAttributeEXT";
993993
}
994+
995+
// Validate optional Hit Kind (operand 4)
996+
if (inst->operands().size() > 4) {
997+
const uint32_t hit_kind_type = _.GetOperandTypeId(inst, 4);
998+
if (!_.IsUnsignedIntScalarType(hit_kind_type) ||
999+
_.GetBitWidth(hit_kind_type) != 32) {
1000+
return _.diag(SPV_ERROR_INVALID_DATA, inst)
1001+
<< "Hit Kind must be a 32-bit unsigned int scalar";
1002+
}
1003+
}
9941004
break;
9951005
}
9961006

test/val/val_ray_tracing_reorder_test.cpp

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,8 @@ TEST_F(ValidateRayTracingReorderEXT,
14471447
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
14481448
}
14491449

1450-
TEST_F(ValidateRayTracingReorderEXT, HitObjectRecordFromQueryEXT) {
1450+
TEST_F(ValidateRayTracingReorderEXT,
1451+
HitObjectRecordFromQueryEXTWithoutHitKind) {
14511452
const std::string cap = R"(
14521453
OpCapability RayQueryKHR
14531454
)";
@@ -1472,6 +1473,60 @@ TEST_F(ValidateRayTracingReorderEXT, HitObjectRecordFromQueryEXT) {
14721473
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
14731474
}
14741475

1476+
TEST_F(ValidateRayTracingReorderEXT, HitObjectRecordFromQueryEXTWithHitKind) {
1477+
const std::string cap = R"(
1478+
OpCapability RayQueryKHR
1479+
)";
1480+
const std::string extensions = R"(
1481+
OpExtension "SPV_KHR_ray_query"
1482+
)";
1483+
const std::string declarations = R"(
1484+
%uint = OpTypeInt 32 0
1485+
%uint_5 = OpConstant %uint 5
1486+
%uint_254 = OpConstant %uint 254
1487+
%rayquery_type = OpTypeRayQueryKHR
1488+
%_ptr_Function_rayquery = OpTypePointer Function %rayquery_type
1489+
)";
1490+
1491+
const std::string body = R"(
1492+
%ray_query = OpVariable %_ptr_Function_rayquery Function
1493+
OpHitObjectRecordFromQueryEXT %hObj %ray_query %uint_5 %attr %uint_254
1494+
)";
1495+
1496+
CompileSuccessfully(
1497+
GenerateReorderShaderCodeEXT(body, declarations, extensions, cap).c_str(),
1498+
SPV_ENV_VULKAN_1_2);
1499+
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
1500+
}
1501+
1502+
TEST_F(ValidateRayTracingReorderEXT,
1503+
HitObjectRecordFromQueryEXTHitKindWrongType) {
1504+
const std::string cap = R"(
1505+
OpCapability RayQueryKHR
1506+
)";
1507+
const std::string extensions = R"(
1508+
OpExtension "SPV_KHR_ray_query"
1509+
)";
1510+
const std::string declarations = R"(
1511+
%uint = OpTypeInt 32 0
1512+
%uint_5 = OpConstant %uint 5
1513+
%rayquery_type = OpTypeRayQueryKHR
1514+
%_ptr_Function_rayquery = OpTypePointer Function %rayquery_type
1515+
)";
1516+
1517+
const std::string body = R"(
1518+
%ray_query = OpVariable %_ptr_Function_rayquery Function
1519+
OpHitObjectRecordFromQueryEXT %hObj %ray_query %uint_5 %attr %float_1
1520+
)";
1521+
1522+
CompileSuccessfully(
1523+
GenerateReorderShaderCodeEXT(body, declarations, extensions, cap).c_str(),
1524+
SPV_ENV_VULKAN_1_2);
1525+
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
1526+
EXPECT_THAT(getDiagnosticString(),
1527+
HasSubstr("Hit Kind must be a 32-bit unsigned int scalar"));
1528+
}
1529+
14751530
TEST_F(ValidateRayTracingReorderEXT, HitObjectRecordMissMotionEXT) {
14761531
const std::string declarations = R"(
14771532
%uint = OpTypeInt 32 0

0 commit comments

Comments
 (0)