[Piglit] [PATCH] Test accuracy of dFdx and dFdy functions.

Paul Berry stereotype441 at gmail.com
Fri Sep 20 10:15:24 PDT 2013


Mesa/i965 currently (as of commit 1cc3b90) has an inaccurate
implementation of dFdy() which produces the same results for every
pixel in an aligned 2x2 block.  This piglit test exposes the
inaccuracy.
---
 .../execution/fs-dfdx-accuracy.shader_test         | 35 ++++++++++++++++++++++
 .../execution/fs-dfdy-accuracy.shader_test         | 35 ++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test
 create mode 100644 tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test

diff --git a/tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test b/tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test
new file mode 100644
index 0000000..b8d471c
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-dfdx-accuracy.shader_test
@@ -0,0 +1,35 @@
+# The spec allows considerable leeway in how dFdx() is calculated,
+# however the expected implementation is via forward or backward
+# differencing.  (Implementations are permitted, for instance, to use
+# forward differencing for some pixels and backward differencing for
+# other pixels).
+#
+# This test computes dFdx(x*y), which should exactly equal y at every
+# pixel, regardless of whether forward or backward differencing is
+# used.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+void main()
+{
+	gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+	float x = gl_FragCoord.x;
+	float y = gl_FragCoord.y;
+	float xy = x * y;
+	float dxydx = dFdx(xy);
+	if (distance(dxydx, y) > 1.0e-3)
+		gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+	else
+		gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test b/tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test
new file mode 100644
index 0000000..5c02680
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-dfdy-accuracy.shader_test
@@ -0,0 +1,35 @@
+# The spec allows considerable leeway in how dFdy() is calculated,
+# however the expected implementation is via forward or backward
+# differencing.  (Implementations are permitted, for instance, to use
+# forward differencing for some pixels and backward differencing for
+# other pixels).
+#
+# This test computes dFdy(x*y), which should exactly equal x at every
+# pixel, regardless of whether forward or backward differencing is
+# used.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+void main()
+{
+	gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+	float x = gl_FragCoord.x;
+	float y = gl_FragCoord.y;
+	float xy = x * y;
+	float dxydy = dFdy(xy);
+	if (distance(dxydy, x) > 1.0e-1)
+		gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+	else
+		gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.8.4



More information about the Piglit mailing list