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:
authorRicardo Garcia <47594367+rg3igalia@users.noreply.github.com>2022-09-21 22:27:36 +0300
committerGitHub <noreply@github.com>2022-09-21 22:27:36 +0300
commitaeb1c64d4ab7105ea981d3076d5f47a88a0ccb2d (patch)
treed9d5c3d48f0fcab30f347560c59fceb7920ada35
parent11d0d162279b7cd19f82dac3934149dd97a3a42c (diff)
spirv-val: Make it legal to use arrays of ray queries (#4938)
Private arrays of ray queries are legal to use. Several CTS tests check they work properly but were being rejected by spirv-val.
-rw-r--r--source/val/validate_ray_query.cpp6
-rw-r--r--test/val/val_ray_query_test.cpp53
2 files changed, 57 insertions, 2 deletions
diff --git a/source/val/validate_ray_query.cpp b/source/val/validate_ray_query.cpp
index f92bf016a..b553449d0 100644
--- a/source/val/validate_ray_query.cpp
+++ b/source/val/validate_ray_query.cpp
@@ -28,8 +28,10 @@ spv_result_t ValidateRayQueryPointer(ValidationState_t& _,
uint32_t ray_query_index) {
const uint32_t ray_query_id = inst->GetOperandAs<uint32_t>(ray_query_index);
auto variable = _.FindDef(ray_query_id);
- if (!variable || (variable->opcode() != SpvOpVariable &&
- variable->opcode() != SpvOpFunctionParameter)) {
+ const auto var_opcode = variable->opcode();
+ if (!variable ||
+ (var_opcode != SpvOpVariable && var_opcode != SpvOpFunctionParameter &&
+ var_opcode != SpvOpAccessChain)) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< "Ray Query must be a memory object declaration";
}
diff --git a/test/val/val_ray_query_test.cpp b/test/val/val_ray_query_test.cpp
index e9b969637..1541c7453 100644
--- a/test/val/val_ray_query_test.cpp
+++ b/test/val/val_ray_query_test.cpp
@@ -18,6 +18,7 @@
#include <string>
#include "gmock/gmock.h"
+#include "spirv-tools/libspirv.h"
#include "test/val/val_fixtures.h"
namespace spvtools {
@@ -573,6 +574,58 @@ OpRayQueryGenerateIntersectionKHR %ray_query %u32_0
HasSubstr("Hit T must be a 32-bit float scalar"));
}
+TEST_F(ValidateRayQuery, RayQueryArraySuccess) {
+ // This shader is slightly different to the ones above, so it doesn't reuse
+ // the shader code generator.
+ const std::string shader = R"(
+ OpCapability Shader
+ OpCapability RayQueryKHR
+ OpExtension "SPV_KHR_ray_query"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %main "main"
+ OpExecutionMode %main LocalSize 1 1 1
+ OpSource GLSL 460
+ OpDecorate %topLevelAS DescriptorSet 0
+ OpDecorate %topLevelAS Binding 0
+ OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
+ %void = OpTypeVoid
+ %func = OpTypeFunction %void
+ %ray_query = OpTypeRayQueryKHR
+ %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+ %ray_query_array = OpTypeArray %ray_query %uint_2
+%ptr_ray_query_array = OpTypePointer Private %ray_query_array
+ %rayQueries = OpVariable %ptr_ray_query_array Private
+ %int = OpTypeInt 32 1
+ %int_0 = OpConstant %int 0
+ %ptr_ray_query = OpTypePointer Private %ray_query
+ %accel_struct = OpTypeAccelerationStructureKHR
+ %ptr_accel_struct = OpTypePointer UniformConstant %accel_struct
+ %topLevelAS = OpVariable %ptr_accel_struct UniformConstant
+ %uint_0 = OpConstant %uint 0
+ %uint_255 = OpConstant %uint 255
+ %float = OpTypeFloat 32
+ %v3float = OpTypeVector %float 3
+ %float_0 = OpConstant %float 0
+ %vec3_zero = OpConstantComposite %v3float %float_0 %float_0 %float_0
+ %float_1 = OpConstant %float 1
+ %vec3_xy_0_z_1 = OpConstantComposite %v3float %float_0 %float_0 %float_1
+ %float_10 = OpConstant %float 10
+ %v3uint = OpTypeVector %uint 3
+ %uint_1 = OpConstant %uint 1
+ %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
+ %main = OpFunction %void None %func
+ %main_label = OpLabel
+ %first_ray_query = OpAccessChain %ptr_ray_query %rayQueries %int_0
+ %topLevelAS_val = OpLoad %accel_struct %topLevelAS
+ OpRayQueryInitializeKHR %first_ray_query %topLevelAS_val %uint_0 %uint_255 %vec3_zero %float_0 %vec3_xy_0_z_1 %float_10
+ OpReturn
+ OpFunctionEnd
+)";
+ CompileSuccessfully(shader);
+ EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
+}
+
} // namespace
} // namespace val
} // namespace spvtools