summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hlsl-intrinsic/fragment-derivative.slang105
-rw-r--r--tests/spirv/fwidth.slang54
2 files changed, 140 insertions, 19 deletions
diff --git a/tests/hlsl-intrinsic/fragment-derivative.slang b/tests/hlsl-intrinsic/fragment-derivative.slang
new file mode 100644
index 000000000..ff605aae6
--- /dev/null
+++ b/tests/hlsl-intrinsic/fragment-derivative.slang
@@ -0,0 +1,105 @@
+//TEST:SIMPLE(filecheck=CHECK_HLSL): -target hlsl -stage fragment -entry main
+//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main
+//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry main
+
+bool testFragmentProcessingDerivativeFunctionsScalar()
+{
+// CHECK_HLSL: ddx
+// CHECK_SPV: OpDPdx
+// CHECK_GLSL: dFdx
+// CHECK_HLSL: ddy
+// CHECK_SPV: OpDPdy
+// CHECK_GLSL: dFdy
+// CHECK_HLSL: ddx_fine
+// CHECK_SPV: OpDPdxFine
+// CHECK_GLSL: dFdxFine
+// CHECK_HLSL: ddy_fine
+// CHECK_SPV: OpDPdyFine
+// CHECK_GLSL: dFdyFine
+// CHECK_HLSL: ddx_coarse
+// CHECK_SPV: OpDPdxCoarse
+// CHECK_GLSL: dFdxCoarse
+// CHECK_HLSL: ddy_coarse
+// CHECK_SPV: OpDPdyCoarse
+// CHECK_GLSL: dFdyCoarse
+// CHECK_HLSL: fwidth
+// CHECK_SPV: OpFwidth
+// CHECK_GLSL: fwidth
+// CHECK_HLSL: abs(ddx_fine({{.*}})) + abs(ddy_fine({{.*}}))
+// CHECK_SPV: OpFwidthFine
+// CHECK_GLSL: fwidthFine
+// CHECK_HLSL: abs(ddx_coarse({{.*}})) + abs(ddy_coarse({{.*}}))
+// CHECK_SPV: OpFwidthCoarse
+// CHECK_GLSL: fwidthCoarse
+ return true
+ && ddx(1.0f) != -1.0f
+ && ddy(1.0f) != -1.0f
+ && ddx_fine(1.0f) != -1.0f
+ && ddy_fine(1.0f) != -1.0f
+ && ddx_coarse(1.0f) != -1.0f
+ && ddy_coarse(1.0f) != -1.0f
+ && fwidth(1.0f) != -1.0f
+ && fwidth_fine(1.0f) != -1.0f
+ && fwidth_coarse(1.0f) != -1.0f
+ ;
+}
+__generic<let N:int>
+bool testFragmentProcessingDerivativeFunctionsVector()
+{
+// CHECK_HLSL: ddx
+// CHECK_SPV: OpDPdx
+// CHECK_GLSL: dFdx
+// CHECK_HLSL: ddy
+// CHECK_SPV: OpDPdy
+// CHECK_GLSL: dFdy
+// CHECK_HLSL: ddx_fine
+// CHECK_SPV: OpDPdxFine
+// CHECK_GLSL: dFdxFine
+// CHECK_HLSL: ddy_fine
+// CHECK_SPV: OpDPdyFine
+// CHECK_GLSL: dFdyFine
+// CHECK_HLSL: ddx_coarse
+// CHECK_SPV: OpDPdxCoarse
+// CHECK_GLSL: dFdxCoarse
+// CHECK_HLSL: ddy_coarse
+// CHECK_SPV: OpDPdyCoarse
+// CHECK_GLSL: dFdyCoarse
+// CHECK_HLSL: fwidth
+// CHECK_SPV: OpFwidth
+// CHECK_GLSL: fwidth
+// CHECK_HLSL: abs(ddx_fine({{.*}})) + abs(ddy_fine({{.*}}))
+// CHECK_SPV: OpFwidthFine
+// CHECK_GLSL: fwidthFine
+// CHECK_HLSL: abs(ddx_coarse({{.*}})) + abs(ddy_coarse({{.*}}))
+// CHECK_SPV: OpFwidthCoarse
+// CHECK_GLSL: fwidthCoarse
+ return true
+ && all(ddx(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(ddy(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(ddx_fine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(ddy_fine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(ddx_coarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(ddy_coarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(fwidth(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(fwidth_fine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ && all(fwidth_coarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f))
+ ;
+}
+
+bool testFragmentProcessingFunctions()
+{
+ return true
+ && testFragmentProcessingDerivativeFunctionsScalar()
+ && testFragmentProcessingDerivativeFunctionsVector<2>()
+ && testFragmentProcessingDerivativeFunctionsVector<3>()
+ && testFragmentProcessingDerivativeFunctionsVector<4>()
+ ;
+ ;
+}
+
+[shader("pixel")]
+int4 main() : SV_Target {
+ return int4(true
+ && testFragmentProcessingFunctions()
+ );
+}
diff --git a/tests/spirv/fwidth.slang b/tests/spirv/fwidth.slang
index a55dfa3b0..a65e799f5 100644
--- a/tests/spirv/fwidth.slang
+++ b/tests/spirv/fwidth.slang
@@ -17,50 +17,66 @@ void main()
float b2 = ddy(w);
output[2] = b2;
- // CHECK: OpDPdxCoarse
- float b3 = ddx_coarse(w);
+ // CHECK: OpFwidthCoarse
+ float b3 = fwidth_coarse(w);
output[3] = b3;
- // CHECK: OpDPdyCoarse
- float b4 = ddy_coarse(w);
+ // CHECK: OpDPdxCoarse
+ float b4 = ddx_coarse(w);
output[4] = b4;
- // CHECK: OpDPdxFine
- float b5 = ddx_fine(w);
+ // CHECK: OpDPdyCoarse
+ float b5 = ddy_coarse(w);
output[5] = b5;
- // CHECK: OpDPdyFine
- float b6 = ddy_fine(w);
+ // CHECK: OpFwidthFine
+ float b6 = fwidth_fine(w);
output[6] = b6;
+
+ // CHECK: OpDPdxFine
+ float b7 = ddx_fine(w);
+ output[7] = b7;
+
+ // CHECK: OpDPdyFine
+ float b8 = ddy_fine(w);
+ output[8] = b8;
}
{
// CHECK: OpFwidth
float3 w = 1.0;
float3 b = fwidth(w);
- output[7] = b.x;
+ output[9] = b.x;
// CHECK: OpDPdx
float3 b1 = ddx(w);
- output[8] = b1.x;
+ output[10] = b1.x;
// CHECK: OpDPdy
float3 b2 = ddy(w);
- output[9] = b2.x;
+ output[11] = b2.x;
+
+ // CHECK: OpFwidthCoarse
+ float3 b3 = fwidth_coarse(w);
+ output[12] = b3.x;
// CHECK: OpDPdxCoarse
- float3 b3 = ddx_coarse(w);
- output[10] = b3.x;
+ float3 b4 = ddx_coarse(w);
+ output[13] = b4.x;
// CHECK: OpDPdyCoarse
- float3 b4 = ddy_coarse(w);
- output[11] = b4.x;
+ float3 b5 = ddy_coarse(w);
+ output[14] = b5.x;
+
+ // CHECK: OpFwidthFine
+ float3 b6 = fwidth_fine(w);
+ output[15] = b6.x;
// CHECK: OpDPdxFine
- float3 b5 = ddx_fine(w);
- output[12] = b5.x;
+ float3 b7 = ddx_fine(w);
+ output[16] = b7.x;
// CHECK: OpDPdyFine
- float3 b6 = ddy_fine(w);
- output[13] = b6.x;
+ float3 b8 = ddy_fine(w);
+ output[17] = b8.x;
}
}