Add ray query capability if acceleration structure or ray query types declared (#2469)

* Add ray query capability if acceleration structure used

Fixes #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"
This commit is contained in:
Daniel Koch 2020-11-24 23:06:16 -05:00 committed by GitHub
parent ffccefddfd
commit 4d41da3b81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 145 additions and 9 deletions

View File

@ -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:
{

View File

@ -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";

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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
);