diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 18ef64f4..4a489dfe 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -3778,10 +3778,36 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty spvType = builder.makeUintType(32); break; case glslang::EbtAccStruct: + switch (glslangIntermediate->getStage()) { + case EShLangRayGen: + case EShLangIntersect: + case EShLangAnyHit: + case EShLangClosestHit: + case EShLangMiss: + case EShLangCallable: + // these all should have the RayTracingNV/KHR capability already + break; + default: + { + auto& extensions = glslangIntermediate->getRequestedExtensions(); + if (extensions.find("GL_EXT_ray_query") != extensions.end()) { + builder.addExtension(spv::E_SPV_KHR_ray_query); + builder.addCapability(spv::CapabilityRayQueryKHR); + } + } + break; + } spvType = builder.makeAccelerationStructureType(); break; case glslang::EbtRayQuery: - spvType = builder.makeRayQueryType(); + { + auto& extensions = glslangIntermediate->getRequestedExtensions(); + if (extensions.find("GL_EXT_ray_query") != extensions.end()) { + builder.addExtension(spv::E_SPV_KHR_ray_query); + builder.addCapability(spv::CapabilityRayQueryKHR); + } + spvType = builder.makeRayQueryType(); + } break; case glslang::EbtReference: { diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index e6ad4c1a..de681a82 100644 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -1380,7 +1380,7 @@ const char* OpcodeString(int op) case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV"; case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV"; - case OpTypeRayQueryKHR: return "OpTypeRayQueryProvisionalKHR"; + case OpTypeRayQueryKHR: return "OpTypeRayQueryKHR"; case OpRayQueryInitializeKHR: return "OpRayQueryInitializeKHR"; case OpRayQueryTerminateKHR: return "OpRayQueryTerminateKHR"; case OpRayQueryGenerateIntersectionKHR: return "OpRayQueryGenerateIntersectionKHR"; diff --git a/Test/baseResults/rayQuery-allOps.comp.out b/Test/baseResults/rayQuery-allOps.comp.out index 9c49e2e3..fd4a2ff8 100644 --- a/Test/baseResults/rayQuery-allOps.comp.out +++ b/Test/baseResults/rayQuery-allOps.comp.out @@ -86,7 +86,7 @@ rayQuery-allOps.comp 35: TypePointer Function 8(float) 37: 18(int) Constant 3 38: 8(float) Constant 1176255488 - 45: TypeRayQueryProvisionalKHR + 45: TypeRayQueryKHR 46: TypePointer Private 45 47(rayQuery): 46(ptr) Variable Private 48: TypeAccelerationStructureKHR diff --git a/Test/baseResults/rayQuery-allOps.frag.out b/Test/baseResults/rayQuery-allOps.frag.out index cff8fb0e..573a640a 100644 --- a/Test/baseResults/rayQuery-allOps.frag.out +++ b/Test/baseResults/rayQuery-allOps.frag.out @@ -85,7 +85,7 @@ rayQuery-allOps.frag 35: TypePointer Function 8(float) 37: 18(int) Constant 3 38: 8(float) Constant 1176255488 - 45: TypeRayQueryProvisionalKHR + 45: TypeRayQueryKHR 46: TypePointer Private 45 47(rayQuery): 46(ptr) Variable Private 48: TypeAccelerationStructureKHR diff --git a/Test/baseResults/rayQuery-allOps.rgen.out b/Test/baseResults/rayQuery-allOps.rgen.out index 418dad18..deb0f7d5 100644 --- a/Test/baseResults/rayQuery-allOps.rgen.out +++ b/Test/baseResults/rayQuery-allOps.rgen.out @@ -85,7 +85,7 @@ rayQuery-allOps.rgen 35: TypePointer Function 8(float) 37: 18(int) Constant 3 38: 8(float) Constant 1176255488 - 45: TypeRayQueryProvisionalKHR + 45: TypeRayQueryKHR 46: TypePointer Private 45 47(rayQuery): 46(ptr) Variable Private 48: TypeAccelerationStructureKHR diff --git a/Test/baseResults/rayQuery-global.rgen.out b/Test/baseResults/rayQuery-global.rgen.out index 637b7528..7b051735 100644 --- a/Test/baseResults/rayQuery-global.rgen.out +++ b/Test/baseResults/rayQuery-global.rgen.out @@ -26,7 +26,7 @@ rayQuery-global.rgen Decorate 27(rtas) Binding 1 2: TypeVoid 3: TypeFunction 2 - 6: TypeRayQueryProvisionalKHR + 6: TypeRayQueryKHR 7: TypePointer Private 6 8: TypeFunction 2 7(ptr) 15: TypeBool diff --git a/Test/baseResults/rayQuery-initialize.rgen.out b/Test/baseResults/rayQuery-initialize.rgen.out index 3b833332..f16facd5 100644 --- a/Test/baseResults/rayQuery-initialize.rgen.out +++ b/Test/baseResults/rayQuery-initialize.rgen.out @@ -55,7 +55,7 @@ rayQuery-initialize.rgen 3: TypeFunction 2 6: TypeInt 32 0 7: TypeFunction 6(int) - 10: TypeRayQueryProvisionalKHR + 10: TypeRayQueryKHR 11: TypePointer Private 10 12: TypeFloat 32 13: TypeVector 12(float) 3 diff --git a/Test/baseResults/rayQuery-no-cse.rgen.out b/Test/baseResults/rayQuery-no-cse.rgen.out index 2f46f078..a44c41f1 100644 --- a/Test/baseResults/rayQuery-no-cse.rgen.out +++ b/Test/baseResults/rayQuery-no-cse.rgen.out @@ -57,7 +57,7 @@ rayQuery-no-cse.rgen 3: TypeFunction 2 6: TypeInt 32 0 7: TypeFunction 6(int) - 10: TypeRayQueryProvisionalKHR + 10: TypeRayQueryKHR 11: TypePointer Private 10 12: TypeFloat 32 13: TypeVector 12(float) 3 diff --git a/Test/baseResults/rayQuery.rgen.out b/Test/baseResults/rayQuery.rgen.out index 36809733..80e9916e 100644 --- a/Test/baseResults/rayQuery.rgen.out +++ b/Test/baseResults/rayQuery.rgen.out @@ -39,7 +39,7 @@ rayQuery.rgen 11: TypePointer Function 10(float) 13: 10(float) Constant 0 15: 10(float) Constant 1148846080 - 16: TypeRayQueryProvisionalKHR + 16: TypeRayQueryKHR 17: TypePointer Private 16 18(localRayQuery): 17(ptr) Variable Private 19: TypeAccelerationStructureKHR diff --git a/Test/baseResults/spv.ext.AccelDecl.frag.out b/Test/baseResults/spv.ext.AccelDecl.frag.out new file mode 100644 index 00000000..11d45606 --- /dev/null +++ b/Test/baseResults/spv.ext.AccelDecl.frag.out @@ -0,0 +1,41 @@ +spv.ext.AccelDecl.frag +// Module Version 10400 +// Generated by (magic number): 8000a +// Id's are bound by 15 + + Capability Shader + Capability RayQueryKHR + Extension "SPV_KHR_ray_query" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 9 14 + ExecutionMode 4 OriginUpperLeft + Source GLSL 460 + SourceExtension "GL_ARB_separate_shader_objects" + SourceExtension "GL_EXT_nonuniform_qualifier" + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_EXT_scalar_block_layout" + SourceExtension "GL_GOOGLE_cpp_style_line_directive" + SourceExtension "GL_GOOGLE_include_directive" + Name 4 "main" + Name 9 "outColor" + Name 14 "topLevelAS" + Decorate 9(outColor) Location 0 + Decorate 14(topLevelAS) DescriptorSet 0 + Decorate 14(topLevelAS) Binding 1 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Output 7(fvec4) + 9(outColor): 8(ptr) Variable Output + 10: 6(float) Constant 0 + 11: 7(fvec4) ConstantComposite 10 10 10 10 + 12: TypeAccelerationStructureKHR + 13: TypePointer UniformConstant 12 + 14(topLevelAS): 13(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + Store 9(outColor) 11 + Return + FunctionEnd diff --git a/Test/baseResults/spv.ext.RayQueryDecl.frag.out b/Test/baseResults/spv.ext.RayQueryDecl.frag.out new file mode 100644 index 00000000..97681e9f --- /dev/null +++ b/Test/baseResults/spv.ext.RayQueryDecl.frag.out @@ -0,0 +1,39 @@ +spv.ext.RayQueryDecl.frag +// Module Version 10400 +// Generated by (magic number): 8000a +// Id's are bound by 15 + + Capability Shader + Capability RayQueryKHR + Extension "SPV_KHR_ray_query" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 9 14 + ExecutionMode 4 OriginUpperLeft + Source GLSL 460 + SourceExtension "GL_ARB_separate_shader_objects" + SourceExtension "GL_EXT_nonuniform_qualifier" + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_EXT_scalar_block_layout" + SourceExtension "GL_GOOGLE_cpp_style_line_directive" + SourceExtension "GL_GOOGLE_include_directive" + Name 4 "main" + Name 9 "outColor" + Name 14 "rq" + Decorate 9(outColor) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Output 7(fvec4) + 9(outColor): 8(ptr) Variable Output + 10: 6(float) Constant 0 + 11: 7(fvec4) ConstantComposite 10 10 10 10 + 12: TypeRayQueryKHR + 13: TypePointer Private 12 + 14(rq): 13(ptr) Variable Private + 4(main): 2 Function None 3 + 5: Label + Store 9(outColor) 11 + Return + FunctionEnd diff --git a/Test/spv.ext.AccelDecl.frag b/Test/spv.ext.AccelDecl.frag new file mode 100644 index 00000000..4374bf39 --- /dev/null +++ b/Test/spv.ext.AccelDecl.frag @@ -0,0 +1,14 @@ +#version 460 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_EXT_nonuniform_qualifier : enable +#extension GL_GOOGLE_include_directive : enable +#extension GL_EXT_scalar_block_layout : enable +#extension GL_EXT_ray_query : enable + +layout(location = 0) out vec4 outColor; + +layout(binding = 1, set = 0) uniform accelerationStructureEXT topLevelAS; + +void main() { + outColor = vec4(0.0); +} diff --git a/Test/spv.ext.RayQueryDecl.frag b/Test/spv.ext.RayQueryDecl.frag new file mode 100644 index 00000000..8a144d6b --- /dev/null +++ b/Test/spv.ext.RayQueryDecl.frag @@ -0,0 +1,14 @@ +#version 460 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_EXT_nonuniform_qualifier : enable +#extension GL_GOOGLE_include_directive : enable +#extension GL_EXT_scalar_block_layout : enable +#extension GL_EXT_ray_query : enable + +layout(location = 0) out vec4 outColor; + +rayQueryEXT rq; + +void main() { + outColor = vec4(0.0); +} diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 90f05389..a393cccc 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -577,6 +577,8 @@ INSTANTIATE_TEST_SUITE_P( "spv.ext.RayGenSBTlayout430.rgen", "spv.ext.RayGenSBTlayoutscalar.rgen", "spv.ext.World3x4.rahit", + "spv.ext.AccelDecl.frag", + "spv.ext.RayQueryDecl.frag", })), FileNameAsCustomTestSuffix );