forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultipleinout.slang
36 lines (30 loc) · 1.3 KB
/
multipleinout.slang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//TEST:SIMPLE(filecheck=CHECK): -stage closesthit -entry main -target spirv -emit-spirv-directly
// This test checks whether the spirv generated when there are multiple inout or out variables, they
// all get consolidated into one IncomingRayPayloadKHR.
struct ReflectionRay
{
float4 color;
};
StructuredBuffer<float4> colors;
[shader("closesthit")]
void main(
BuiltInTriangleIntersectionAttributes attributes,
inout ReflectionRay ioPayload,
out float3 dummy)
{
uint materialID = (InstanceIndex() << 1)
+ InstanceID()
+ PrimitiveIndex()
+ HitKind();
ioPayload.color = colors[materialID];
dummy = HitTriangleVertexPosition(0);
}
// CHECK: OpEntryPoint ClosestHitKHR %main "main" %{{.*}} %{{.*}} %gl_PrimitiveID %{{.*}} %gl_InstanceID %colors %{{.*}}
// CHECK: %_struct_{{.*}} = OpTypeStruct %ReflectionRay %v3float
// CHECK: %_ptr_IncomingRayPayloadKHR__struct_{{.*}} = OpTypePointer IncomingRayPayloadKHR %_struct_{{.*}}
// CHECK: %main = OpFunction %void None %{{.*}}
// CHECK: %materialID = OpIAdd %uint %{{.*}} %{{.*}}
// CHECK: %{{.*}} = OpAccessChain %_ptr_StorageBuffer_v4float %colors %int_0 %materialID
// CHECK: %{{.*}} = OpLoad %v4float %{{.*}}
// CHECK: %{{.*}} = OpAccessChain %_ptr_Input_v3float %{{.*}} %uint_0
// CHECK: %{{.*}} = OpLoad %v3float %{{.*}}