yum-mirror/slang

Making it easier to work with shaders

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

Yong HeDefer immutable buffer loads when emitting spirv. (#7579)c701ec00c

master
1.6 KiB46 linesraw
1// Test that using workgroup size from more than one entrypoint result in
2// correct lowering into global variable.
3
4//TEST:SIMPLE(filecheck=CHECK_EXPERIMENTAL): -target spirv -emit-spirv-directly -fvk-use-entrypoint-name -O0 -enable-experimental-passes
5//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -fvk-use-entrypoint-name -O0
6
7
8
9RWStructuredBuffer<int> outputBuffer;
10
11uint3 f() { return WorkgroupSize(); }
12
13[shader("compute")]
14[numthreads(1u, 2u, 3)]
15void compute1()
16{
17    // CHECK_EXPERIMENTAL-DAG: %[[VAR:[A-Za-z0-9_]+]] = OpTypePointer Function %v3int
18    // CHECK_EXPERIMENTAL: Op{{.*}}AccessChain %[[VAR]]
19    //
20    // CHECK_EXPERIMENTAL-DAG: %[[CALL_RS:[A-Za-z0-9_]+]] = OpFunctionCall %v3uint %f
21    // CHECK_EXPERIMENTAL: OpCompositeExtract %uint %[[CALL_RS]] 0
22    //
23    // CHECK_EXPERIMENTAL-DAG: %[[PTR:[A-Za-z0-9_]+]] = Op{{.*}}AccessChain %_ptr_StorageBuffer_int %outputBuffer %int_0 %int_1
24    // CHECK_EXPERIMENTAL: OpStore %[[PTR]] %int_2
25
26    // CHECK-DAG: %[[VAR:[A-Za-z0-9_]+]] = OpVariable %_ptr_Private_v3int Private
27    // CHECK: OpStore %[[VAR]]
28    //
29    // CHECK-DAG: %[[CALL_RS:[A-Za-z0-9_]+]] = OpFunctionCall %v3uint %f
30    // CHECK: OpCompositeExtract %uint %[[CALL_RS]] 0
31    //
32    // CHECK-DAG: %[[PTR:[A-Za-z0-9_]+]] = Op{{.*}}AccessChain %_ptr_StorageBuffer_int %outputBuffer %int_0 %int_1
33    // CHECK: OpStore %[[PTR]] %int_2
34
35    const int x = f().x;
36    outputBuffer[0] = x;
37    outputBuffer[1] = WorkgroupSize().y;
38}
39
40[shader("compute")]
41[numthreads(4, 5, 6)]
42void compute2()
43{
44    const int x = f().x;
45    outputBuffer[0] = x;
46}