@@ -633,6 +633,58 @@ TEST_F(ValidateRayQuery, RayQueryArraySuccess) {
633633 EXPECT_EQ (SPV_SUCCESS , ValidateInstructions ());
634634}
635635
636+ TEST_F (ValidateRayQuery, RayQueryArraySuccessInBounds) {
637+ // This shader is slightly different to the ones above, so it doesn't reuse
638+ // the shader code generator.
639+ const std::string shader = R"(
640+ OpCapability Shader
641+ OpCapability RayQueryKHR
642+ OpExtension "SPV_KHR_ray_query"
643+ OpMemoryModel Logical GLSL450
644+ OpEntryPoint GLCompute %main "main"
645+ OpExecutionMode %main LocalSize 1 1 1
646+ OpSource GLSL 460
647+ OpDecorate %topLevelAS DescriptorSet 0
648+ OpDecorate %topLevelAS Binding 0
649+ OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
650+ %void = OpTypeVoid
651+ %func = OpTypeFunction %void
652+ %ray_query = OpTypeRayQueryKHR
653+ %uint = OpTypeInt 32 0
654+ %uint_2 = OpConstant %uint 2
655+ %ray_query_array = OpTypeArray %ray_query %uint_2
656+ %ptr_ray_query_array = OpTypePointer Private %ray_query_array
657+ %rayQueries = OpVariable %ptr_ray_query_array Private
658+ %int = OpTypeInt 32 1
659+ %int_0 = OpConstant %int 0
660+ %ptr_ray_query = OpTypePointer Private %ray_query
661+ %accel_struct = OpTypeAccelerationStructureKHR
662+ %ptr_accel_struct = OpTypePointer UniformConstant %accel_struct
663+ %topLevelAS = OpVariable %ptr_accel_struct UniformConstant
664+ %uint_0 = OpConstant %uint 0
665+ %uint_255 = OpConstant %uint 255
666+ %float = OpTypeFloat 32
667+ %v3float = OpTypeVector %float 3
668+ %float_0 = OpConstant %float 0
669+ %vec3_zero = OpConstantComposite %v3float %float_0 %float_0 %float_0
670+ %float_1 = OpConstant %float 1
671+ %vec3_xy_0_z_1 = OpConstantComposite %v3float %float_0 %float_0 %float_1
672+ %float_10 = OpConstant %float 10
673+ %v3uint = OpTypeVector %uint 3
674+ %uint_1 = OpConstant %uint 1
675+ %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
676+ %main = OpFunction %void None %func
677+ %main_label = OpLabel
678+ %first_ray_query = OpInBoundsAccessChain %ptr_ray_query %rayQueries %int_0
679+ %topLevelAS_val = OpLoad %accel_struct %topLevelAS
680+ OpRayQueryInitializeKHR %first_ray_query %topLevelAS_val %uint_0 %uint_255 %vec3_zero %float_0 %vec3_xy_0_z_1 %float_10
681+ OpReturn
682+ OpFunctionEnd
683+ )" ;
684+ CompileSuccessfully (shader);
685+ EXPECT_EQ (SPV_SUCCESS , ValidateInstructions ());
686+ }
687+
636688TEST_F (ValidateRayQuery, ClusterASNV) {
637689 const std::string cap = R"(
638690 OpCapability RayTracingClusterAccelerationStructureNV
0 commit comments