Skip to content

Commit b64a23c

Browse files
author
Tim Foley
authored
Fix the "acceleration structure in compute" bug for GL_NV_ray_tracing too (shader-slang#1759)
A recent change broke code that uses `RayTracingAccelerationStructure` in non-RT shader stages for Vulkan/GLSL when also *not* doing any ray tracing in the shader code. A recent fix patched that up for code using `GL_EXT_ray_tracing` and/or `GL_EXT_ray_query`, but that fix didn't apply on the path that uses `GL_NV_ray_tracing` via an opt-in. This change fixes that gap and checks in a test for it.
1 parent 210a988 commit b64a23c

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

source/slang/slang-emit-glsl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,7 @@ void GLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
18221822
// We know that the acceleration structure type will translate
18231823
// to the one from that extension:
18241824
//
1825+
_requireRayTracing();
18251826
m_writer->emit("accelerationStructureNV");
18261827
}
18271828
else
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// acceleration-structure-in-compute.slang
2+
3+
// Test for using ray-tracing acceleration structures as a shader input
4+
// in non-ray-tracing shader code (that never actually traces rays)
5+
6+
//TEST:CROSS_COMPILE:-target spirv-asm -stage compute -profile glsl_460+GL_NV_ray_tracing -entry main -DUSE_NV_EXT=1
7+
8+
uniform RaytracingAccelerationStructure gScene;
9+
10+
int helper(RaytracingAccelerationStructure a, int b)
11+
{
12+
return b;
13+
}
14+
15+
[shader("compute")]
16+
void main(
17+
uniform RaytracingAccelerationStructure x)
18+
{
19+
helper(x, 1);
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#version 460
2+
3+
#extension GL_NV_ray_tracing : require
4+
5+
int helper_0(accelerationStructureNV a_0, int b_0)
6+
{
7+
return b_0;
8+
}
9+
10+
layout(binding = 1)
11+
uniform accelerationStructureNV entryPointParams_x_0;
12+
13+
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
14+
void main()
15+
{
16+
int _S1 = helper_0(entryPointParams_x_0, 1);
17+
return;
18+
}

0 commit comments

Comments
 (0)