[Piglit] [PATCH] glsl-sdl-sincos-accuracy: Add a new test for a vc4 bug with SDL2.
Eric Anholt
eric at anholt.net
Sat Sep 22 00:23:05 UTC 2018
Our sin(0.0) and cos(0.0) were too inaccurate, causing twisting in
SDL2's rendering.
---
.../glsl-sdl-sincos-accuracy.shader_test | 36 +++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 tests/shaders/glsl-sdl-sincos-accuracy.shader_test
diff --git a/tests/shaders/glsl-sdl-sincos-accuracy.shader_test b/tests/shaders/glsl-sdl-sincos-accuracy.shader_test
new file mode 100644
index 000000000000..c6ca7e1ae596
--- /dev/null
+++ b/tests/shaders/glsl-sdl-sincos-accuracy.shader_test
@@ -0,0 +1,36 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+void main()
+{
+ gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+/* SDL2 prior to 12156:e5a666405750 (Aug 28) would render a bunch of
+ * its contents using cos/sin in the VS to handle a user-passed angle
+ * value (See SDL's RenderCopyEx, for example). If our error at angle
+ * == 0.0 is too much, we'll slightly rotate the images even with
+ * nearest filtering.
+ */
+uniform float angle;
+void main()
+{
+ float sin_err = abs(sin(angle) - 0.0);
+ float cos_err = abs(cos(angle) - 1.0);
+ /* Allow a tolerance of half a pixel of error at a 2048x2048
+ * window (viewport is from -1 to 1).
+ */
+ float tolerance = 2.0 / 2048.0 / 2.0;
+
+ gl_FragColor = vec4(sin_err >= tolerance,
+ sin_err < tolerance && cos_err < tolerance,
+ cos_err >= tolerance,
+ 0.0);
+}
+
+[test]
+uniform float angle 0.0
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 0.0
--
2.18.0
More information about the Piglit
mailing list