yum-mirror/slang

Making it easier to work with shaders

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

jarcherNVAllow checking capabilities in specific stages (#7375)3fa382505

master
1.5 KiB49 linesraw
1//TEST:SIMPLE(filecheck=CHECK_CS): -target hlsl -stage compute -entry computeMain -profile cs_6_3
2//TEST:SIMPLE(filecheck=CHECK_SM): -target hlsl -stage compute -entry computeMain -profile sm_6_3
3//TEST:SIMPLE(filecheck=CHECK_CS_CAP): -target hlsl -stage compute -entry computeMain -profile cs_6_3 -capability hlsl_2018
4//TEST:SIMPLE(filecheck=CHECK_SM_CAP): -target hlsl -stage compute -entry computeMain -profile sm_6_3 -capability hlsl_2018
5
6// Test IR code generation for the `?:` "select" operator with the hlsl_2018 capability and cs_6_3 profile.
7
8// Verify that select is emitted for cs_6_3 and sm_6_3.
9// CHECK_CS: select({{.*}})
10// CHECK_SM: select({{.*}})
11// CHECK_CS-NOT: {{.*}}?{{.*}}:{{.*}}
12// CHECK_SM-NOT: {{.*}}?{{.*}}:{{.*}}
13
14// Verify that select is not emitted for cs_6_3 and sm_6_3 with the hlsl_2018 capability.
15// CHECK_CS_CAP-NOT: select({{.*}})
16// CHECK_SM_CAP-NOT: select({{.*}})
17// CHECK_CS_CAP: {{.*}}?{{.*}}:{{.*}}
18// CHECK_SM_CAP: {{.*}}?{{.*}}:{{.*}}
19
20RWStructuredBuffer<int> outputBuffer;
21static int result = 0;
22bool2 assignFunc(int index)
23{
24    result++;
25    return bool2(true);
26}
27
28[numthreads(4, 1, 1)]
29void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
30{
31    int index = dispatchThreadID.x;
32
33    if (all(bool2(index >= 1) && assignFunc(index)))
34    {
35        result++;
36    }
37
38    if (all(bool2(index >= 2) || !assignFunc(index)))
39    {
40        result++;
41    }
42
43    if (all(bool2(index >= 3) ? assignFunc(index) : bool2(false)))
44    {
45        result++;
46    }
47
48    outputBuffer[index] = result;
49}