[Piglit] [PATCH 3/3] glsl-1.50: Port over basic UBO tests from glsl 1.40 VS to glsl 1.50 GS

Fabian Bieler fabianbieler at fastmail.fm
Mon Jun 17 20:42:27 PDT 2013


On 2013-06-17 22:34, Eric Anholt wrote:
> gs-struct-array-complicated is currently crashing in Mesa, and
> gs-struct-pad is broken like it is for VS/FS.
> ---
>  .../uniform_buffer/gs-array-copy.shader_test       |  64 +++++++++
>  .../glsl-1.50/uniform_buffer/gs-basic.shader_test  |  57 ++++++++
>  .../glsl-1.50/uniform_buffer/gs-bools.shader_test  |  63 +++++++++
>  .../gs-float-array-const-index.shader_test         |  60 +++++++++
>  .../gs-float-array-variable-index.shader_test      |  67 ++++++++++
>  .../glsl-1.50/uniform_buffer/gs-floats.shader_test |  63 +++++++++
>  .../uniform_buffer/gs-mat4-row-major.shader_test   |  57 ++++++++
>  .../glsl-1.50/uniform_buffer/gs-mat4.shader_test   |  57 ++++++++
>  .../gs-struct-copy-complicated.shader_test         | 144 +++++++++++++++++++++
>  .../uniform_buffer/gs-struct-copy.shader_test      |  66 ++++++++++
>  .../uniform_buffer/gs-struct-pad.shader_test       |  70 ++++++++++
>  .../glsl-1.50/uniform_buffer/gs-struct.shader_test |  65 ++++++++++
>  .../uniform_buffer/gs-two-members.shader_test      |  59 +++++++++
>  13 files changed, 892 insertions(+)
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-array-copy.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-basic.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-bools.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-float-array-const-index.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-float-array-variable-index.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-floats.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-mat4-row-major.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-mat4.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-struct-copy-complicated.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-struct-copy.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-struct-pad.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-struct.shader_test
>  create mode 100644 tests/spec/glsl-1.50/uniform_buffer/gs-two-members.shader_test
> 
[...]
> diff --git a/tests/spec/glsl-1.50/uniform_buffer/gs-struct-copy-complicated.shader_test b/tests/spec/glsl-1.50/uniform_buffer/gs-struct-copy-complicated.shader_test
> new file mode 100644
> index 0000000..f518377
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/uniform_buffer/gs-struct-copy-complicated.shader_test
> @@ -0,0 +1,144 @@
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +out vec4 vertex_to_gs;
> +
> +void main()
> +{
> +	vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +struct S2 {
> +	vec2 v2;
> +	mat2 m22[2];
> +};
> +
> +uniform ubo1 {
> +	struct S {
> +		S2 arr[2];
> +		vec3 v3;
> +		bool b;
> +	} s[2];
>From gl GLSL 1.5 spec page 35 (page 41 of the PDF):
"Types and declarators are the same as for other input, output, and uniform variable declarations outside
blocks, with these exceptions:
[...]
•   structure definitions cannot be nested inside a block"
This applies to all *struct* tests in the series.
Note that this exception is missing from the 1.4 spec.
> +};
> +
> +in vec4 vertex_to_gs[3];
> +out vec4 v;
> +
> +void main()
> +{
> +	for (int i = 0; i < 3; i++) {
> +		gl_Position = vertex_to_gs[i];
> +
> +		S temp[2] = s;
> +
> +		/* Try to prevent copy propagation */
> +		temp[0].arr[0].v2 = vec2(0.01, 0.02);
> +
> +		v = vec4(0, 1, 0, 0);
> +
> +		if (temp[0].arr[0].v2 != vec2(0.01, 0.02))
> +			v = vec4(0.02, 0, temp[0].arr[0].v2);
> +		else if (temp[0].arr[0].m22[0][0] != vec2(0.03, 0.04))
> +			v = vec4(0.04, 0, temp[0].arr[0].m22[0][0]);
> +		else if (temp[0].arr[0].m22[0][1] != vec2(0.05, 0.06))
> +			v = vec4(0.06, 0, temp[0].arr[0].m22[0][1]);
> +		else if (temp[0].arr[0].m22[1][0] != vec2(0.07, 0.08))
> +			v = vec4(0.08, 0, temp[0].arr[0].m22[1][0]);
> +		else if (temp[0].arr[0].m22[1][1] != vec2(0.09, 0.10))
> +			v = vec4(0.10, 0, temp[0].arr[0].m22[1][1]);
> +
> +		else if (temp[0].arr[1].v2 != vec2(0.21, 0.22))
> +			v = vec4(0.22, 0, temp[0].arr[1].v2);
> +		else if (temp[0].arr[1].m22[0][0] != vec2(0.23, 0.24))
> +			v = vec4(0.24, 0, temp[0].arr[1].m22[0][0]);
> +		else if (temp[0].arr[1].m22[0][1] != vec2(0.25, 0.26))
> +			v = vec4(0.26, 0, temp[0].arr[1].m22[0][1]);
> +		else if (temp[0].arr[1].m22[1][0] != vec2(0.27, 0.28))
> +			v = vec4(0.28, 0, temp[0].arr[1].m22[1][0]);
> +		else if (temp[0].arr[1].m22[1][1] != vec2(0.29, 0.30))
> +			v = vec4(0.30, 0, temp[0].arr[1].m22[1][1]);
> +
> +		else if (temp[0].v3 != vec3(0.31, 0.32, 0.33))
> +			v = vec4(0.32, temp[0].v3);
> +		else if (temp[0].b != false)
> +			v = vec4(0.34, 0, 0, temp[0].b);
> +
> +		else if (temp[1].arr[0].v2 != vec2(0.41, 0.42))
> +			v = vec4(0.42, 0, temp[1].arr[0].v2);
> +		else if (temp[1].arr[0].m22[0][0] != vec2(0.43, 0.44))
> +			v = vec4(0.44, 0, temp[1].arr[0].m22[0][0]);
> +		else if (temp[1].arr[0].m22[0][1] != vec2(0.45, 0.46))
> +			v = vec4(0.46, 0, temp[1].arr[0].m22[0][1]);
> +		else if (temp[1].arr[0].m22[1][0] != vec2(0.47, 0.48))
> +			v = vec4(0.48, 0, temp[1].arr[0].m22[1][0]);
> +		else if (temp[1].arr[0].m22[1][1] != vec2(0.49, 0.50))
> +			v = vec4(0.50, 0, temp[1].arr[0].m22[1][1]);
> +
> +		else if (temp[1].arr[1].v2 != vec2(0.61, 0.62))
> +			v = vec4(0.62, 0, temp[1].arr[1].v2);
> +		else if (temp[1].arr[1].m22[0][0] != vec2(0.63, 0.64))
> +			v = vec4(0.64, 0, temp[1].arr[1].m22[0][0]);
> +		else if (temp[1].arr[1].m22[0][1] != vec2(0.65, 0.66))
> +			v = vec4(0.66, 0, temp[1].arr[1].m22[0][1]);
> +		else if (temp[1].arr[1].m22[1][0] != vec2(0.67, 0.68))
> +			v = vec4(0.68, 0, temp[1].arr[1].m22[1][0]);
> +		else if (temp[1].arr[1].m22[1][1] != vec2(0.69, 0.70))
> +			v = vec4(0.70, 0, temp[1].arr[1].m22[1][1]);
> +
> +		else if (temp[1].v3 != vec3(0.71, 0.72, 0.73))
> +			v = vec4(0.72, temp[1].v3);
> +		else if (temp[1].b != true)
> +			v = vec4(0.74, 0, 0, temp[1].b);
> +
> +		EmitVertex();
> +	}
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 v;
> +
> +void main()
> +{
> +	gl_FragColor = v;
> +}
> +
> +[vertex data]
> +vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0  1.0
> +-1.0  1.0
> +
> +[test]
> +uniform vec2 s[0].arr[0].v2 0.99 0.99
> +uniform mat2 s[0].arr[0].m22[0] 0.03 0.04 0.05 0.06
> +uniform mat2 s[0].arr[0].m22[1] 0.07 0.08 0.09 0.10
> +uniform vec2 s[0].arr[1].v2 0.21 0.22
> +uniform mat2 s[0].arr[1].m22[0] 0.23 0.24 0.25 0.26
> +uniform mat2 s[0].arr[1].m22[1] 0.27 0.28 0.29 0.30
> +uniform vec3 s[0].v3 0.31 0.32 0.33
> +uniform int s[0].b 0
> +
> +uniform vec2 s[1].arr[0].v2 0.41 0.42
> +uniform mat2 s[1].arr[0].m22[0] 0.43 0.44 0.45 0.46
> +uniform mat2 s[1].arr[0].m22[1] 0.47 0.48 0.49 0.50
> +uniform vec2 s[1].arr[1].v2 0.61 0.62
> +uniform mat2 s[1].arr[1].m22[0] 0.63 0.64 0.65 0.66
> +uniform mat2 s[1].arr[1].m22[1] 0.67 0.68 0.69 0.70
> +uniform vec3 s[1].v3 0.71 0.72 0.73
> +uniform int s[1].b 2
> +
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe all rgba 0.0 1.0 0.0 0.0
[...]
> diff --git a/tests/spec/glsl-1.50/uniform_buffer/gs-struct-pad.shader_test b/tests/spec/glsl-1.50/uniform_buffer/gs-struct-pad.shader_test
> new file mode 100644
> index 0000000..c0e91a0
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/uniform_buffer/gs-struct-pad.shader_test
> @@ -0,0 +1,70 @@
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +out vec4 vertex_to_gs;
> +
> +void main()
> +{
> +	vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +uniform ubo1 {
> +	struct S {
> +		struct S1 {
> +			float r;
> +		} s1;
Embedded structure definitions are not allowed in GLSL. This applies to the 1.4 tests [vf]s-struct-pad as well.
> +
> +		struct S2 {
> +			float g;
> +			float b;
> +			float a;
> +		} s2;
> +	} s;
> +};
> +
> +in vec4 vertex_to_gs[3];
> +out vec4 v;
> +
> +void main()
> +{
> +	for (int i = 0; i < 3; i++) {
> +		gl_Position = vertex_to_gs[i];
> +		v = vec4(s.s1.r, s.s2.g, s.s2.b, s.s2.a);
> +		EmitVertex();
> +	}
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 v;
> +
> +void main()
> +{
> +	gl_FragColor = v;
> +}
> +
> +[vertex data]
> +vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0  1.0
> +-1.0  1.0
> +
> +[test]
> +uniform float s.s1.r 0.0
> +uniform float s.s2.g 1.0
> +uniform float s.s2.b 0.0
> +uniform float s.s2.a 0.0
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe all rgba 0.0 1.0 0.0 0.0
[...]
Apart from these two issues,

Reviewed-by: Fabian Bieler <fabianbieler at fastmail.fm>


More information about the Piglit mailing list