yum-mirror/slang

Making it easier to work with shaders

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

Julius IkkalaImplement specialization constant support in numthreads / local_size (#5963)cbdc7e121

master
1.1 KiB35 linesraw
1//TEST:SIMPLE(filecheck=GLSL): -target glsl -allow-glsl
2//TEST:SIMPLE(filecheck=GLSL): -target glsl
3//TEST:SIMPLE(filecheck=CHECK): -target spirv -allow-glsl
4//TEST:SIMPLE(filecheck=CHECK): -target spirv
5
6// CHECK-DAG: OpExecutionModeId %computeMain1 LocalSizeId %[[C0:[0-9A-Za-z_]+]] %[[C1:[0-9A-Za-z_]+]] %[[C2:[0-9A-Za-z_]+]]
7// CHECK-DAG: OpDecorate %[[C0]] SpecId 1
8// CHECK-DAG: OpDecorate %[[C1]] SpecId 0
9// CHECK-DAG: %[[C2]] = OpConstant %int 4
10// CHECK-DAG: OpStore %{{.*}} %[[C0]]
11// CHECK-DAG: OpStore %{{.*}} %[[C1]]
12// CHECK-DAG: OpStore %{{.*}} %[[C2]]
13
14// GLSL-DAG: layout(constant_id = 1)
15// GLSL-DAG: int constValue0_0 = 0;
16// GLSL-DAG: layout(constant_id = 0)
17// GLSL-DAG: int constValue1_0 = 0;
18// GLSL-DAG: layout(local_size_x_id = 1, local_size_y_id = 0, local_size_z = 4) in;
19
20[vk::specialization_constant]
21const int constValue0 = 0;
22
23[vk::constant_id(0)]
24const int constValue1 = 0;
25
26RWStructuredBuffer<int> outputBuffer;
27
28[numthreads(constValue0, constValue1, 4)]
29void computeMain1()
30{
31    int3 size = WorkgroupSize();
32    outputBuffer[0] = size.x;
33    outputBuffer[1] = size.y;
34    outputBuffer[2] = size.z;
35}