Make GL_KHR_ray_query provide EOpConstructAccStruct

Previously, GL_KHR_ray_tracing was a required extension to generate
OpConvertUToAccelerationStructureKHR conversion instructions from uint64
and uvec2. However, both GL_KHR_ray_tracing and GL_KHR_ray_query should
provide this construction.

Change-Id: I6564c127fd28d9b527d334958a5adc168f5cdd9a
This commit is contained in:
Thomas Aven 2022-07-13 08:25:57 +02:00
parent 68c1880c09
commit 374c124025
5 changed files with 73 additions and 2 deletions

View File

@ -0,0 +1,51 @@
rayQuery-OpConvertUToAccelerationStructureKHR.comp
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 28
Capability Shader
Capability RayQueryKHR
Extension "SPV_KHR_ray_query"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 1 1 1
Source GLSL 460
SourceExtension "GL_EXT_ray_query"
Name 4 "main"
Name 8 "rayQuery"
Name 11 "params"
MemberName 11(params) 0 "tlas"
Name 13 ""
MemberDecorate 11(params) 0 Offset 0
Decorate 11(params) Block
2: TypeVoid
3: TypeFunction 2
6: TypeRayQueryKHR
7: TypePointer Private 6
8(rayQuery): 7(ptr) Variable Private
9: TypeInt 32 0
10: TypeVector 9(int) 2
11(params): TypeStruct 10(ivec2)
12: TypePointer PushConstant 11(params)
13: 12(ptr) Variable PushConstant
14: TypeInt 32 1
15: 14(int) Constant 0
16: TypePointer PushConstant 10(ivec2)
19: TypeAccelerationStructureKHR
21: 9(int) Constant 0
22: TypeFloat 32
23: TypeVector 22(float) 3
24: 22(float) Constant 0
25: 23(fvec3) ConstantComposite 24 24 24
26: 22(float) Constant 1065353216
27: 23(fvec3) ConstantComposite 26 26 26
4(main): 2 Function None 3
5: Label
17: 16(ptr) AccessChain 13 15
18: 10(ivec2) Load 17
20: 19 ConvertUToAccelerationStructureKHR 18
RayQueryInitializeKHR 8(rayQuery) 20 21 21 25 24 27 26
RayQueryTerminateKHR 8(rayQuery)
Return
FunctionEnd

View File

@ -0,0 +1,15 @@
#version 460
#extension GL_EXT_ray_query : enable
layout(push_constant, std140) uniform params
{
uvec2 tlas;
};
void main()
{
rayQueryEXT rayQuery;
rayQueryInitializeEXT(rayQuery, accelerationStructureEXT(tlas), 0, 0, vec3(0.0), 0.0, vec3(1.0), 1.0);
rayQueryTerminateEXT(rayQuery);
}

View File

@ -8095,12 +8095,12 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
case EOpConstructAccStruct:
if ((node->getType().isScalar() && node->getType().getBasicType() == EbtUint64)) {
// construct acceleration structure from uint64
requireExtensions(loc, 1, &E_GL_EXT_ray_tracing, "uint64_t conversion to acclerationStructureEXT");
requireExtensions(loc, Num_ray_tracing_EXTs, ray_tracing_EXTs, "uint64_t conversion to acclerationStructureEXT");
return intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvUint64ToAccStruct, true, node,
type);
} else if (node->getType().isVector() && node->getType().getBasicType() == EbtUint && node->getVectorSize() == 2) {
// construct acceleration structure from uint64
requireExtensions(loc, 1, &E_GL_EXT_ray_tracing, "uvec2 conversion to accelerationStructureEXT");
requireExtensions(loc, Num_ray_tracing_EXTs, ray_tracing_EXTs, "uvec2 conversion to accelerationStructureEXT");
return intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvUvec2ToAccStruct, true, node,
type);
} else

View File

@ -217,6 +217,10 @@ const char* const E_GL_EXT_fragment_shader_barycentric = "GL_EXT_fragment_s
const char* const post_depth_coverageEXTs[] = { E_GL_ARB_post_depth_coverage, E_GL_EXT_post_depth_coverage };
const int Num_post_depth_coverageEXTs = sizeof(post_depth_coverageEXTs) / sizeof(post_depth_coverageEXTs[0]);
// Array of extensions to cover both extensions providing ray tracing capabilities.
const char* const ray_tracing_EXTs[] = { E_GL_EXT_ray_query, E_GL_EXT_ray_tracing };
const int Num_ray_tracing_EXTs = sizeof(ray_tracing_EXTs) / sizeof(ray_tracing_EXTs[0]);
// OVR extensions
const char* const E_GL_OVR_multiview = "GL_OVR_multiview";
const char* const E_GL_OVR_multiview2 = "GL_OVR_multiview2";

View File

@ -258,6 +258,7 @@ INSTANTIATE_TEST_SUITE_P(
"rayQuery-initialization.Error.comp",
"rayQuery-global.rgen",
"rayQuery-types.comp",
"rayQuery-OpConvertUToAccelerationStructureKHR.comp",
"spv.set.vert",
"spv.double.comp",
"spv.100ops.frag",