glsl-sdl-sincos-accuracy: Add a new test for a vc4 bug with SDL2.

Submitted by Eric Anholt on Sept. 22, 2018, 12:23 a.m.

Details

Message ID 20180922002305.13244-1-eric@anholt.net
State New
Headers show
Series "glsl-sdl-sincos-accuracy: Add a new test for a vc4 bug with SDL2." ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Eric Anholt Sept. 22, 2018, 12:23 a.m.
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

Patch hide | download patch | download mbox

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

Comments

One small nit below, otherwise LGTM

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>

On 9/22/18 3:23 AM, Eric Anholt wrote:
> 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;
> +}

could use [vertex shader passthrough]

> +
> +[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
>