From 50a722818bc00a082d844d08c7974b6c4f02e3e7 Mon Sep 17 00:00:00 2001 From: Neslisah Torosdagli Date: Fri, 20 Mar 2020 18:23:27 -0400 Subject: [PATCH] GL_EXT_ray_query glslang updates, and test cases added. --- SPIRV/GlslangToSpv.cpp | 67 +++- SPIRV/spirv.hpp | 25 -- Test/baseResults/rayQuery-allOps.rgen.out | 438 +++++++++++++++++++++ .../baseResults/rayQuery-array-2d-dynamic.rgen.out | 199 ++++++++++ Test/baseResults/rayQuery-decls.rgen.out | 197 +++++++++ Test/baseResults/rayQuery-initialize.rgen.out | 168 ++++++++ Test/baseResults/rayQuery-no-cse.rgen.out | 179 +++++++++ Test/baseResults/rayQuery.rgen.out | 84 ++++ Test/rayQuery-allOps.rgen | 212 ++++++++++ Test/rayQuery-array-2d-dynamic.rgen | 36 ++ Test/rayQuery-decls.rgen | 53 +++ Test/rayQuery-initialize.rgen | 33 ++ Test/rayQuery-no-cse.rgen | 35 ++ Test/rayQuery.rgen | 23 ++ glslang/Include/Types.h | 2 +- glslang/MachineIndependent/Initialize.cpp | 2 +- glslang/MachineIndependent/Intermediate.cpp | 1 - gtests/Spv.FromFile.cpp | 8 + 18 files changed, 1724 insertions(+), 38 deletions(-) create mode 100644 Test/baseResults/rayQuery-allOps.rgen.out create mode 100644 Test/baseResults/rayQuery-array-2d-dynamic.rgen.out create mode 100644 Test/baseResults/rayQuery-decls.rgen.out create mode 100644 Test/baseResults/rayQuery-initialize.rgen.out create mode 100644 Test/baseResults/rayQuery-no-cse.rgen.out create mode 100644 Test/baseResults/rayQuery.rgen.out create mode 100644 Test/rayQuery-allOps.rgen create mode 100644 Test/rayQuery-array-2d-dynamic.rgen create mode 100644 Test/rayQuery-decls.rgen create mode 100644 Test/rayQuery-initialize.rgen create mode 100644 Test/rayQuery-no-cse.rgen create mode 100644 Test/rayQuery.rgen diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index c3808c4..0d29b2b 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -1477,6 +1477,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, builder.addExecutionMode(shaderEntry, spv::ExecutionModeDepthReplacing); #ifndef GLSLANG_WEB + switch(glslangIntermediate->getDepth()) { case glslang::EldGreater: mode = spv::ExecutionModeDepthGreater; break; case glslang::EldLess: mode = spv::ExecutionModeDepthLess; break; @@ -1514,7 +1515,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, builder.addExtension(spv::E_SPV_EXT_fragment_shader_interlock); } #endif - break; + break; case EShLangCompute: builder.addCapability(spv::CapabilityShader); @@ -2289,6 +2290,13 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI case glslang::EOpEndStreamPrimitive: builder.createNoResultOp(spv::OpEndStreamPrimitive, operand); return false; + case glslang::EOpRayQueryTerminate: + builder.createNoResultOp(spv::OpRayQueryTerminateKHR, operand); + return false; + case glslang::EOpRayQueryConfirmIntersection: + builder.createNoResultOp(spv::OpRayQueryConfirmIntersectionKHR, operand); + return false; + #endif default: @@ -2710,9 +2718,32 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt case glslang::EOpRayQueryTerminate: case glslang::EOpRayQueryGenerateIntersection: case glslang::EOpRayQueryConfirmIntersection: + builder.addExtension("SPV_KHR_ray_query"); + builder.addCapability(spv::CapabilityRayQueryProvisionalKHR); noReturnValue = true; break; - + case glslang::EOpRayQueryProceed: + case glslang::EOpRayQueryGetIntersectionType: + case glslang::EOpRayQueryGetRayTMin: + case glslang::EOpRayQueryGetRayFlags: + case glslang::EOpRayQueryGetIntersectionT: + case glslang::EOpRayQueryGetIntersectionInstanceCustomIndex: + case glslang::EOpRayQueryGetIntersectionInstanceId: + case glslang::EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset: + case glslang::EOpRayQueryGetIntersectionGeometryIndex: + case glslang::EOpRayQueryGetIntersectionPrimitiveIndex: + case glslang::EOpRayQueryGetIntersectionBarycentrics: + case glslang::EOpRayQueryGetIntersectionFrontFace: + case glslang::EOpRayQueryGetIntersectionCandidateAABBOpaque: + case glslang::EOpRayQueryGetIntersectionObjectRayDirection: + case glslang::EOpRayQueryGetIntersectionObjectRayOrigin: + case glslang::EOpRayQueryGetWorldRayDirection: + case glslang::EOpRayQueryGetWorldRayOrigin: + case glslang::EOpRayQueryGetIntersectionObjectToWorld: + case glslang::EOpRayQueryGetIntersectionWorldToObject: + builder.addExtension("SPV_KHR_ray_query"); + builder.addCapability(spv::CapabilityRayQueryProvisionalKHR); + break; case glslang::EOpCooperativeMatrixLoad: case glslang::EOpCooperativeMatrixStore: noReturnValue = true; @@ -2780,6 +2811,9 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt break; case glslang::EOpRayQueryInitialize: + case glslang::EOpRayQueryTerminate: + case glslang::EOpRayQueryConfirmIntersection: + case glslang::EOpRayQueryProceed: case glslang::EOpRayQueryGenerateIntersection: case glslang::EOpRayQueryGetIntersectionType: case glslang::EOpRayQueryGetIntersectionT: @@ -5947,6 +5981,24 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, OpDe case glslang::EOpFwidthCoarse: unaryOp = spv::OpFwidthCoarse; break; + case glslang::EOpRayQueryProceed: + unaryOp = spv::OpRayQueryProceedKHR; + break; + case glslang::EOpRayQueryGetRayTMin: + unaryOp = spv::OpRayQueryGetRayTMinKHR; + break; + case glslang::EOpRayQueryGetRayFlags: + unaryOp = spv::OpRayQueryGetRayFlagsKHR; + break; + case glslang::EOpRayQueryGetWorldRayOrigin: + unaryOp = spv::OpRayQueryGetWorldRayOriginKHR; + break; + case glslang::EOpRayQueryGetWorldRayDirection: + unaryOp = spv::OpRayQueryGetWorldRayDirectionKHR; + break; + case glslang::EOpRayQueryGetIntersectionCandidateAABBOpaque: + unaryOp = spv::OpRayQueryGetIntersectionCandidateAABBOpaqueKHR; + break; case glslang::EOpInterpolateAtCentroid: if (typeProxy == glslang::EbtFloat16) builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float); @@ -7688,10 +7740,9 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv:: case glslang::EOpRayQueryProceed: { typeId = builder.makeBoolType(); opCode = spv::OpRayQueryProceedKHR; - } - break; + } break; case glslang::EOpRayQueryGetIntersectionType: { - typeId = builder.makeIntType(32); + typeId = builder.makeUintType(32); opCode = spv::OpRayQueryGetIntersectionTypeKHR; } break; case glslang::EOpRayQueryGetRayTMin: { @@ -7703,7 +7754,7 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv:: opCode = spv::OpRayQueryGetRayFlagsKHR; } break; case glslang::EOpRayQueryGetIntersectionT: { - typeId = builder.makeIntType(32); + typeId = builder.makeFloatType(32); opCode = spv::OpRayQueryGetIntersectionTKHR; } break; case glslang::EOpRayQueryGetIntersectionInstanceCustomIndex: { @@ -7756,14 +7807,10 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv:: } break; case glslang::EOpRayQueryGetIntersectionObjectToWorld: { typeId = builder.makeMatrixType(builder.makeFloatType(32), 4, 3); - // https://gitlab.khronos.org/spirv/spirv-extensions/blob/cdf44fd4b854a5297bf2191d4f57f9bccbc49098/SPV_KHR_ray_query.asciidoc#ray_query_candidate_intersection_type - // or per description is it typeId = builder.makeVectorType(builder.makeVectorType(builder.makeFloatType(32), 3), 4); opCode = spv::OpRayQueryGetIntersectionObjectToWorldKHR; } break; case glslang::EOpRayQueryGetIntersectionWorldToObject: { typeId = builder.makeMatrixType(builder.makeFloatType(32), 4, 3); - // https://gitlab.khronos.org/spirv/spirv-extensions/blob/cdf44fd4b854a5297bf2191d4f57f9bccbc49098/SPV_KHR_ray_query.asciidoc#ray_query_candidate_intersection_type - // or per description is it typeId = builder.makeVectorType(builder.makeVectorType(builder.makeFloatType(32), 3), 4); opCode = spv::OpRayQueryGetIntersectionWorldToObjectKHR; } break; case glslang::EOpWritePackedPrimitiveIndices4x8NV: diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp index c2f7909..b371137 100644 --- a/SPIRV/spirv.hpp +++ b/SPIRV/spirv.hpp @@ -1940,31 +1940,6 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpRayQueryGetIntersectionObjectToWorldKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetIntersectionWorldToObjectKHR: *hasResult = true; *hasResultType = true; break; case OpExecuteCallableNV: *hasResult = false; *hasResultType = false; break; - case OpTypeAccelerationStructureKHR: *hasResult = true; *hasResultType = false; break; - case OpTypeRayQueryProvisionalKHR: *hasResult = true; *hasResultType = false; break; - case OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; - case OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; - case OpRayQueryGenerateIntersectionKHR: *hasResult = false; *hasResultType = false; break; - case OpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; - case OpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetRayTMinKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetRayFlagsKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionTKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionInstanceCustomIndexKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionInstanceIdKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionGeometryIndexKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionPrimitiveIndexKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionBarycentricsKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionFrontFaceKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionCandidateAABBOpaqueKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionObjectRayDirectionKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionObjectRayOriginKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetWorldRayDirectionKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetWorldRayOriginKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionObjectToWorldKHR: *hasResult = true; *hasResultType = true; break; - case OpRayQueryGetIntersectionWorldToObjectKHR: *hasResult = true; *hasResultType = true; break; case OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break; case OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break; case OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break; diff --git a/Test/baseResults/rayQuery-allOps.rgen.out b/Test/baseResults/rayQuery-allOps.rgen.out new file mode 100644 index 0000000..826094c --- /dev/null +++ b/Test/baseResults/rayQuery-allOps.rgen.out @@ -0,0 +1,438 @@ +rayQuery-allOps.rgen +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 265 + + Capability RayQueryProvisionalKHR + Capability RayTracingNV + Extension "SPV_KHR_ray_query" + Extension "SPV_NV_ray_tracing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint RayGenerationKHR 4 "main" + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 6 "doSomething(" + Name 10 "Ray" + MemberName 10(Ray) 0 "pos" + MemberName 10(Ray) 1 "tmin" + MemberName 10(Ray) 2 "dir" + MemberName 10(Ray) 3 "tmax" + Name 12 "makeRayDesc(" + Name 15 "Log" + MemberName 15(Log) 0 "x" + MemberName 15(Log) 1 "y" + Name 17 "" + Name 26 "ray" + Name 45 "rayQuery" + Name 48 "rtas" + Name 51 "ray" + Name 69 "candidateType" + Name 79 "_mat4x3" + Name 84 "_mat3x4" + Name 146 "t" + Name 160 "committedStatus" + Name 246 "o" + Name 249 "d" + Name 260 "Ray" + MemberName 260(Ray) 0 "pos" + MemberName 260(Ray) 1 "tmin" + MemberName 260(Ray) 2 "dir" + MemberName 260(Ray) 3 "tmax" + Name 262 "Rays" + MemberName 262(Rays) 0 "rays" + Name 264 "" + MemberDecorate 15(Log) 0 Offset 0 + MemberDecorate 15(Log) 1 Offset 4 + Decorate 15(Log) BufferBlock + Decorate 17 DescriptorSet 0 + Decorate 17 Binding 0 + Decorate 48(rtas) DescriptorSet 0 + Decorate 48(rtas) Binding 1 + MemberDecorate 260(Ray) 0 Offset 0 + MemberDecorate 260(Ray) 1 Offset 12 + MemberDecorate 260(Ray) 2 Offset 16 + MemberDecorate 260(Ray) 3 Offset 28 + Decorate 261 ArrayStride 32 + MemberDecorate 262(Rays) 0 Offset 0 + Decorate 262(Rays) BufferBlock + Decorate 264 DescriptorSet 0 + Decorate 264 Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 8: TypeFloat 32 + 9: TypeVector 8(float) 3 + 10(Ray): TypeStruct 9(fvec3) 8(float) 9(fvec3) 8(float) + 11: TypeFunction 10(Ray) + 14: TypeInt 32 0 + 15(Log): TypeStruct 14(int) 14(int) + 16: TypePointer Uniform 15(Log) + 17: 16(ptr) Variable Uniform + 18: TypeInt 32 1 + 19: 18(int) Constant 0 + 20: 14(int) Constant 0 + 21: TypePointer Uniform 14(int) + 23: 18(int) Constant 1 + 25: TypePointer Function 10(Ray) + 27: 8(float) Constant 0 + 28: 9(fvec3) ConstantComposite 27 27 27 + 29: TypePointer Function 9(fvec3) + 31: 18(int) Constant 2 + 32: 8(float) Constant 1065353216 + 33: 9(fvec3) ConstantComposite 32 27 27 + 35: TypePointer Function 8(float) + 37: 18(int) Constant 3 + 38: 8(float) Constant 1176255488 + 43: TypeRayQueryProvisionalKHR + 44: TypePointer Function 43 + 46: TypeAccelerationStructureKHR + 47: TypePointer UniformConstant 46 + 48(rtas): 47(ptr) Variable UniformConstant + 50: 14(int) Constant 255 + 66: TypeBool + 68: TypePointer Function 14(int) + 70: 66(bool) ConstantFalse + 77: TypeMatrix 9(fvec3) 4 + 78: TypePointer Function 77 + 81: TypeVector 8(float) 4 + 82: TypeMatrix 81(fvec4) 3 + 83: TypePointer Function 82 + 88: 66(bool) ConstantTrue + 93: TypeVector 8(float) 2 + 147: 8(float) Constant 1056964608 + 179: 14(int) Constant 1 + 202: 14(int) Constant 2 + 260(Ray): TypeStruct 9(fvec3) 8(float) 9(fvec3) 8(float) + 261: TypeRuntimeArray 260(Ray) + 262(Rays): TypeStruct 261 + 263: TypePointer Uniform 262(Rays) + 264: 263(ptr) Variable Uniform + 4(main): 2 Function None 3 + 5: Label + 45(rayQuery): 44(ptr) Variable Function + 51(ray): 25(ptr) Variable Function +69(candidateType): 68(ptr) Variable Function + 79(_mat4x3): 78(ptr) Variable Function + 84(_mat3x4): 83(ptr) Variable Function + 146(t): 35(ptr) Variable Function +160(committedStatus): 68(ptr) Variable Function + 246(o): 29(ptr) Variable Function + 249(d): 29(ptr) Variable Function + 49: 46 Load 48(rtas) + 52: 29(ptr) AccessChain 51(ray) 19 + 53: 9(fvec3) Load 52 + 54: 35(ptr) AccessChain 51(ray) 23 + 55: 8(float) Load 54 + 56: 29(ptr) AccessChain 51(ray) 31 + 57: 9(fvec3) Load 56 + 58: 35(ptr) AccessChain 51(ray) 37 + 59: 8(float) Load 58 + RayQueryInitializeKHR 45(rayQuery) 49 20 50 53 55 57 59 + Branch 60 + 60: Label + LoopMerge 62 63 None + Branch 64 + 64: Label + 65: 43 Load 45(rayQuery) + 67: 66(bool) RayQueryProceedKHR 65 + BranchConditional 67 61 62 + 61: Label + 71: 14(int) RayQueryGetIntersectionTypeKHR 45(rayQuery) 19 + Store 69(candidateType) 71 + 72: 14(int) Load 69(candidateType) + SelectionMerge 75 None + Switch 72 75 + case 0: 73 + case 1: 74 + 73: Label + 76: 43 Load 45(rayQuery) + RayQueryTerminateKHR 76 + 80: 77 RayQueryGetIntersectionObjectToWorldKHR 45(rayQuery) 19 + Store 79(_mat4x3) 80 + 85: 77 Load 79(_mat4x3) + 86: 82 Transpose 85 + Store 84(_mat3x4) 86 + 87: 43 Load 45(rayQuery) + RayQueryConfirmIntersectionKHR 87 + 89: 66(bool) RayQueryGetIntersectionFrontFaceKHR 45(rayQuery) 23 + SelectionMerge 91 None + BranchConditional 89 90 91 + 90: Label + 92: 2 FunctionCall 6(doSomething() + Branch 91 + 91: Label + 94: 93(fvec2) RayQueryGetIntersectionBarycentricsKHR 45(rayQuery) 23 + 95: 8(float) CompositeExtract 94 0 + 96: 66(bool) FOrdEqual 95 27 + SelectionMerge 98 None + BranchConditional 96 97 98 + 97: Label + 99: 2 FunctionCall 6(doSomething() + Branch 98 + 98: Label + 100: 18(int) RayQueryGetIntersectionInstanceCustomIndexKHR 45(rayQuery) 23 + 101: 66(bool) SGreaterThan 100 19 + SelectionMerge 103 None + BranchConditional 101 102 103 + 102: Label + 104: 2 FunctionCall 6(doSomething() + Branch 103 + 103: Label + 105: 18(int) RayQueryGetIntersectionInstanceIdKHR 45(rayQuery) 23 + 106: 66(bool) SGreaterThan 105 19 + SelectionMerge 108 None + BranchConditional 106 107 108 + 107: Label + 109: 2 FunctionCall 6(doSomething() + Branch 108 + 108: Label + 110: 9(fvec3) RayQueryGetIntersectionObjectRayDirectionKHR 45(rayQuery) 23 + 111: 8(float) CompositeExtract 110 0 + 112: 66(bool) FOrdGreaterThan 111 27 + SelectionMerge 114 None + BranchConditional 112 113 114 + 113: Label + 115: 2 FunctionCall 6(doSomething() + Branch 114 + 114: Label + 116: 9(fvec3) RayQueryGetIntersectionObjectRayOriginKHR 45(rayQuery) 23 + 117: 8(float) CompositeExtract 116 0 + 118: 66(bool) FOrdGreaterThan 117 27 + SelectionMerge 120 None + BranchConditional 118 119 120 + 119: Label + 121: 2 FunctionCall 6(doSomething() + Branch 120 + 120: Label + 122: 18(int) RayQueryGetIntersectionPrimitiveIndexKHR 45(rayQuery) 23 + 123: 66(bool) SGreaterThan 122 19 + SelectionMerge 125 None + BranchConditional 123 124 125 + 124: Label + 126: 2 FunctionCall 6(doSomething() + Branch 125 + 125: Label + 127: 8(float) RayQueryGetIntersectionTKHR 45(rayQuery) 23 + 128: 66(bool) FOrdGreaterThan 127 27 + SelectionMerge 130 None + BranchConditional 128 129 130 + 129: Label + 131: 2 FunctionCall 6(doSomething() + Branch 130 + 130: Label + 132: 18(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 45(rayQuery) 23 + 133: 66(bool) UGreaterThan 132 20 + SelectionMerge 135 None + BranchConditional 133 134 135 + 134: Label + 136: 2 FunctionCall 6(doSomething() + Branch 135 + 135: Label + Branch 75 + 74: Label + 138: 77 RayQueryGetIntersectionObjectToWorldKHR 45(rayQuery) 19 + Store 79(_mat4x3) 138 + 139: 77 Load 79(_mat4x3) + 140: 82 Transpose 139 + Store 84(_mat3x4) 140 + 141: 43 Load 45(rayQuery) + 142: 66(bool) RayQueryGetIntersectionCandidateAABBOpaqueKHR 141 + SelectionMerge 144 None + BranchConditional 142 143 144 + 143: Label + 145: 2 FunctionCall 6(doSomething() + Branch 144 + 144: Label + Store 146(t) 147 + 148: 8(float) Load 146(t) + RayQueryGenerateIntersectionKHR 45(rayQuery) 148 + 149: 43 Load 45(rayQuery) + RayQueryTerminateKHR 149 + Branch 75 + 75: Label + Branch 63 + 63: Label + Branch 60 + 62: Label + 152: 35(ptr) AccessChain 84(_mat3x4) 19 20 + 153: 8(float) Load 152 + 154: 35(ptr) AccessChain 79(_mat4x3) 19 20 + 155: 8(float) Load 154 + 156: 66(bool) FOrdEqual 153 155 + SelectionMerge 158 None + BranchConditional 156 157 158 + 157: Label + 159: 2 FunctionCall 6(doSomething() + Branch 158 + 158: Label + 161: 14(int) RayQueryGetIntersectionTypeKHR 45(rayQuery) 23 + Store 160(committedStatus) 161 + 162: 14(int) Load 160(committedStatus) + SelectionMerge 166 None + Switch 162 166 + case 0: 163 + case 1: 164 + case 2: 165 + 163: Label + 167: 77 RayQueryGetIntersectionWorldToObjectKHR 45(rayQuery) 19 + Store 79(_mat4x3) 167 + 168: 77 Load 79(_mat4x3) + 169: 82 Transpose 168 + Store 84(_mat3x4) 169 + Branch 166 + 164: Label + 171: 77 RayQueryGetIntersectionWorldToObjectKHR 45(rayQuery) 23 + Store 79(_mat4x3) 171 + 172: 77 Load 79(_mat4x3) + 173: 82 Transpose 172 + Store 84(_mat3x4) 173 + 174: 66(bool) RayQueryGetIntersectionFrontFaceKHR 45(rayQuery) 23 + SelectionMerge 176 None + BranchConditional 174 175 176 + 175: Label + 177: 2 FunctionCall 6(doSomething() + Branch 176 + 176: Label + 178: 93(fvec2) RayQueryGetIntersectionBarycentricsKHR 45(rayQuery) 23 + 180: 8(float) CompositeExtract 178 1 + 181: 66(bool) FOrdEqual 180 27 + SelectionMerge 183 None + BranchConditional 181 182 183 + 182: Label + 184: 2 FunctionCall 6(doSomething() + Branch 183 + 183: Label + Branch 166 + 165: Label + 186: 18(int) RayQueryGetIntersectionGeometryIndexKHR 45(rayQuery) 23 + 187: 66(bool) SGreaterThan 186 19 + SelectionMerge 189 None + BranchConditional 187 188 189 + 188: Label + 190: 2 FunctionCall 6(doSomething() + Branch 189 + 189: Label + 191: 18(int) RayQueryGetIntersectionInstanceIdKHR 45(rayQuery) 23 + 192: 66(bool) SGreaterThan 191 19 + SelectionMerge 194 None + BranchConditional 192 193 194 + 193: Label + 195: 2 FunctionCall 6(doSomething() + Branch 194 + 194: Label + 196: 18(int) RayQueryGetIntersectionInstanceCustomIndexKHR 45(rayQuery) 23 + 197: 66(bool) SGreaterThan 196 19 + SelectionMerge 199 None + BranchConditional 197 198 199 + 198: Label + 200: 2 FunctionCall 6(doSomething() + Branch 199 + 199: Label + 201: 9(fvec3) RayQueryGetIntersectionObjectRayDirectionKHR 45(rayQuery) 23 + 203: 8(float) CompositeExtract 201 2 + 204: 66(bool) FOrdGreaterThan 203 27 + SelectionMerge 206 None + BranchConditional 204 205 206 + 205: Label + 207: 2 FunctionCall 6(doSomething() + Branch 206 + 206: Label + 208: 9(fvec3) RayQueryGetIntersectionObjectRayOriginKHR 45(rayQuery) 23 + 209: 8(float) CompositeExtract 208 0 + 210: 66(bool) FOrdGreaterThan 209 27 + SelectionMerge 212 None + BranchConditional 210 211 212 + 211: Label + 213: 2 FunctionCall 6(doSomething() + Branch 212 + 212: Label + 214: 18(int) RayQueryGetIntersectionPrimitiveIndexKHR 45(rayQuery) 23 + 215: 66(bool) SGreaterThan 214 19 + SelectionMerge 217 None + BranchConditional 215 216 217 + 216: Label + 218: 2 FunctionCall 6(doSomething() + Branch 217 + 217: Label + 219: 8(float) RayQueryGetIntersectionTKHR 45(rayQuery) 23 + 220: 66(bool) FOrdGreaterThan 219 27 + SelectionMerge 222 None + BranchConditional 220 221 222 + 221: Label + 223: 2 FunctionCall 6(doSomething() + Branch 222 + 222: Label + Branch 166 + 166: Label + 226: 35(ptr) AccessChain 84(_mat3x4) 19 20 + 227: 8(float) Load 226 + 228: 35(ptr) AccessChain 79(_mat4x3) 19 20 + 229: 8(float) Load 228 + 230: 66(bool) FOrdEqual 227 229 + SelectionMerge 232 None + BranchConditional 230 231 232 + 231: Label + 233: 2 FunctionCall 6(doSomething() + Branch 232 + 232: Label + 234: 43 Load 45(rayQuery) + 235: 14(int) RayQueryGetRayFlagsKHR 234 + 236: 66(bool) UGreaterThan 235 20 + SelectionMerge 238 None + BranchConditional 236 237 238 + 237: Label + 239: 2 FunctionCall 6(doSomething() + Branch 238 + 238: Label + 240: 43 Load 45(rayQuery) + 241: 8(float) RayQueryGetRayTMinKHR 240 + 242: 66(bool) FOrdGreaterThan 241 27 + SelectionMerge 244 None + BranchConditional 242 243 244 + 243: Label + 245: 2 FunctionCall 6(doSomething() + Branch 244 + 244: Label + 247: 43 Load 45(rayQuery) + 248: 9(fvec3) RayQueryGetWorldRayOriginKHR 247 + Store 246(o) 248 + 250: 43 Load 45(rayQuery) + 251: 9(fvec3) RayQueryGetWorldRayDirectionKHR 250 + Store 249(d) 251 + 252: 35(ptr) AccessChain 246(o) 20 + 253: 8(float) Load 252 + 254: 35(ptr) AccessChain 249(d) 202 + 255: 8(float) Load 254 + 256: 66(bool) FOrdEqual 253 255 + SelectionMerge 258 None + BranchConditional 256 257 258 + 257: Label + 259: 2 FunctionCall 6(doSomething() + Branch 258 + 258: Label + Return + FunctionEnd + 6(doSomething(): 2 Function None 3 + 7: Label + 22: 21(ptr) AccessChain 17 19 + Store 22 20 + 24: 21(ptr) AccessChain 17 23 + Store 24 20 + Return + FunctionEnd +12(makeRayDesc(): 10(Ray) Function None 11 + 13: Label + 26(ray): 25(ptr) Variable Function + 30: 29(ptr) AccessChain 26(ray) 19 + Store 30 28 + 34: 29(ptr) AccessChain 26(ray) 31 + Store 34 33 + 36: 35(ptr) AccessChain 26(ray) 23 + Store 36 27 + 39: 35(ptr) AccessChain 26(ray) 37 + Store 39 38 + 40: 10(Ray) Load 26(ray) + ReturnValue 40 + FunctionEnd diff --git a/Test/baseResults/rayQuery-array-2d-dynamic.rgen.out b/Test/baseResults/rayQuery-array-2d-dynamic.rgen.out new file mode 100644 index 0000000..e5af7ee --- /dev/null +++ b/Test/baseResults/rayQuery-array-2d-dynamic.rgen.out @@ -0,0 +1,199 @@ +rayQuery-array-2d-dynamic.rgen +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 126 + + Capability RayQueryProvisionalKHR + Capability RayTracingNV + Extension "SPV_KHR_ray_query" + Extension "SPV_NV_ray_tracing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint RayGenerationKHR 4 "main" 23 28 + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 8 "launchIndex(" + Name 14 "Ray" + MemberName 14(Ray) 0 "pos" + MemberName 14(Ray) 1 "tmin" + MemberName 14(Ray) 2 "dir" + MemberName 14(Ray) 3 "tmax" + Name 19 "doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;" + Name 17 "rayQuery" + Name 18 "ray" + Name 23 "gl_LaunchIDNV" + Name 28 "gl_LaunchSizeNV" + Name 50 "rtas" + Name 68 "index" + Name 70 "ray" + Name 71 "Ray" + MemberName 71(Ray) 0 "pos" + MemberName 71(Ray) 1 "tmin" + MemberName 71(Ray) 2 "dir" + MemberName 71(Ray) 3 "tmax" + Name 73 "Rays" + MemberName 73(Rays) 0 "rays" + Name 75 "" + Name 90 "rayQuery" + Name 92 "param" + Name 95 "param" + Name 118 "C" + Name 120 "param" + Name 123 "param" + Decorate 23(gl_LaunchIDNV) BuiltIn LaunchIdKHR + Decorate 28(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR + Decorate 50(rtas) DescriptorSet 0 + Decorate 50(rtas) Binding 0 + MemberDecorate 71(Ray) 0 Offset 0 + MemberDecorate 71(Ray) 1 Offset 12 + MemberDecorate 71(Ray) 2 Offset 16 + MemberDecorate 71(Ray) 3 Offset 28 + Decorate 72 ArrayStride 32 + MemberDecorate 73(Rays) 0 Offset 0 + Decorate 73(Rays) BufferBlock + Decorate 75 DescriptorSet 0 + Decorate 75 Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypeFunction 6(int) + 10: TypeRayQueryProvisionalKHR + 11: TypePointer Function 10 + 12: TypeFloat 32 + 13: TypeVector 12(float) 3 + 14(Ray): TypeStruct 13(fvec3) 12(float) 13(fvec3) 12(float) + 15: TypePointer Function 14(Ray) + 16: TypeFunction 2 11(ptr) 15(ptr) + 21: TypeVector 6(int) 3 + 22: TypePointer Input 21(ivec3) +23(gl_LaunchIDNV): 22(ptr) Variable Input + 24: 6(int) Constant 2 + 25: TypePointer Input 6(int) +28(gl_LaunchSizeNV): 22(ptr) Variable Input + 29: 6(int) Constant 0 + 33: 6(int) Constant 1 + 48: TypeAccelerationStructureKHR + 49: TypePointer UniformConstant 48 + 50(rtas): 49(ptr) Variable UniformConstant + 52: TypeInt 32 1 + 53: 52(int) Constant 0 + 54: TypePointer Function 13(fvec3) + 57: 52(int) Constant 1 + 58: TypePointer Function 12(float) + 61: 52(int) Constant 2 + 64: 52(int) Constant 3 + 67: TypePointer Function 6(int) + 71(Ray): TypeStruct 13(fvec3) 12(float) 13(fvec3) 12(float) + 72: TypeRuntimeArray 71(Ray) + 73(Rays): TypeStruct 72 + 74: TypePointer Uniform 73(Rays) + 75: 74(ptr) Variable Uniform + 77: TypePointer Uniform 71(Ray) + 88: TypeArray 10 24 + 89: TypePointer Function 88 + 117: TypePointer Private 52(int) + 118(C): 117(ptr) Variable Private + 4(main): 2 Function None 3 + 5: Label + 68(index): 67(ptr) Variable Function + 70(ray): 15(ptr) Variable Function + 90(rayQuery): 89(ptr) Variable Function + 92(param): 11(ptr) Variable Function + 95(param): 15(ptr) Variable Function + 120(param): 11(ptr) Variable Function + 123(param): 15(ptr) Variable Function + 69: 6(int) FunctionCall 8(launchIndex() + Store 68(index) 69 + 76: 6(int) Load 68(index) + 78: 77(ptr) AccessChain 75 53 76 + 79: 71(Ray) Load 78 + 80: 13(fvec3) CompositeExtract 79 0 + 81: 54(ptr) AccessChain 70(ray) 53 + Store 81 80 + 82: 12(float) CompositeExtract 79 1 + 83: 58(ptr) AccessChain 70(ray) 57 + Store 83 82 + 84: 13(fvec3) CompositeExtract 79 2 + 85: 54(ptr) AccessChain 70(ray) 61 + Store 85 84 + 86: 12(float) CompositeExtract 79 3 + 87: 58(ptr) AccessChain 70(ray) 64 + Store 87 86 + 91: 6(int) Load 68(index) + 93: 11(ptr) AccessChain 90(rayQuery) 53 + 94: 10 Load 93 + Store 92(param) 94 + 96: 77(ptr) AccessChain 75 53 91 + 97: 71(Ray) Load 96 + 98: 13(fvec3) CompositeExtract 97 0 + 99: 54(ptr) AccessChain 95(param) 53 + Store 99 98 + 100: 12(float) CompositeExtract 97 1 + 101: 58(ptr) AccessChain 95(param) 57 + Store 101 100 + 102: 13(fvec3) CompositeExtract 97 2 + 103: 54(ptr) AccessChain 95(param) 61 + Store 103 102 + 104: 12(float) CompositeExtract 97 3 + 105: 58(ptr) AccessChain 95(param) 64 + Store 105 104 + 106: 2 FunctionCall 19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;) 92(param) 95(param) + 107: 11(ptr) AccessChain 90(rayQuery) 57 + 108: 48 Load 50(rtas) + 109: 54(ptr) AccessChain 70(ray) 53 + 110: 13(fvec3) Load 109 + 111: 58(ptr) AccessChain 70(ray) 57 + 112: 12(float) Load 111 + 113: 54(ptr) AccessChain 70(ray) 61 + 114: 13(fvec3) Load 113 + 115: 58(ptr) AccessChain 70(ray) 64 + 116: 12(float) Load 115 + RayQueryInitializeKHR 107 108 33 24 110 112 114 116 + 119: 52(int) Load 118(C) + 121: 11(ptr) AccessChain 90(rayQuery) 119 + 122: 10 Load 121 + Store 120(param) 122 + 124: 14(Ray) Load 70(ray) + Store 123(param) 124 + 125: 2 FunctionCall 19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;) 120(param) 123(param) + Return + FunctionEnd + 8(launchIndex(): 6(int) Function None 7 + 9: Label + 26: 25(ptr) AccessChain 23(gl_LaunchIDNV) 24 + 27: 6(int) Load 26 + 30: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 29 + 31: 6(int) Load 30 + 32: 6(int) IMul 27 31 + 34: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 33 + 35: 6(int) Load 34 + 36: 6(int) IMul 32 35 + 37: 25(ptr) AccessChain 23(gl_LaunchIDNV) 33 + 38: 6(int) Load 37 + 39: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 29 + 40: 6(int) Load 39 + 41: 6(int) IMul 38 40 + 42: 6(int) IAdd 36 41 + 43: 25(ptr) AccessChain 23(gl_LaunchIDNV) 29 + 44: 6(int) Load 43 + 45: 6(int) IAdd 42 44 + ReturnValue 45 + FunctionEnd +19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;): 2 Function None 16 + 17(rayQuery): 11(ptr) FunctionParameter + 18(ray): 15(ptr) FunctionParameter + 20: Label + 51: 48 Load 50(rtas) + 55: 54(ptr) AccessChain 18(ray) 53 + 56: 13(fvec3) Load 55 + 59: 58(ptr) AccessChain 18(ray) 57 + 60: 12(float) Load 59 + 62: 54(ptr) AccessChain 18(ray) 61 + 63: 13(fvec3) Load 62 + 65: 58(ptr) AccessChain 18(ray) 64 + 66: 12(float) Load 65 + RayQueryInitializeKHR 17(rayQuery) 51 29 33 56 60 63 66 + Return + FunctionEnd diff --git a/Test/baseResults/rayQuery-decls.rgen.out b/Test/baseResults/rayQuery-decls.rgen.out new file mode 100644 index 0000000..7a40d43 --- /dev/null +++ b/Test/baseResults/rayQuery-decls.rgen.out @@ -0,0 +1,197 @@ +rayQuery-decls.rgen +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 127 + + Capability RayQueryProvisionalKHR + Capability RayTracingNV + Extension "SPV_KHR_ray_query" + Extension "SPV_NV_ray_tracing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint RayGenerationKHR 4 "main" 12 17 + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 8 "launchIndex(" + Name 12 "gl_LaunchIDNV" + Name 17 "gl_LaunchSizeNV" + Name 38 "index" + Name 42 "Ray" + MemberName 42(Ray) 0 "pos" + MemberName 42(Ray) 1 "tmin" + MemberName 42(Ray) 2 "dir" + MemberName 42(Ray) 3 "tmax" + Name 44 "ray" + Name 45 "Ray" + MemberName 45(Ray) 0 "pos" + MemberName 45(Ray) 1 "tmin" + MemberName 45(Ray) 2 "dir" + MemberName 45(Ray) 3 "tmax" + Name 47 "Rays" + MemberName 47(Rays) 0 "rays" + Name 49 "" + Name 73 "g_rayQueryArray" + Name 74 "block" + MemberName 74(block) 0 "idx" + Name 76 "" + Name 81 "rayQuery0b" + Name 86 "rayQuery0a" + Name 89 "rayQuery0c" + Name 96 "rtas" + Name 106 "rayQuery1c" + Name 126 "g_rayQueryUnused" + Decorate 12(gl_LaunchIDNV) BuiltIn LaunchIdKHR + Decorate 17(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR + MemberDecorate 45(Ray) 0 Offset 0 + MemberDecorate 45(Ray) 1 Offset 12 + MemberDecorate 45(Ray) 2 Offset 16 + MemberDecorate 45(Ray) 3 Offset 28 + Decorate 46 ArrayStride 32 + MemberDecorate 47(Rays) 0 Offset 0 + Decorate 47(Rays) BufferBlock + Decorate 49 DescriptorSet 0 + Decorate 49 Binding 2 + MemberDecorate 74(block) 0 Offset 0 + Decorate 74(block) BufferBlock + Decorate 96(rtas) DescriptorSet 0 + Decorate 96(rtas) Binding 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypeFunction 6(int) + 10: TypeVector 6(int) 3 + 11: TypePointer Input 10(ivec3) +12(gl_LaunchIDNV): 11(ptr) Variable Input + 13: 6(int) Constant 2 + 14: TypePointer Input 6(int) +17(gl_LaunchSizeNV): 11(ptr) Variable Input + 18: 6(int) Constant 0 + 22: 6(int) Constant 1 + 37: TypePointer Function 6(int) + 40: TypeFloat 32 + 41: TypeVector 40(float) 3 + 42(Ray): TypeStruct 41(fvec3) 40(float) 41(fvec3) 40(float) + 43: TypePointer Function 42(Ray) + 45(Ray): TypeStruct 41(fvec3) 40(float) 41(fvec3) 40(float) + 46: TypeRuntimeArray 45(Ray) + 47(Rays): TypeStruct 46 + 48: TypePointer Uniform 47(Rays) + 49: 48(ptr) Variable Uniform + 50: TypeInt 32 1 + 51: 50(int) Constant 0 + 53: TypePointer Uniform 45(Ray) + 57: TypePointer Function 41(fvec3) + 60: 50(int) Constant 1 + 61: TypePointer Function 40(float) + 64: 50(int) Constant 2 + 67: 50(int) Constant 3 + 69: TypeRayQueryProvisionalKHR + 70: 6(int) Constant 4 + 71: TypeArray 69 70 + 72: TypePointer Function 71 + 74(block): TypeStruct 6(int) + 75: TypePointer ShaderRecordBufferKHR 74(block) + 76: 75(ptr) Variable ShaderRecordBufferKHR + 77: TypePointer ShaderRecordBufferKHR 6(int) + 80: TypePointer Function 69 + 94: TypeAccelerationStructureKHR + 95: TypePointer UniformConstant 94 + 96(rtas): 95(ptr) Variable UniformConstant + 117: 6(int) Constant 3 + 4(main): 2 Function None 3 + 5: Label + 38(index): 37(ptr) Variable Function + 44(ray): 43(ptr) Variable Function +73(g_rayQueryArray): 72(ptr) Variable Function + 81(rayQuery0b): 80(ptr) Variable Function + 86(rayQuery0a): 80(ptr) Variable Function + 89(rayQuery0c): 80(ptr) Variable Function + 106(rayQuery1c): 80(ptr) Variable Function +126(g_rayQueryUnused): 80(ptr) Variable Function + 39: 6(int) FunctionCall 8(launchIndex() + Store 38(index) 39 + 52: 6(int) Load 38(index) + 54: 53(ptr) AccessChain 49 51 52 + 55: 45(Ray) Load 54 + 56: 41(fvec3) CompositeExtract 55 0 + 58: 57(ptr) AccessChain 44(ray) 51 + Store 58 56 + 59: 40(float) CompositeExtract 55 1 + 62: 61(ptr) AccessChain 44(ray) 60 + Store 62 59 + 63: 41(fvec3) CompositeExtract 55 2 + 65: 57(ptr) AccessChain 44(ray) 64 + Store 65 63 + 66: 40(float) CompositeExtract 55 3 + 68: 61(ptr) AccessChain 44(ray) 67 + Store 68 66 + 78: 77(ptr) AccessChain 76 51 + 79: 6(int) Load 78 + 82: 69 Load 81(rayQuery0b) + 83: 80(ptr) AccessChain 73(g_rayQueryArray) 79 + Store 83 82 + 84: 77(ptr) AccessChain 76 51 + 85: 6(int) Load 84 + 87: 69 Load 86(rayQuery0a) + 88: 80(ptr) AccessChain 73(g_rayQueryArray) 85 + Store 88 87 + 90: 77(ptr) AccessChain 76 51 + 91: 6(int) Load 90 + 92: 80(ptr) AccessChain 73(g_rayQueryArray) 91 + 93: 69 Load 92 + Store 89(rayQuery0c) 93 + 97: 94 Load 96(rtas) + 98: 57(ptr) AccessChain 44(ray) 51 + 99: 41(fvec3) Load 98 + 100: 61(ptr) AccessChain 44(ray) 60 + 101: 40(float) Load 100 + 102: 57(ptr) AccessChain 44(ray) 64 + 103: 41(fvec3) Load 102 + 104: 61(ptr) AccessChain 44(ray) 67 + 105: 40(float) Load 104 + RayQueryInitializeKHR 89(rayQuery0c) 97 22 13 99 101 103 105 + 107: 94 Load 96(rtas) + 108: 57(ptr) AccessChain 44(ray) 51 + 109: 41(fvec3) Load 108 + 110: 61(ptr) AccessChain 44(ray) 60 + 111: 40(float) Load 110 + 112: 57(ptr) AccessChain 44(ray) 64 + 113: 41(fvec3) Load 112 + 114: 61(ptr) AccessChain 44(ray) 67 + 115: 40(float) Load 114 + RayQueryInitializeKHR 106(rayQuery1c) 107 22 22 109 111 113 115 + 116: 94 Load 96(rtas) + 118: 57(ptr) AccessChain 44(ray) 51 + 119: 41(fvec3) Load 118 + 120: 61(ptr) AccessChain 44(ray) 60 + 121: 40(float) Load 120 + 122: 57(ptr) AccessChain 44(ray) 64 + 123: 41(fvec3) Load 122 + 124: 61(ptr) AccessChain 44(ray) 67 + 125: 40(float) Load 124 + RayQueryInitializeKHR 106(rayQuery1c) 116 117 70 119 121 123 125 + Return + FunctionEnd + 8(launchIndex(): 6(int) Function None 7 + 9: Label + 15: 14(ptr) AccessChain 12(gl_LaunchIDNV) 13 + 16: 6(int) Load 15 + 19: 14(ptr) AccessChain 17(gl_LaunchSizeNV) 18 + 20: 6(int) Load 19 + 21: 6(int) IMul 16 20 + 23: 14(ptr) AccessChain 17(gl_LaunchSizeNV) 22 + 24: 6(int) Load 23 + 25: 6(int) IMul 21 24 + 26: 14(ptr) AccessChain 12(gl_LaunchIDNV) 22 + 27: 6(int) Load 26 + 28: 14(ptr) AccessChain 17(gl_LaunchSizeNV) 18 + 29: 6(int) Load 28 + 30: 6(int) IMul 27 29 + 31: 6(int) IAdd 25 30 + 32: 14(ptr) AccessChain 12(gl_LaunchIDNV) 18 + 33: 6(int) Load 32 + 34: 6(int) IAdd 31 33 + ReturnValue 34 + FunctionEnd diff --git a/Test/baseResults/rayQuery-initialize.rgen.out b/Test/baseResults/rayQuery-initialize.rgen.out new file mode 100644 index 0000000..f7e05a9 --- /dev/null +++ b/Test/baseResults/rayQuery-initialize.rgen.out @@ -0,0 +1,168 @@ +rayQuery-initialize.rgen +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 103 + + Capability RayQueryProvisionalKHR + Capability RayTracingNV + Extension "SPV_KHR_ray_query" + Extension "SPV_NV_ray_tracing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint RayGenerationKHR 4 "main" 23 28 + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 8 "launchIndex(" + Name 14 "Ray" + MemberName 14(Ray) 0 "pos" + MemberName 14(Ray) 1 "tmin" + MemberName 14(Ray) 2 "dir" + MemberName 14(Ray) 3 "tmax" + Name 19 "doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;" + Name 17 "rayQuery" + Name 18 "ray" + Name 23 "gl_LaunchIDNV" + Name 28 "gl_LaunchSizeNV" + Name 50 "rtas" + Name 68 "index" + Name 70 "ray" + Name 71 "Ray" + MemberName 71(Ray) 0 "pos" + MemberName 71(Ray) 1 "tmin" + MemberName 71(Ray) 2 "dir" + MemberName 71(Ray) 3 "tmax" + Name 73 "Rays" + MemberName 73(Rays) 0 "rays" + Name 75 "" + Name 88 "rayQuery" + Name 89 "param" + Name 91 "param" + Decorate 23(gl_LaunchIDNV) BuiltIn LaunchIdKHR + Decorate 28(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR + Decorate 50(rtas) DescriptorSet 0 + Decorate 50(rtas) Binding 0 + MemberDecorate 71(Ray) 0 Offset 0 + MemberDecorate 71(Ray) 1 Offset 12 + MemberDecorate 71(Ray) 2 Offset 16 + MemberDecorate 71(Ray) 3 Offset 28 + Decorate 72 ArrayStride 32 + MemberDecorate 73(Rays) 0 Offset 0 + Decorate 73(Rays) BufferBlock + Decorate 75 DescriptorSet 0 + Decorate 75 Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypeFunction 6(int) + 10: TypeRayQueryProvisionalKHR + 11: TypePointer Function 10 + 12: TypeFloat 32 + 13: TypeVector 12(float) 3 + 14(Ray): TypeStruct 13(fvec3) 12(float) 13(fvec3) 12(float) + 15: TypePointer Function 14(Ray) + 16: TypeFunction 2 11(ptr) 15(ptr) + 21: TypeVector 6(int) 3 + 22: TypePointer Input 21(ivec3) +23(gl_LaunchIDNV): 22(ptr) Variable Input + 24: 6(int) Constant 2 + 25: TypePointer Input 6(int) +28(gl_LaunchSizeNV): 22(ptr) Variable Input + 29: 6(int) Constant 0 + 33: 6(int) Constant 1 + 48: TypeAccelerationStructureKHR + 49: TypePointer UniformConstant 48 + 50(rtas): 49(ptr) Variable UniformConstant + 52: TypeInt 32 1 + 53: 52(int) Constant 0 + 54: TypePointer Function 13(fvec3) + 57: 52(int) Constant 1 + 58: TypePointer Function 12(float) + 61: 52(int) Constant 2 + 64: 52(int) Constant 3 + 67: TypePointer Function 6(int) + 71(Ray): TypeStruct 13(fvec3) 12(float) 13(fvec3) 12(float) + 72: TypeRuntimeArray 71(Ray) + 73(Rays): TypeStruct 72 + 74: TypePointer Uniform 73(Rays) + 75: 74(ptr) Variable Uniform + 77: TypePointer Uniform 71(Ray) + 4(main): 2 Function None 3 + 5: Label + 68(index): 67(ptr) Variable Function + 70(ray): 15(ptr) Variable Function + 88(rayQuery): 11(ptr) Variable Function + 89(param): 11(ptr) Variable Function + 91(param): 15(ptr) Variable Function + 69: 6(int) FunctionCall 8(launchIndex() + Store 68(index) 69 + 76: 6(int) Load 68(index) + 78: 77(ptr) AccessChain 75 53 76 + 79: 71(Ray) Load 78 + 80: 13(fvec3) CompositeExtract 79 0 + 81: 54(ptr) AccessChain 70(ray) 53 + Store 81 80 + 82: 12(float) CompositeExtract 79 1 + 83: 58(ptr) AccessChain 70(ray) 57 + Store 83 82 + 84: 13(fvec3) CompositeExtract 79 2 + 85: 54(ptr) AccessChain 70(ray) 61 + Store 85 84 + 86: 12(float) CompositeExtract 79 3 + 87: 58(ptr) AccessChain 70(ray) 64 + Store 87 86 + 90: 10 Load 88(rayQuery) + Store 89(param) 90 + 92: 14(Ray) Load 70(ray) + Store 91(param) 92 + 93: 2 FunctionCall 19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;) 89(param) 91(param) + 94: 48 Load 50(rtas) + 95: 54(ptr) AccessChain 70(ray) 53 + 96: 13(fvec3) Load 95 + 97: 58(ptr) AccessChain 70(ray) 57 + 98: 12(float) Load 97 + 99: 54(ptr) AccessChain 70(ray) 61 + 100: 13(fvec3) Load 99 + 101: 58(ptr) AccessChain 70(ray) 64 + 102: 12(float) Load 101 + RayQueryInitializeKHR 88(rayQuery) 94 33 24 96 98 100 102 + Return + FunctionEnd + 8(launchIndex(): 6(int) Function None 7 + 9: Label + 26: 25(ptr) AccessChain 23(gl_LaunchIDNV) 24 + 27: 6(int) Load 26 + 30: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 29 + 31: 6(int) Load 30 + 32: 6(int) IMul 27 31 + 34: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 33 + 35: 6(int) Load 34 + 36: 6(int) IMul 32 35 + 37: 25(ptr) AccessChain 23(gl_LaunchIDNV) 33 + 38: 6(int) Load 37 + 39: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 29 + 40: 6(int) Load 39 + 41: 6(int) IMul 38 40 + 42: 6(int) IAdd 36 41 + 43: 25(ptr) AccessChain 23(gl_LaunchIDNV) 29 + 44: 6(int) Load 43 + 45: 6(int) IAdd 42 44 + ReturnValue 45 + FunctionEnd +19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;): 2 Function None 16 + 17(rayQuery): 11(ptr) FunctionParameter + 18(ray): 15(ptr) FunctionParameter + 20: Label + 51: 48 Load 50(rtas) + 55: 54(ptr) AccessChain 18(ray) 53 + 56: 13(fvec3) Load 55 + 59: 58(ptr) AccessChain 18(ray) 57 + 60: 12(float) Load 59 + 62: 54(ptr) AccessChain 18(ray) 61 + 63: 13(fvec3) Load 62 + 65: 58(ptr) AccessChain 18(ray) 64 + 66: 12(float) Load 65 + RayQueryInitializeKHR 17(rayQuery) 51 29 33 56 60 63 66 + Return + FunctionEnd diff --git a/Test/baseResults/rayQuery-no-cse.rgen.out b/Test/baseResults/rayQuery-no-cse.rgen.out new file mode 100644 index 0000000..357fa8c --- /dev/null +++ b/Test/baseResults/rayQuery-no-cse.rgen.out @@ -0,0 +1,179 @@ +rayQuery-no-cse.rgen +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 109 + + Capability RayQueryProvisionalKHR + Capability RayTracingNV + Extension "SPV_KHR_ray_query" + Extension "SPV_NV_ray_tracing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint RayGenerationKHR 4 "main" 23 28 + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 8 "launchIndex(" + Name 14 "Ray" + MemberName 14(Ray) 0 "pos" + MemberName 14(Ray) 1 "tmin" + MemberName 14(Ray) 2 "dir" + MemberName 14(Ray) 3 "tmax" + Name 19 "doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;" + Name 17 "rayQuery" + Name 18 "ray" + Name 23 "gl_LaunchIDNV" + Name 28 "gl_LaunchSizeNV" + Name 50 "rtas" + Name 68 "index" + Name 70 "ray" + Name 71 "Ray" + MemberName 71(Ray) 0 "pos" + MemberName 71(Ray) 1 "tmin" + MemberName 71(Ray) 2 "dir" + MemberName 71(Ray) 3 "tmax" + Name 73 "Rays" + MemberName 73(Rays) 0 "rays" + Name 75 "" + Name 88 "rayQuery1" + Name 89 "param" + Name 91 "param" + Name 103 "rayQuery2" + Name 104 "param" + Name 106 "param" + Decorate 23(gl_LaunchIDNV) BuiltIn LaunchIdKHR + Decorate 28(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR + Decorate 50(rtas) DescriptorSet 0 + Decorate 50(rtas) Binding 0 + MemberDecorate 71(Ray) 0 Offset 0 + MemberDecorate 71(Ray) 1 Offset 12 + MemberDecorate 71(Ray) 2 Offset 16 + MemberDecorate 71(Ray) 3 Offset 28 + Decorate 72 ArrayStride 32 + MemberDecorate 73(Rays) 0 Offset 0 + Decorate 73(Rays) BufferBlock + Decorate 75 DescriptorSet 0 + Decorate 75 Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypeFunction 6(int) + 10: TypeRayQueryProvisionalKHR + 11: TypePointer Function 10 + 12: TypeFloat 32 + 13: TypeVector 12(float) 3 + 14(Ray): TypeStruct 13(fvec3) 12(float) 13(fvec3) 12(float) + 15: TypePointer Function 14(Ray) + 16: TypeFunction 2 11(ptr) 15(ptr) + 21: TypeVector 6(int) 3 + 22: TypePointer Input 21(ivec3) +23(gl_LaunchIDNV): 22(ptr) Variable Input + 24: 6(int) Constant 2 + 25: TypePointer Input 6(int) +28(gl_LaunchSizeNV): 22(ptr) Variable Input + 29: 6(int) Constant 0 + 33: 6(int) Constant 1 + 48: TypeAccelerationStructureKHR + 49: TypePointer UniformConstant 48 + 50(rtas): 49(ptr) Variable UniformConstant + 52: TypeInt 32 1 + 53: 52(int) Constant 0 + 54: TypePointer Function 13(fvec3) + 57: 52(int) Constant 1 + 58: TypePointer Function 12(float) + 61: 52(int) Constant 2 + 64: 52(int) Constant 3 + 67: TypePointer Function 6(int) + 71(Ray): TypeStruct 13(fvec3) 12(float) 13(fvec3) 12(float) + 72: TypeRuntimeArray 71(Ray) + 73(Rays): TypeStruct 72 + 74: TypePointer Uniform 73(Rays) + 75: 74(ptr) Variable Uniform + 77: TypePointer Uniform 71(Ray) + 4(main): 2 Function None 3 + 5: Label + 68(index): 67(ptr) Variable Function + 70(ray): 15(ptr) Variable Function + 88(rayQuery1): 11(ptr) Variable Function + 89(param): 11(ptr) Variable Function + 91(param): 15(ptr) Variable Function + 103(rayQuery2): 11(ptr) Variable Function + 104(param): 11(ptr) Variable Function + 106(param): 15(ptr) Variable Function + 69: 6(int) FunctionCall 8(launchIndex() + Store 68(index) 69 + 76: 6(int) Load 68(index) + 78: 77(ptr) AccessChain 75 53 76 + 79: 71(Ray) Load 78 + 80: 13(fvec3) CompositeExtract 79 0 + 81: 54(ptr) AccessChain 70(ray) 53 + Store 81 80 + 82: 12(float) CompositeExtract 79 1 + 83: 58(ptr) AccessChain 70(ray) 57 + Store 83 82 + 84: 13(fvec3) CompositeExtract 79 2 + 85: 54(ptr) AccessChain 70(ray) 61 + Store 85 84 + 86: 12(float) CompositeExtract 79 3 + 87: 58(ptr) AccessChain 70(ray) 64 + Store 87 86 + 90: 10 Load 88(rayQuery1) + Store 89(param) 90 + 92: 14(Ray) Load 70(ray) + Store 91(param) 92 + 93: 2 FunctionCall 19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;) 89(param) 91(param) + 94: 48 Load 50(rtas) + 95: 54(ptr) AccessChain 70(ray) 53 + 96: 13(fvec3) Load 95 + 97: 58(ptr) AccessChain 70(ray) 57 + 98: 12(float) Load 97 + 99: 54(ptr) AccessChain 70(ray) 61 + 100: 13(fvec3) Load 99 + 101: 58(ptr) AccessChain 70(ray) 64 + 102: 12(float) Load 101 + RayQueryInitializeKHR 88(rayQuery1) 94 33 24 96 98 100 102 + 105: 10 Load 103(rayQuery2) + Store 104(param) 105 + 107: 14(Ray) Load 70(ray) + Store 106(param) 107 + 108: 2 FunctionCall 19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;) 104(param) 106(param) + Return + FunctionEnd + 8(launchIndex(): 6(int) Function None 7 + 9: Label + 26: 25(ptr) AccessChain 23(gl_LaunchIDNV) 24 + 27: 6(int) Load 26 + 30: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 29 + 31: 6(int) Load 30 + 32: 6(int) IMul 27 31 + 34: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 33 + 35: 6(int) Load 34 + 36: 6(int) IMul 32 35 + 37: 25(ptr) AccessChain 23(gl_LaunchIDNV) 33 + 38: 6(int) Load 37 + 39: 25(ptr) AccessChain 28(gl_LaunchSizeNV) 29 + 40: 6(int) Load 39 + 41: 6(int) IMul 38 40 + 42: 6(int) IAdd 36 41 + 43: 25(ptr) AccessChain 23(gl_LaunchIDNV) 29 + 44: 6(int) Load 43 + 45: 6(int) IAdd 42 44 + ReturnValue 45 + FunctionEnd +19(doInitialize(rq1;struct-Ray-vf3-f1-vf3-f11;): 2 Function None 16 + 17(rayQuery): 11(ptr) FunctionParameter + 18(ray): 15(ptr) FunctionParameter + 20: Label + 51: 48 Load 50(rtas) + 55: 54(ptr) AccessChain 18(ray) 53 + 56: 13(fvec3) Load 55 + 59: 58(ptr) AccessChain 18(ray) 57 + 60: 12(float) Load 59 + 62: 54(ptr) AccessChain 18(ray) 61 + 63: 13(fvec3) Load 62 + 65: 58(ptr) AccessChain 18(ray) 64 + 66: 12(float) Load 65 + RayQueryInitializeKHR 17(rayQuery) 51 29 33 56 60 63 66 + Return + FunctionEnd diff --git a/Test/baseResults/rayQuery.rgen.out b/Test/baseResults/rayQuery.rgen.out new file mode 100644 index 0000000..9f4f76d --- /dev/null +++ b/Test/baseResults/rayQuery.rgen.out @@ -0,0 +1,84 @@ +rayQuery.rgen +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 46 + + Capability RayQueryProvisionalKHR + Capability RayTracingNV + Extension "SPV_KHR_ray_query" + Extension "SPV_NV_ray_tracing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint RayGenerationKHR 4 "main" + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 8 "rayFlags" + Name 12 "tMin" + Name 14 "tMax" + Name 18 "localRayQuery" + Name 21 "accNV0" + Name 26 "block" + MemberName 26(block) 0 "dir" + MemberName 26(block) 1 "origin" + Name 28 "" + Decorate 21(accNV0) DescriptorSet 0 + Decorate 21(accNV0) Binding 0 + MemberDecorate 26(block) 0 Offset 0 + MemberDecorate 26(block) 1 Offset 16 + Decorate 26(block) BufferBlock + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypePointer Function 6(int) + 9: 6(int) Constant 9 + 10: TypeFloat 32 + 11: TypePointer Function 10(float) + 13: 10(float) Constant 0 + 15: 10(float) Constant 1148846080 + 16: TypeRayQueryProvisionalKHR + 17: TypePointer Function 16 + 19: TypeAccelerationStructureKHR + 20: TypePointer UniformConstant 19 + 21(accNV0): 20(ptr) Variable UniformConstant + 24: 6(int) Constant 255 + 25: TypeVector 10(float) 3 + 26(block): TypeStruct 25(fvec3) 25(fvec3) + 27: TypePointer ShaderRecordBufferKHR 26(block) + 28: 27(ptr) Variable ShaderRecordBufferKHR + 29: TypeInt 32 1 + 30: 29(int) Constant 1 + 31: TypePointer ShaderRecordBufferKHR 25(fvec3) + 35: 29(int) Constant 0 + 40: TypeBool + 4(main): 2 Function None 3 + 5: Label + 8(rayFlags): 7(ptr) Variable Function + 12(tMin): 11(ptr) Variable Function + 14(tMax): 11(ptr) Variable Function +18(localRayQuery): 17(ptr) Variable Function + Store 8(rayFlags) 9 + Store 12(tMin) 13 + Store 14(tMax) 15 + 22: 19 Load 21(accNV0) + 23: 6(int) Load 8(rayFlags) + 32: 31(ptr) AccessChain 28 30 + 33: 25(fvec3) Load 32 + 34: 10(float) Load 12(tMin) + 36: 31(ptr) AccessChain 28 35 + 37: 25(fvec3) Load 36 + 38: 10(float) Load 14(tMax) + RayQueryInitializeKHR 18(localRayQuery) 22 23 24 33 34 37 38 + 39: 16 Load 18(localRayQuery) + 41: 40(bool) RayQueryProceedKHR 39 + 42: 40(bool) LogicalNot 41 + SelectionMerge 44 None + BranchConditional 42 43 44 + 43: Label + 45: 16 Load 18(localRayQuery) + RayQueryTerminateKHR 45 + Branch 44 + 44: Label + Return + FunctionEnd diff --git a/Test/rayQuery-allOps.rgen b/Test/rayQuery-allOps.rgen new file mode 100644 index 0000000..7c62a64 --- /dev/null +++ b/Test/rayQuery-allOps.rgen @@ -0,0 +1,212 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(std430, set = 0, binding = 0) buffer Log +{ + uint x; + uint y; +}; + +layout(binding = 1, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +void doSomething() +{ + x = 0; + y = 0; +} + +Ray makeRayDesc() +{ + Ray ray; + ray.pos= vec3(0,0,0); + ray.dir = vec3(1,0,0); + ray.tmin = 0.0f; + ray.tmax = 9999.0; + return ray; +} + +void main() +{ + Ray ray;// = makeRayDesc(); + rayQueryEXT rayQuery; + rayQueryInitializeEXT(rayQuery, rtas, 0, 0xFF, ray.pos, ray.tmin, ray.dir, ray.tmax); + + mat4x3 _mat4x3; + mat3x4 _mat3x4; + + while (rayQueryProceedEXT(rayQuery)) + { + uint candidateType = rayQueryGetIntersectionTypeEXT(rayQuery, false); + switch(candidateType) + { + case gl_RayQueryCandidateIntersectionTriangleEXT: + + rayQueryTerminateEXT(rayQuery); + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + rayQueryConfirmIntersectionEXT(rayQuery); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true).x == 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceIdEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionTEXT(rayQuery, true) > 0.f) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, true) > 0) + { + doSomething(); + } + break; + + case gl_RayQueryCandidateIntersectionAABBEXT: + { + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + if (rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQuery)) + { + doSomething(); + } + + float t = 0.5; + rayQueryGenerateIntersectionEXT(rayQuery, t); + rayQueryTerminateEXT(rayQuery); + break; + } + } + } + + if(_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + uint committedStatus = rayQueryGetIntersectionTypeEXT(rayQuery, true); + + switch(committedStatus) + { + case gl_RayQueryCommittedIntersectionNoneEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + break; + + case gl_RayQueryCommittedIntersectionTriangleEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, true); + _mat3x4 = transpose(_mat4x3); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true).y == 0) + { + doSomething(); + } + break; + + case gl_RayQueryCommittedIntersectionGeneratedEXT : + + if(rayQueryGetIntersectionGeometryIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceIdEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true).z > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionTEXT(rayQuery, true) > 0.f) + { + doSomething(); + } + break; + } + + if (_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + if (rayQueryGetRayFlagsEXT(rayQuery) > 0) + { + doSomething(); + } + + if (rayQueryGetRayTMinEXT(rayQuery) > 0.0) + { + doSomething(); + } + + vec3 o = rayQueryGetWorldRayOriginEXT(rayQuery); + vec3 d = rayQueryGetWorldRayDirectionEXT(rayQuery); + + if (o.x == d.z) + { + doSomething(); + } +} diff --git a/Test/rayQuery-array-2d-dynamic.rgen b/Test/rayQuery-array-2d-dynamic.rgen new file mode 100644 index 0000000..922e944 --- /dev/null +++ b/Test/rayQuery-array-2d-dynamic.rgen @@ -0,0 +1,36 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(binding = 0, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +uint launchIndex() +{ + return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x; +} + +void doInitialize(rayQueryEXT rayQuery, Ray ray) +{ + rayQueryInitializeEXT(rayQuery, rtas, 0, 1, ray.pos, ray.tmin, ray.dir, ray.tmax); +} + +int C; + +void main() +{ + uint index = launchIndex(); + Ray ray = rays[index]; + rayQueryEXT rayQuery[2]; + doInitialize(rayQuery[0], rays[index]); + rayQueryInitializeEXT(rayQuery[1], rtas, 1, 2, ray.pos, ray.tmin, ray.dir, ray.tmax); + doInitialize(rayQuery[C], ray); +} diff --git a/Test/rayQuery-decls.rgen b/Test/rayQuery-decls.rgen new file mode 100644 index 0000000..f3e5f5f --- /dev/null +++ b/Test/rayQuery-decls.rgen @@ -0,0 +1,53 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(binding = 0, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; +layout(shaderRecordNV) buffer block +{ + uint idx; +}; + +uint launchIndex() +{ + return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x; +} + +rayQueryEXT g_rayQueryArray[4]; +rayQueryEXT g_rayQueryUnused; + +void main() +{ + uint index = launchIndex(); + Ray ray = rays[index]; + + rayQueryEXT rayQuery0a; + rayQueryEXT rayQuery0b; + + g_rayQueryArray[idx] = rayQuery0b; // Stored here, then overwritten with rayQuery0a + g_rayQueryArray[idx] = rayQuery0a; + + // No separate allocation, just a handle copy + // optimizations should have eliminated load from global array + rayQueryEXT rayQuery0c = g_rayQueryArray[idx]; + + // rayQuery0a is the one actually used here + rayQueryInitializeEXT(rayQuery0c, rtas, gl_RayFlagsOpaqueEXT, 2, ray.pos, ray.tmin, ray.dir, ray.tmax); + + // AllocateRayQuery occurs here, rather than next to allocas + // Should not be extray allocate, since above should allocate and copy + rayQueryEXT rayQuery1c; + // update the rayFlags as RAY_FLAG_FORCE_OPAQUE + rayQueryInitializeEXT(rayQuery1c, rtas, gl_RayFlagsOpaqueEXT, 1, ray.pos, ray.tmin, ray.dir, ray.tmax); + + rayQueryInitializeEXT(rayQuery1c, rtas, 3, 4, ray.pos, ray.tmin, ray.dir, ray.tmax); +} diff --git a/Test/rayQuery-initialize.rgen b/Test/rayQuery-initialize.rgen new file mode 100644 index 0000000..75ec1ba --- /dev/null +++ b/Test/rayQuery-initialize.rgen @@ -0,0 +1,33 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(binding = 0, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +uint launchIndex() +{ + return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x; +} + +void doInitialize(rayQueryEXT rayQuery, Ray ray) +{ + rayQueryInitializeEXT(rayQuery, rtas, 0, 1, ray.pos, ray.tmin, ray.dir, ray.tmax); +} + +void main() +{ + uint index = launchIndex(); + Ray ray = rays[index]; + rayQueryEXT rayQuery; + doInitialize(rayQuery, ray); + rayQueryInitializeEXT(rayQuery, rtas, 1, 2, ray.pos, ray.tmin, ray.dir, ray.tmax); +} diff --git a/Test/rayQuery-no-cse.rgen b/Test/rayQuery-no-cse.rgen new file mode 100644 index 0000000..dd6e90d --- /dev/null +++ b/Test/rayQuery-no-cse.rgen @@ -0,0 +1,35 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(binding = 0, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +uint launchIndex() +{ + return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x; +} + +void doInitialize(rayQueryEXT rayQuery, Ray ray) +{ + rayQueryInitializeEXT(rayQuery, rtas, 0, 1, ray.pos, ray.tmin, ray.dir, ray.tmax); +} + +void main() +{ + uint index = launchIndex(); + Ray ray = rays[index]; + rayQueryEXT rayQuery1; + rayQueryEXT rayQuery2; + doInitialize(rayQuery1, ray); + rayQueryInitializeEXT(rayQuery1, rtas, 1, 2, ray.pos, ray.tmin, ray.dir, ray.tmax); + doInitialize(rayQuery2, ray); +} diff --git a/Test/rayQuery.rgen b/Test/rayQuery.rgen new file mode 100644 index 0000000..3e62110 --- /dev/null +++ b/Test/rayQuery.rgen @@ -0,0 +1,23 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable +layout(binding = 0, set = 0) uniform accelerationStructureNV accNV0; + +layout(shaderRecordNV) buffer block +{ + vec3 dir; + vec3 origin; +}; + +void main() +{ + rayQueryEXT localRayQuery; + uint rayFlags = gl_RayFlagsOpaqueEXT | gl_RayFlagsSkipClosestHitShaderEXT; + float tMin = 0.f; + float tMax = 1000.f; + rayQueryInitializeEXT(localRayQuery, accNV0, rayFlags, 0xFF , origin, tMin, dir, tMax); + if (!rayQueryProceedEXT(localRayQuery)) + { + rayQueryTerminateEXT(localRayQuery); + } +} diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index a8c57a4..ebc6cd3 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -1674,7 +1674,7 @@ public: } virtual bool isOpaque() const { return basicType == EbtSampler #ifndef GLSLANG_WEB - || basicType == EbtAtomicUint || basicType == EbtAccStruct || basicType == EbtRayQuery + || basicType == EbtAtomicUint || basicType == EbtAccStruct #endif ; } virtual bool isBuiltIn() const { return getQualifier().builtIn != EbvNone; } diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 4b4ab80..7c55108 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -4326,10 +4326,10 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV // Builtins for GL_NV_ray_tracing/GL_EXT_ray_tracing/GL_EXT_ray_query if (profile != EEsProfile && version >= 460) { commonBuiltins.append("void rayQueryInitializeEXT(rayQueryEXT, accelerationStructureEXT, uint, uint, vec3, float, vec3, float);" - "bool rayQueryProceedEXT(rayQueryEXT);" "void rayQueryTerminateEXT(rayQueryEXT);" "void rayQueryGenerateIntersectionEXT(rayQueryEXT, float);" "void rayQueryConfirmIntersectionEXT(rayQueryEXT);" + "bool rayQueryProceedEXT(rayQueryEXT);" "uint rayQueryGetIntersectionTypeEXT(rayQueryEXT, bool);" "float rayQueryGetRayTMinEXT(rayQueryEXT);" "uint rayQueryGetRayFlagsEXT(rayQueryEXT);" diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp index 5bd764e..d242c39 100755 --- a/glslang/MachineIndependent/Intermediate.cpp +++ b/glslang/MachineIndependent/Intermediate.cpp @@ -540,7 +540,6 @@ bool TIntermediate::isConversionAllowed(TOperator op, TIntermTyped* node) const case EbtAtomicUint: case EbtSampler: case EbtAccStruct: - case EbtRayQuery: // opaque types can be passed to functions if (op == EOpFunction) break; diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 8031bf1..24941ce 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -105,6 +105,7 @@ TEST_P(CompileVulkanToDebugSpirvTest, FromFile) "/baseResults/", false, true); } + TEST_P(CompileVulkan1_1ToSpirvTest, FromFile) { loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), @@ -229,6 +230,12 @@ INSTANTIATE_TEST_CASE_P( "spv.while-continue-break.vert", "spv.while-simple.vert", // vulkan-specific tests + "rayQuery.rgen", + "rayQuery-array-2d-dynamic.rgen", + "rayQuery-decls.rgen", + "rayQuery-no-cse.rgen", + "rayQuery-initialize.rgen", + "rayQuery-allOps.rgen", "spv.set.vert", "spv.double.comp", "spv.100ops.frag", @@ -447,6 +454,7 @@ INSTANTIATE_TEST_CASE_P( FileNameAsCustomTestSuffix ); + // Cases with deliberately unreachable code. // By default the compiler will aggressively eliminate // unreachable merges and continues. -- 2.7.4