summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/stage-switch.slang
blob: 1bdd1f85a72562685eab81c97927ec815fc224a8 (plain)
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
37
38
//TEST:SIMPLE(filecheck=CHECK):-target spirv

float ddx_or(float val, float defaultVal)
{
    __stage_switch
    {
        case fragment:
            return ddx(val);
        default:
            return defaultVal;
    }
}

float intermediate(float val)
{
    return ddx_or(val, 1.0);
}

RWStructuredBuffer<float> output;

[numthreads(1,1,1)]
void computeMain()
{
    // CHECK-LABEL: %computeMain = OpFunction 
    // CHECK: OpStore %{{.*}} %float_1
    // CHECK: OpFunctionEnd
    output[0] = intermediate(2.0);
}

[shader("fragment")]
float4 fragmentMain(float vin) : SV_Target
{
    // CHECK-LABEL: %fragmentMain = OpFunction 
    // CHECK: OpDPdx
    // CHECK: OpFunctionEnd
    return intermediate(vin);
}