Skip to content

Commit d9d0b4f

Browse files
authored
Fix optix varying legalization. (shader-slang#6089)
* Fix optix varying legalization. * Add test.
1 parent cb835b9 commit d9d0b4f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

source/slang/slang-ir-legalize-varying-params.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,8 @@ struct CUDAEntryPointVaryingParamLegalizeContext : EntryPointVaryingParamLegaliz
10531053
IRType* typeToFetch,
10541054
IRBuilder* builder)
10551055
{
1056+
if (auto ptrValType = tryGetPointedToType(builder, typeToFetch))
1057+
typeToFetch = ptrValType;
10561058
if (auto structType = as<IRStructType>(typeToFetch))
10571059
{
10581060
List<IRInst*> fieldVals;

tests/cuda/optix-hit-attributes.slang

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//TEST:SIMPLE(filecheck=CHECK): -target cuda
2+
//CHECK: __global__ void __closesthit__closestHitShaderA
3+
struct RayPayload
4+
{
5+
float4 color;
6+
};
7+
8+
[shader("closesthit")]
9+
void closestHitShaderA(inout RayPayload payload, in BuiltInTriangleIntersectionAttributes attr)
10+
{
11+
uint primitiveIndex = PrimitiveIndex();
12+
float4 color = float4(0, 0, 0, 1);
13+
color[primitiveIndex] = 1;
14+
payload.color = color;
15+
}

0 commit comments

Comments
 (0)