GLSL: Ensure ray query object decls are flushed if allocated in Function.
glslang always emits Private variables, but DXC not so much.
This commit is contained in:
parent
e51630595f
commit
18f3cd6810
@ -0,0 +1,15 @@
|
||||
#version 460
|
||||
#extension GL_EXT_ray_query : require
|
||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout(set = 0, binding = 0) uniform accelerationStructureEXT RTAS;
|
||||
|
||||
float _16;
|
||||
vec3 _17;
|
||||
|
||||
void main()
|
||||
{
|
||||
rayQueryEXT _19;
|
||||
rayQueryInitializeEXT(_19, RTAS, 2u, 255u, _17, _16, _17, _16);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
OpCapability Shader
|
||||
OpCapability RayTracingKHR
|
||||
OpCapability RayQueryKHR
|
||||
OpExtension "SPV_KHR_ray_tracing"
|
||||
OpExtension "SPV_KHR_ray_query"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main" %RTAS %gl_LocalInvocationIndex
|
||||
OpExecutionMode %main LocalSize 64 1 1
|
||||
OpSource GLSL 460
|
||||
OpName %accelerationStructureNV "accelerationStructureNV"
|
||||
OpName %RTAS "RTAS"
|
||||
OpName %main "main"
|
||||
OpName %rayQueryKHR "rayQueryKHR"
|
||||
OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
|
||||
OpDecorate %RTAS DescriptorSet 0
|
||||
OpDecorate %RTAS Binding 0
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_255 = OpConstant %uint 255
|
||||
%accelerationStructureNV = OpTypeAccelerationStructureKHR
|
||||
%_ptr_UniformConstant_accelerationStructureNV = OpTypePointer UniformConstant %accelerationStructureNV
|
||||
%_ptr_Input_uint = OpTypePointer Input %uint
|
||||
%void = OpTypeVoid
|
||||
%12 = OpTypeFunction %void
|
||||
%rayQueryKHR = OpTypeRayQueryKHR
|
||||
%_ptr_Function_rayQueryKHR = OpTypePointer Function %rayQueryKHR
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%RTAS = OpVariable %_ptr_UniformConstant_accelerationStructureNV UniformConstant
|
||||
%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
|
||||
%16 = OpUndef %float
|
||||
%17 = OpUndef %v3float
|
||||
%main = OpFunction %void None %12
|
||||
%18 = OpLabel
|
||||
%19 = OpVariable %_ptr_Function_rayQueryKHR Function
|
||||
%20 = OpLoad %accelerationStructureNV %RTAS
|
||||
OpRayQueryInitializeKHR %19 %20 %uint_2 %uint_255 %17 %16 %17 %16
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -12546,6 +12546,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
|
||||
// Don't bother forwarding temporaries. Avoids having to test expression invalidation with ray query objects.
|
||||
case OpRayQueryInitializeKHR:
|
||||
flush_variable_declaration(ops[0]);
|
||||
statement("rayQueryInitializeEXT(",
|
||||
to_expression(ops[0]), ", ", to_expression(ops[1]), ", ",
|
||||
to_expression(ops[2]), ", ", to_expression(ops[3]), ", ",
|
||||
@ -12553,23 +12554,29 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
to_expression(ops[6]), ", ", to_expression(ops[7]), ");");
|
||||
break;
|
||||
case OpRayQueryProceedKHR:
|
||||
flush_variable_declaration(ops[0]);
|
||||
emit_op(ops[0], ops[1], join("rayQueryProceedEXT(", to_expression(ops[2]), ")"), false);
|
||||
break;
|
||||
case OpRayQueryTerminateKHR:
|
||||
flush_variable_declaration(ops[0]);
|
||||
statement("rayQueryTerminateEXT(", to_expression(ops[0]), ");");
|
||||
break;
|
||||
case OpRayQueryGenerateIntersectionKHR:
|
||||
flush_variable_declaration(ops[0]);
|
||||
statement("rayQueryGenerateIntersectionEXT(", to_expression(ops[0]), ", ", to_expression(ops[1]), ");");
|
||||
break;
|
||||
case OpRayQueryConfirmIntersectionKHR:
|
||||
flush_variable_declaration(ops[0]);
|
||||
statement("rayQueryConfirmIntersectionEXT(", to_expression(ops[0]), ");");
|
||||
break;
|
||||
#define GLSL_RAY_QUERY_GET_OP(op) \
|
||||
case OpRayQueryGet##op##KHR: \
|
||||
flush_variable_declaration(ops[2]); \
|
||||
emit_op(ops[0], ops[1], join("rayQueryGet" #op "EXT(", to_expression(ops[2]), ")"), false); \
|
||||
break
|
||||
#define GLSL_RAY_QUERY_GET_OP2(op) \
|
||||
case OpRayQueryGet##op##KHR: \
|
||||
flush_variable_declaration(ops[2]); \
|
||||
emit_op(ops[0], ops[1], join("rayQueryGet" #op "EXT(", to_expression(ops[2]), ", ", "bool(", to_expression(ops[3]), "))"), false); \
|
||||
break
|
||||
GLSL_RAY_QUERY_GET_OP(RayTMin);
|
||||
|
Loading…
Reference in New Issue
Block a user