yum-mirror/slang

Making it easier to work with shaders

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

Yong HeLower varying parameters as pointers instead of SSA values. (#5919)c43f6fa55

master
5.3 KiB137 linesraw
1//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry main -allow-glsl
2//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl
3#version 450
4
5layout(location = 0) out ivec4 outColorActual;
6
7layout (location = 0) in float inDataV1;
8layout (location = 1) in vec2 inDataV2;
9layout (location = 2) in vec3 inDataV3;
10layout (location = 3) in vec4 inDataV4;
11
12bool testFragmentProcessingDerivativeFunctionsScalar()
13{
14// CHECK_SPV: OpDPdx
15// CHECK_GLSL: dFdx
16// CHECK_SPV: OpDPdy
17// CHECK_GLSL: dFdy
18// CHECK_SPV: OpDPdxFine
19// CHECK_GLSL: dFdxFine
20// CHECK_SPV: OpDPdyFine
21// CHECK_GLSL: dFdyFine
22// CHECK_SPV: OpDPdxCoarse
23// CHECK_GLSL: dFdxCoarse
24// CHECK_SPV: OpDPdyCoarse
25// CHECK_GLSL: dFdyCoarse
26// CHECK_SPV: OpFwidth
27// CHECK_GLSL: fwidth
28// CHECK_SPV: OpFwidthFine
29// CHECK_GLSL: fwidthFine
30// CHECK_SPV: OpFwidthCoarse
31// CHECK_GLSL: fwidthCoarse
32    return true
33        && dFdx(1.0f) != -1.0f
34        && dFdy(1.0f) != -1.0f
35        && dFdxFine(1.0f) != -1.0f
36        && dFdyFine(1.0f) != -1.0f
37        && dFdxCoarse(1.0f) != -1.0f
38        && dFdyCoarse(1.0f) != -1.0f
39        && fwidth(1.0f) != -1.0f
40        && fwidthFine(1.0f) != -1.0f
41        && fwidthCoarse(1.0f) != -1.0f
42        ;
43}
44__generic<let N:int>
45bool testFragmentProcessingDerivativeFunctionsVector()
46{
47// CHECK_SPV: OpDPdx
48// CHECK_GLSL: dFdx
49// CHECK_SPV: OpDPdy
50// CHECK_GLSL: dFdy
51// CHECK_SPV: OpDPdxFine
52// CHECK_GLSL: dFdxFine
53// CHECK_SPV: OpDPdyFine
54// CHECK_GLSL: dFdyFine
55// CHECK_SPV: OpDPdxCoarse
56// CHECK_GLSL: dFdxCoarse
57// CHECK_SPV: OpDPdyCoarse
58// CHECK_GLSL: dFdyCoarse
59// CHECK_SPV: OpFwidth
60// CHECK_GLSL: fwidth
61// CHECK_SPV: OpFwidthFine
62// CHECK_GLSL: fwidthFine
63// CHECK_SPV: OpFwidthCoarse
64// CHECK_GLSL: fwidthCoarse
65    return true
66        && dFdx(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
67        && dFdy(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
68        && dFdxFine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
69        && dFdyFine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
70        && dFdxCoarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
71        && dFdyCoarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
72        && fwidth(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
73        && fwidthFine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
74        && fwidthCoarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f)
75        ;
76}
77bool testFragmentProcessingInterpolateFunctions()
78{
79// CHECK_SPV-DAG: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV1
80// CHECK_GLSL-DAG: interpolateAtCentroid{{.*}}inDataV1
81// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV1 {{.*}}
82// CHECK_GLSL: interpolateAtSample{{.*}}inDataV1
83// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV1 {{.*}}
84// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV1
85
86// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV2
87// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV2
88// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV2 {{.*}}
89// CHECK_GLSL: interpolateAtSample{{.*}}inDataV2
90// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV2 {{.*}}
91// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV2
92
93// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV3
94// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV3
95// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV3 {{.*}}
96// CHECK_GLSL: interpolateAtSample{{.*}}inDataV3
97// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV3 {{.*}}
98// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV3
99
100// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV4
101// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV4
102// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV4 {{.*}}
103// CHECK_GLSL: interpolateAtSample{{.*}}inDataV4
104// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV4 {{.*}}
105// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV4
106    return true
107        && interpolateAtCentroid(inDataV1) != -1.0f
108        && interpolateAtSample(inDataV1, 0) != -1.0f
109        && interpolateAtOffset(inDataV1, vec2(0.0f)) != -1.0f
110        && interpolateAtCentroid(inDataV2) != vector<float,2>(-1.0f)
111        && interpolateAtSample(inDataV2, 0) != vector<float,2>(-1.0f)
112        && interpolateAtOffset(inDataV2, vec2(0.0f)) != vector<float,2>(-1.0f)
113        && interpolateAtCentroid(inDataV3) != vector<float,3>(-1.0f)
114        && interpolateAtSample(inDataV3, 0) != vector<float,3>(-1.0f)
115        && interpolateAtOffset(inDataV3, vec2(0.0f)) != vector<float,3>(-1.0f)
116        && interpolateAtCentroid(inDataV4) != vector<float,4>(-1.0f)
117        && interpolateAtSample(inDataV4, 0) != vector<float,4>(-1.0f)
118        && interpolateAtOffset(inDataV4, vec2(0.0f)) != vector<float,4>(-1.0f)
119        ;
120}
121bool testFragmentProcessingFunctions()
122{
123    return true
124        && testFragmentProcessingDerivativeFunctionsScalar()
125        && testFragmentProcessingDerivativeFunctionsVector<2>()
126        && testFragmentProcessingDerivativeFunctionsVector<3>()
127        && testFragmentProcessingDerivativeFunctionsVector<4>()
128        && testFragmentProcessingInterpolateFunctions()
129        ;
130    ;
131}
132
133void main() {
134    outColorActual = ivec4(true
135        && testFragmentProcessingFunctions()
136        );
137}