Skip to content

Commit 4d41da3

Browse files
authored
Add ray query capability if acceleration structure or ray query types declared (KhronosGroup#2469)
* Add ray query capability if acceleration structure used Fixes KhronosGroup#2430 in non-ray tracing stages and the extension is enabled * Add ray query capability if ray query declared * Fix printing of TypeRayQueryKHR It's no longer spelled with "Provisional"
1 parent ffccefd commit 4d41da3

14 files changed

+145
-9
lines changed

SPIRV/GlslangToSpv.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3778,10 +3778,36 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
37783778
spvType = builder.makeUintType(32);
37793779
break;
37803780
case glslang::EbtAccStruct:
3781+
switch (glslangIntermediate->getStage()) {
3782+
case EShLangRayGen:
3783+
case EShLangIntersect:
3784+
case EShLangAnyHit:
3785+
case EShLangClosestHit:
3786+
case EShLangMiss:
3787+
case EShLangCallable:
3788+
// these all should have the RayTracingNV/KHR capability already
3789+
break;
3790+
default:
3791+
{
3792+
auto& extensions = glslangIntermediate->getRequestedExtensions();
3793+
if (extensions.find("GL_EXT_ray_query") != extensions.end()) {
3794+
builder.addExtension(spv::E_SPV_KHR_ray_query);
3795+
builder.addCapability(spv::CapabilityRayQueryKHR);
3796+
}
3797+
}
3798+
break;
3799+
}
37813800
spvType = builder.makeAccelerationStructureType();
37823801
break;
37833802
case glslang::EbtRayQuery:
3784-
spvType = builder.makeRayQueryType();
3803+
{
3804+
auto& extensions = glslangIntermediate->getRequestedExtensions();
3805+
if (extensions.find("GL_EXT_ray_query") != extensions.end()) {
3806+
builder.addExtension(spv::E_SPV_KHR_ray_query);
3807+
builder.addCapability(spv::CapabilityRayQueryKHR);
3808+
}
3809+
spvType = builder.makeRayQueryType();
3810+
}
37853811
break;
37863812
case glslang::EbtReference:
37873813
{

SPIRV/doc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ const char* OpcodeString(int op)
13801380
case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV";
13811381
case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV";
13821382

1383-
case OpTypeRayQueryKHR: return "OpTypeRayQueryProvisionalKHR";
1383+
case OpTypeRayQueryKHR: return "OpTypeRayQueryKHR";
13841384
case OpRayQueryInitializeKHR: return "OpRayQueryInitializeKHR";
13851385
case OpRayQueryTerminateKHR: return "OpRayQueryTerminateKHR";
13861386
case OpRayQueryGenerateIntersectionKHR: return "OpRayQueryGenerateIntersectionKHR";

Test/baseResults/rayQuery-allOps.comp.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ rayQuery-allOps.comp
8686
35: TypePointer Function 8(float)
8787
37: 18(int) Constant 3
8888
38: 8(float) Constant 1176255488
89-
45: TypeRayQueryProvisionalKHR
89+
45: TypeRayQueryKHR
9090
46: TypePointer Private 45
9191
47(rayQuery): 46(ptr) Variable Private
9292
48: TypeAccelerationStructureKHR

Test/baseResults/rayQuery-allOps.frag.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ rayQuery-allOps.frag
8585
35: TypePointer Function 8(float)
8686
37: 18(int) Constant 3
8787
38: 8(float) Constant 1176255488
88-
45: TypeRayQueryProvisionalKHR
88+
45: TypeRayQueryKHR
8989
46: TypePointer Private 45
9090
47(rayQuery): 46(ptr) Variable Private
9191
48: TypeAccelerationStructureKHR

Test/baseResults/rayQuery-allOps.rgen.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ rayQuery-allOps.rgen
8585
35: TypePointer Function 8(float)
8686
37: 18(int) Constant 3
8787
38: 8(float) Constant 1176255488
88-
45: TypeRayQueryProvisionalKHR
88+
45: TypeRayQueryKHR
8989
46: TypePointer Private 45
9090
47(rayQuery): 46(ptr) Variable Private
9191
48: TypeAccelerationStructureKHR

Test/baseResults/rayQuery-global.rgen.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rayQuery-global.rgen
2626
Decorate 27(rtas) Binding 1
2727
2: TypeVoid
2828
3: TypeFunction 2
29-
6: TypeRayQueryProvisionalKHR
29+
6: TypeRayQueryKHR
3030
7: TypePointer Private 6
3131
8: TypeFunction 2 7(ptr)
3232
15: TypeBool

Test/baseResults/rayQuery-initialize.rgen.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ rayQuery-initialize.rgen
5555
3: TypeFunction 2
5656
6: TypeInt 32 0
5757
7: TypeFunction 6(int)
58-
10: TypeRayQueryProvisionalKHR
58+
10: TypeRayQueryKHR
5959
11: TypePointer Private 10
6060
12: TypeFloat 32
6161
13: TypeVector 12(float) 3

Test/baseResults/rayQuery-no-cse.rgen.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ rayQuery-no-cse.rgen
5757
3: TypeFunction 2
5858
6: TypeInt 32 0
5959
7: TypeFunction 6(int)
60-
10: TypeRayQueryProvisionalKHR
60+
10: TypeRayQueryKHR
6161
11: TypePointer Private 10
6262
12: TypeFloat 32
6363
13: TypeVector 12(float) 3

Test/baseResults/rayQuery.rgen.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ rayQuery.rgen
3939
11: TypePointer Function 10(float)
4040
13: 10(float) Constant 0
4141
15: 10(float) Constant 1148846080
42-
16: TypeRayQueryProvisionalKHR
42+
16: TypeRayQueryKHR
4343
17: TypePointer Private 16
4444
18(localRayQuery): 17(ptr) Variable Private
4545
19: TypeAccelerationStructureKHR
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
spv.ext.AccelDecl.frag
2+
// Module Version 10400
3+
// Generated by (magic number): 8000a
4+
// Id's are bound by 15
5+
6+
Capability Shader
7+
Capability RayQueryKHR
8+
Extension "SPV_KHR_ray_query"
9+
1: ExtInstImport "GLSL.std.450"
10+
MemoryModel Logical GLSL450
11+
EntryPoint Fragment 4 "main" 9 14
12+
ExecutionMode 4 OriginUpperLeft
13+
Source GLSL 460
14+
SourceExtension "GL_ARB_separate_shader_objects"
15+
SourceExtension "GL_EXT_nonuniform_qualifier"
16+
SourceExtension "GL_EXT_ray_query"
17+
SourceExtension "GL_EXT_scalar_block_layout"
18+
SourceExtension "GL_GOOGLE_cpp_style_line_directive"
19+
SourceExtension "GL_GOOGLE_include_directive"
20+
Name 4 "main"
21+
Name 9 "outColor"
22+
Name 14 "topLevelAS"
23+
Decorate 9(outColor) Location 0
24+
Decorate 14(topLevelAS) DescriptorSet 0
25+
Decorate 14(topLevelAS) Binding 1
26+
2: TypeVoid
27+
3: TypeFunction 2
28+
6: TypeFloat 32
29+
7: TypeVector 6(float) 4
30+
8: TypePointer Output 7(fvec4)
31+
9(outColor): 8(ptr) Variable Output
32+
10: 6(float) Constant 0
33+
11: 7(fvec4) ConstantComposite 10 10 10 10
34+
12: TypeAccelerationStructureKHR
35+
13: TypePointer UniformConstant 12
36+
14(topLevelAS): 13(ptr) Variable UniformConstant
37+
4(main): 2 Function None 3
38+
5: Label
39+
Store 9(outColor) 11
40+
Return
41+
FunctionEnd

0 commit comments

Comments
 (0)