summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
authorpdeayton-nv <205388607+pdeayton-nv@users.noreply.github.com>2025-05-01 14:51:34 -0700
committerGitHub <noreply@github.com>2025-05-01 14:51:34 -0700
commit7d7027853a94c83e9b90b8a11877e91cdaa3e81b (patch)
tree6ed96ae4fc5b2cbfaa0abfd44769eaab2ef6b981 /tests/spirv
parentdde654c8605ea65f959fcadaa6618337ab1f20c0 (diff)
Add fwidth_coarse and fwidth_fine functions (#6941)
Fixes #6940. Add new Slang fwidth_coarse and fwidth_fine functions, similar to GLSL's fwidthCoarse and fwidthFine. Move the implementation of the GLSL functions from glsl.meta.slang to hlsl.meta.slang. Update the existing spirv/fwidth.slang test with the new functions, and add a new hlsl-intrinsic/fragment-derivative.slang test to test HLSL, SPIR-V, and GLSL targets for the new functions.
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/fwidth.slang54
1 files changed, 35 insertions, 19 deletions
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;
}
}