yum-mirror/slang

Making it easier to work with shaders

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

kaizhangNVFix issue of missing scope for 'Differential' type (#7433)60b66c309

master
663 B31 linesraw
1//TEST:SIMPLE(filecheck=CHECK):-target spirv -emit-spirv-via-glsl
2
3// This test is to test that PartlyDiffable.Differential is synthesized
4// with correct scope. If not, the constructor for it will be wrong, and
5// slang will generate wrong code, the downstream compiler will fail to
6// compile.
7
8// CHECK: OpEntryPoint Fragment
9
10struct PartlyDiffable : IDifferentiable
11{
12    int i;
13    float q;
14}
15
16
17func breaker(x:PartlyDiffable.Differential) {
18    return;
19}
20
21
22[shader("fragment")]
23float4 fragment(float4 in: SV_Position)
24    : SV_Target
25{
26    if (PartlyDiffable.Differential(0).q == 0) {
27        return float4(0);
28    } else {
29        return float4(1);
30    }
31}