[Piglit] [PATCH] glsl-{fs|vs}-loop-300.shader_test: test simple loops of 300 iterations

Jose Fonseca jfonseca at vmware.com
Thu Mar 22 01:55:20 PDT 2012


Look great!

Jose

----- Original Message -----
> PS 3.0 only supports loops of up to 255 iterations.  Test a
> 300-iteration
> loop to see what happens on platforms that eventually translate GLSL
> into
> PS 3.0 shaders.
> ---
>  tests/shaders/glsl-fs-loop-300.shader_test |   33
>  +++++++++++++++++++++++
>  tests/shaders/glsl-vs-loop-300.shader_test |   40
>  ++++++++++++++++++++++++++++
>  2 files changed, 73 insertions(+), 0 deletions(-)
>  create mode 100644 tests/shaders/glsl-fs-loop-300.shader_test
>  create mode 100644 tests/shaders/glsl-vs-loop-300.shader_test
> 
> diff --git a/tests/shaders/glsl-fs-loop-300.shader_test
> b/tests/shaders/glsl-fs-loop-300.shader_test
> new file mode 100644
> index 0000000..b171b87
> --- /dev/null
> +++ b/tests/shaders/glsl-fs-loop-300.shader_test
> @@ -0,0 +1,33 @@
> +[require]
> +GLSL >= 1.10
> +
> +[vertex shader file]
> +glsl-mvp.vert
> +
> +[fragment shader]
> +// Pass loop info as uniforms to avoid unrolling
> +// We test 300 iterations because that's greater than PS3.0's 255
> loop
> +// iteration limit.
> +uniform int iters;
> +uniform float step;
> +uniform float expected;
> +void main()
> +{
> +	float sum = 0.0;
> +	int i;
> +	for (i = 0; i < iters; i++) {
> +		sum += step;
> +	}
> +	if (sum == expected) {
> +		gl_FragColor = vec4(0, 1, 0, 1); // green=good
> +	} else {
> +		gl_FragColor = vec4(1, 0, 0, 1); // red=bad
> +	}
> +}
> +
> +[test]
> +uniform int iters 300
> +uniform float step 1.0
> +uniform float expected 300.0
> +draw rect -1 -1 2 2
> +probe rgb 1 1  0 1 0
> diff --git a/tests/shaders/glsl-vs-loop-300.shader_test
> b/tests/shaders/glsl-vs-loop-300.shader_test
> new file mode 100644
> index 0000000..b856755
> --- /dev/null
> +++ b/tests/shaders/glsl-vs-loop-300.shader_test
> @@ -0,0 +1,40 @@
> +[require]
> +GLSL >= 1.10
> +
> +[vertex shader]
> +// Pass loop info as uniforms to avoid unrolling
> +// We test 300 iterations because that's greater than PS3.0's 255
> loop
> +// iteration limit.
> +uniform int iters;
> +uniform float step;
> +uniform float expected;
> +varying vec4 color;
> +void main()
> +{
> +	float sum = 0.0;
> +	int i;
> +	for (i = 0; i < iters; i++) {
> +		sum += step;
> +	}
> +	if (sum == expected) {
> +		color = vec4(0, 1, 0, 1); // green=good
> +	} else {
> +		color = vec4(1, 0, 0, 1); // red=bad
> +	}
> +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +}
> +
> +
> +[fragment shader]
> +varying vec4 color;
> +void main()
> +{
> +	gl_FragColor = color;
> +}
> +
> +[test]
> +uniform int iters 300
> +uniform float step 1.0
> +uniform float expected 300.0
> +draw rect -1 -1 2 2
> +probe rgb 1 1  0 1 0
> --
> 1.7.3.4
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
> 


More information about the Piglit mailing list