diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 1adebef87..eea885280 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -7991,7 +7991,7 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv:: opCode = spv::OpRayQueryGetIntersectionInstanceIdKHR; break; case glslang::EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset: - typeId = builder.makeIntType(32); + typeId = builder.makeUintType(32); opCode = spv::OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR; break; case glslang::EOpRayQueryGetIntersectionGeometryIndex: diff --git a/Test/baseResults/rayQuery-allOps.comp.out b/Test/baseResults/rayQuery-allOps.comp.out index fd4a2ff8c..bf654f779 100644 --- a/Test/baseResults/rayQuery-allOps.comp.out +++ b/Test/baseResults/rayQuery-allOps.comp.out @@ -223,7 +223,7 @@ rayQuery-allOps.comp 129: 2 FunctionCall 6(doSomething() Branch 128 128: Label - 130: 18(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 47(rayQuery) 23 + 130: 14(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 47(rayQuery) 23 131: 66(bool) UGreaterThan 130 20 SelectionMerge 133 None BranchConditional 131 132 133 diff --git a/Test/baseResults/rayQuery-allOps.frag.out b/Test/baseResults/rayQuery-allOps.frag.out index 573a640ab..90ebc4a28 100644 --- a/Test/baseResults/rayQuery-allOps.frag.out +++ b/Test/baseResults/rayQuery-allOps.frag.out @@ -221,7 +221,7 @@ rayQuery-allOps.frag 129: 2 FunctionCall 6(doSomething() Branch 128 128: Label - 130: 18(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 47(rayQuery) 23 + 130: 14(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 47(rayQuery) 23 131: 66(bool) UGreaterThan 130 20 SelectionMerge 133 None BranchConditional 131 132 133 diff --git a/Test/baseResults/rayQuery-allOps.rgen.out b/Test/baseResults/rayQuery-allOps.rgen.out index deb0f7d5e..b3a93b025 100644 --- a/Test/baseResults/rayQuery-allOps.rgen.out +++ b/Test/baseResults/rayQuery-allOps.rgen.out @@ -221,7 +221,7 @@ rayQuery-allOps.rgen 129: 2 FunctionCall 6(doSomething() Branch 128 128: Label - 130: 18(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 47(rayQuery) 23 + 130: 14(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 47(rayQuery) 23 131: 66(bool) UGreaterThan 130 20 SelectionMerge 133 None BranchConditional 131 132 133 diff --git a/Test/baseResults/rayQuery-types.comp.out b/Test/baseResults/rayQuery-types.comp.out new file mode 100644 index 000000000..87a1d6835 --- /dev/null +++ b/Test/baseResults/rayQuery-types.comp.out @@ -0,0 +1,152 @@ +rayQuery-types.comp +// Module Version 10000 +// Generated by (magic number): 8000a +// Id's are bound by 86 + + Capability Shader + Capability RayQueryKHR + Extension "SPV_KHR_ray_query" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 16 8 1 + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + Name 4 "main" + Name 8 "rayQuery" + Name 11 "tlas" + Name 25 "rq_proceed" + Name 35 "intersectionType" + Name 41 "rayTMin" + Name 43 "rayFlags" + Name 46 "worldRayOrigin" + Name 48 "worldDirection" + Name 50 "intersectionT" + Name 53 "customIndex" + Name 55 "instanceId" + Name 57 "sbtOffset" + Name 59 "geometryIndex" + Name 61 "primitiveIndex" + Name 65 "barys" + Name 67 "frontface" + Name 69 "aabbOpaque" + Name 71 "objRayDirection" + Name 73 "objRayOrigin" + Name 77 "objToWorld" + Name 79 "worldToObj" + Decorate 11(tlas) DescriptorSet 0 + Decorate 11(tlas) Binding 0 + Decorate 85 BuiltIn WorkgroupSize + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeRayQueryKHR + 7: TypePointer Private 6 + 8(rayQuery): 7(ptr) Variable Private + 9: TypeAccelerationStructureKHR + 10: TypePointer UniformConstant 9 + 11(tlas): 10(ptr) Variable UniformConstant + 13: TypeInt 32 0 + 14: 13(int) Constant 0 + 15: 13(int) Constant 255 + 16: TypeFloat 32 + 17: TypeVector 16(float) 3 + 18: 16(float) Constant 0 + 19: 17(fvec3) ConstantComposite 18 18 18 + 20: 16(float) Constant 1065353216 + 21: 17(fvec3) ConstantComposite 20 18 18 + 22: 16(float) Constant 1176256512 + 23: TypeBool + 24: TypePointer Function 23(bool) + 34: TypePointer Function 13(int) + 36: 23(bool) ConstantTrue + 37: TypeInt 32 1 + 38: 37(int) Constant 1 + 40: TypePointer Function 16(float) + 45: TypePointer Function 17(fvec3) + 52: TypePointer Function 37(int) + 63: TypeVector 16(float) 2 + 64: TypePointer Function 63(fvec2) + 75: TypeMatrix 17(fvec3) 4 + 76: TypePointer Function 75 + 81: TypeVector 13(int) 3 + 82: 13(int) Constant 16 + 83: 13(int) Constant 8 + 84: 13(int) Constant 1 + 85: 81(ivec3) ConstantComposite 82 83 84 + 4(main): 2 Function None 3 + 5: Label + 25(rq_proceed): 24(ptr) Variable Function +35(intersectionType): 34(ptr) Variable Function + 41(rayTMin): 40(ptr) Variable Function + 43(rayFlags): 34(ptr) Variable Function +46(worldRayOrigin): 45(ptr) Variable Function +48(worldDirection): 45(ptr) Variable Function +50(intersectionT): 40(ptr) Variable Function + 53(customIndex): 52(ptr) Variable Function + 55(instanceId): 52(ptr) Variable Function + 57(sbtOffset): 34(ptr) Variable Function +59(geometryIndex): 52(ptr) Variable Function +61(primitiveIndex): 52(ptr) Variable Function + 65(barys): 64(ptr) Variable Function + 67(frontface): 24(ptr) Variable Function + 69(aabbOpaque): 24(ptr) Variable Function +71(objRayDirection): 45(ptr) Variable Function +73(objRayOrigin): 45(ptr) Variable Function + 77(objToWorld): 76(ptr) Variable Function + 79(worldToObj): 76(ptr) Variable Function + 12: 9 Load 11(tlas) + RayQueryInitializeKHR 8(rayQuery) 12 14 15 19 18 21 22 + 26: 23(bool) RayQueryProceedKHR 8(rayQuery) + Store 25(rq_proceed) 26 + Branch 27 + 27: Label + LoopMerge 29 30 None + Branch 31 + 31: Label + 32: 23(bool) Load 25(rq_proceed) + BranchConditional 32 28 29 + 28: Label + 33: 23(bool) RayQueryProceedKHR 8(rayQuery) + Store 25(rq_proceed) 33 + Branch 30 + 30: Label + Branch 27 + 29: Label + 39: 13(int) RayQueryGetIntersectionTypeKHR 8(rayQuery) 38 + Store 35(intersectionType) 39 + 42: 16(float) RayQueryGetRayTMinKHR 8(rayQuery) + Store 41(rayTMin) 42 + 44: 13(int) RayQueryGetRayFlagsKHR 8(rayQuery) + Store 43(rayFlags) 44 + 47: 17(fvec3) RayQueryGetWorldRayOriginKHR 8(rayQuery) + Store 46(worldRayOrigin) 47 + 49: 17(fvec3) RayQueryGetWorldRayDirectionKHR 8(rayQuery) + Store 48(worldDirection) 49 + 51: 16(float) RayQueryGetIntersectionTKHR 8(rayQuery) 38 + Store 50(intersectionT) 51 + 54: 37(int) RayQueryGetIntersectionInstanceCustomIndexKHR 8(rayQuery) 38 + Store 53(customIndex) 54 + 56: 37(int) RayQueryGetIntersectionInstanceIdKHR 8(rayQuery) 38 + Store 55(instanceId) 56 + 58: 13(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 8(rayQuery) 38 + Store 57(sbtOffset) 58 + 60: 37(int) RayQueryGetIntersectionGeometryIndexKHR 8(rayQuery) 38 + Store 59(geometryIndex) 60 + 62: 37(int) RayQueryGetIntersectionPrimitiveIndexKHR 8(rayQuery) 38 + Store 61(primitiveIndex) 62 + 66: 63(fvec2) RayQueryGetIntersectionBarycentricsKHR 8(rayQuery) 38 + Store 65(barys) 66 + 68: 23(bool) RayQueryGetIntersectionFrontFaceKHR 8(rayQuery) 38 + Store 67(frontface) 68 + 70: 23(bool) RayQueryGetIntersectionCandidateAABBOpaqueKHR 8(rayQuery) + Store 69(aabbOpaque) 70 + 72: 17(fvec3) RayQueryGetIntersectionObjectRayDirectionKHR 8(rayQuery) 38 + Store 71(objRayDirection) 72 + 74: 17(fvec3) RayQueryGetIntersectionObjectRayOriginKHR 8(rayQuery) 38 + Store 73(objRayOrigin) 74 + 78: 75 RayQueryGetIntersectionObjectToWorldKHR 8(rayQuery) 38 + Store 77(objToWorld) 78 + 80: 75 RayQueryGetIntersectionWorldToObjectKHR 8(rayQuery) 38 + Store 79(worldToObj) 80 + Return + FunctionEnd diff --git a/Test/rayQuery-types.comp b/Test/rayQuery-types.comp new file mode 100644 index 000000000..c70a3fc49 --- /dev/null +++ b/Test/rayQuery-types.comp @@ -0,0 +1,45 @@ +#version 460 +#extension GL_EXT_ray_query : require + +layout(local_size_x = 16, local_size_y = 8, local_size_z = 1) in; + +layout(binding = 0, set = 0) uniform accelerationStructureEXT tlas; + +void main() +{ + rayQueryEXT rayQuery; + rayQueryInitializeEXT(rayQuery, // Ray query + tlas, // Top-level acceleration structure + 0, // Ray flags + 0xFF, // 8-bit instance mask + vec3(0), // Ray origin + 0.0, // Minimum t-value + vec3(1, 0, 0), // Ray direction + 10000.0); // Maximum t-value + + // yes this is silly, just want to verify the return types + bool rq_proceed = rayQueryProceedEXT(rayQuery); + while(rq_proceed) + { + rq_proceed = rayQueryProceedEXT(rayQuery); + } + + const uint intersectionType = rayQueryGetIntersectionTypeEXT(rayQuery, true); + const float rayTMin = rayQueryGetRayTMinEXT(rayQuery); + const uint rayFlags = rayQueryGetRayFlagsEXT(rayQuery); + const vec3 worldRayOrigin = rayQueryGetWorldRayOriginEXT(rayQuery); + const vec3 worldDirection = rayQueryGetWorldRayDirectionEXT(rayQuery); + const float intersectionT = rayQueryGetIntersectionTEXT(rayQuery, true); + const int customIndex = rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true); + const int instanceId = rayQueryGetIntersectionInstanceIdEXT(rayQuery, true); + const uint sbtOffset = rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, true); + const int geometryIndex = rayQueryGetIntersectionGeometryIndexEXT(rayQuery, true); + const int primitiveIndex = rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true); + const vec2 barys = rayQueryGetIntersectionBarycentricsEXT(rayQuery, true); + const bool frontface = rayQueryGetIntersectionFrontFaceEXT(rayQuery, true); + const bool aabbOpaque = rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQuery); + const vec3 objRayDirection = rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true); + const vec3 objRayOrigin = rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true); + const mat4x3 objToWorld = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, true); + const mat4x3 worldToObj = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, true); +} diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index a393cccc9..b7f0df58a 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -241,6 +241,7 @@ INSTANTIATE_TEST_SUITE_P( "rayQuery-allOps.frag", "rayQuery-initialization.Error.comp", "rayQuery-global.rgen", + "rayQuery-types.comp", "spv.set.vert", "spv.double.comp", "spv.100ops.frag",