yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeEnhance buffer load specialization pass to specialize past field extracts. (#8547)e4611e2e3

master
890 B35 linesraw
1//TEST:SIMPLE(filecheck=SPV): -target spirv -O0
2
3struct Bottom
4{
5    float bigArray[1024];
6    // SPV: %Bottom_bottomGetValue = OpFunction %float None %{{.*}}
7    // SPV-NEXT: %{{.*}} = OpFunctionParameter %int
8    // SPV-NEXT: OpLabel
9    // SPV-NOT: OpCompositeConstruct
10    // SPV: OpFunctionEnd
11
12    // SPV: %Bottom_bottomGetValue_0 = OpFunction %float None %{{.*}}
13    // SPV-NEXT: %{{.*}} = OpFunctionParameter %int
14    // SPV-NEXT: OpLabel
15    float bottomGetValue(int index) { return bigArray[index]; }
16}
17
18struct Root
19{
20    Bottom bottom1;
21    Bottom bottom2;
22}
23
24ConstantBuffer<Root> cb;
25
26RWStructuredBuffer<float> outputBuffer;
27
28[shader("compute")]
29[numthreads(1, 1, 1)]
30void compute_main(uint3 tid: SV_DispatchThreadID)
31{
32    outputBuffer[0] = cb.bottom1.bottomGetValue(0);
33    outputBuffer[1] = cb.bottom2.bottomGetValue(1);
34    outputBuffer[2] = cb.bottom2.bottomGetValue(2);
35}