[Piglit] [PATCH 3/3] arb_tessellation_shader/quads: new more complex test
Chris Forbes
chrisf at ijw.co.nz
Sun Oct 19 19:50:01 PDT 2014
Seems reasonable.
Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
On Thu, Oct 16, 2014 at 9:41 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> .../execution/quads.shader_test | 125 +++++++++++++++++++++
> 1 file changed, 125 insertions(+)
> create mode 100644 tests/spec/arb_tessellation_shader/execution/quads.shader_test
>
> diff --git a/tests/spec/arb_tessellation_shader/execution/quads.shader_test b/tests/spec/arb_tessellation_shader/execution/quads.shader_test
> new file mode 100644
> index 0000000..d2ba783
> --- /dev/null
> +++ b/tests/spec/arb_tessellation_shader/execution/quads.shader_test
> @@ -0,0 +1,125 @@
> +# What it covers:
> +# * tessellation of quads
> +# * different number of input (pre-TCS) and output (post-TCS) control points
> +# * all inputs are read in each shader
> +# * gl_PatchVerticesIn in TCS and TES
> +#
> +# How it works:
> +# * There is a patch with 4 control points on the input (quad).
> +# * The TCS subdivides the patch into 9 control points (4 tiles in a 2x2 pattern).
> +# * A color is assigned to each tile, which is held in the upper-left corner
> +# of the tile.
> +# * The 2x2 pattern is still a single quad from the tessellator point of view.
> +# * The tessellator should create 21*21 quads (21*21*2 triangles).
> +# * The quad should be tessellated such that you can clearly see 4 tiles that
> +# have different colors. The triangles in the middle should smoothly blend
> +# colors from both tiles (caused by interpolation of varyings).
> +#
> +
> +[require]
> +GLSL >= 1.50
> +GL_ARB_tessellation_shader
> +
> +[vertex shader]
> +#version 150
> +in vec4 vertex;
> +
> +void main()
> +{
> + gl_Position = vec4(vertex.xy, 0, 1);
> +}
> +
> +[tessellation control shader]
> +#version 150
> +#extension GL_ARB_tessellation_shader : require
> +
> +layout(vertices = 9) out;
> +
> +out vec4 color[];
> +out vec4 pos[];
> +
> +void main()
> +{
> + float t = 21;
> + gl_TessLevelInner[0] = t;
> + gl_TessLevelInner[1] = t;
> +
> + gl_TessLevelOuter[0] = t;
> + gl_TessLevelOuter[1] = t;
> + gl_TessLevelOuter[2] = t;
> + gl_TessLevelOuter[3] = t;
> +
> + float x = float(gl_InvocationID % 3) / 2;
> + float y = float(gl_InvocationID / 3) / 2;
> +
> + vec4 x1 = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, x);
> + vec4 x2 = mix(gl_in[2].gl_Position, gl_in[3].gl_Position, x);
> +
> + pos[gl_InvocationID] = mix(x1, x2, y);
> + color[gl_InvocationID] = gl_PatchVerticesIn == 4 ? vec4(x, y, 0, 1) : vec4(0);
> +}
> +
> +[tessellation evaluation shader]
> +#version 150
> +#extension GL_ARB_tessellation_shader : require
> +
> +layout(quads, equal_spacing) in;
> +
> +in vec4 pos[];
> +in vec4 color[];
> +out vec4 fs_color;
> +
> +void main()
> +{
> + float x = gl_TessCoord.x;
> + float y = gl_TessCoord.y;
> + vec4 vx[3], cx[3], v, c;
> +
> + for (int i = 0; i < 3; i++) {
> + if (x <= 0.5) {
> + vx[i] = mix(pos[i*3], pos[i*3+1], x*2);
> + cx[i] = color[i*3];
> + } else {
> + vx[i] = mix(pos[i*3+1], pos[i*3+2], (x-0.5)*2);
> + cx[i] = color[i*3+1];
> + }
> + }
> +
> + if (y <= 0.5) {
> + v = mix(vx[0], vx[1], y*2);
> + c = cx[0];
> + } else {
> + v = mix(vx[1], vx[2], (y-0.5)*2);
> + c = cx[1];
> + }
> +
> + gl_Position = v;
> + fs_color = gl_PatchVerticesIn == 9 ? c : vec4(0);
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 fs_color;
> +
> +void main()
> +{
> + gl_FragColor = fs_color;
> +}
> +
> +[vertex data]
> +vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> +-1.0 1.0
> + 1.0 1.0
> +
> +[test]
> +clear color 0.1 0.1 0.1 0.1
> +clear
> +patch parameter vertices 4
> +draw arrays GL_PATCHES 0 4
> +relative probe rect rgb (0.0 , 0.0 , 0.476, 0.476) (0.0, 0.0, 0.0)
> +relative probe rect rgb (0.524, 0.0 , 0.476, 0.476) (0.5, 0.0, 0.0)
> +relative probe rect rgb (0.0 , 0.524, 0.476, 0.476) (0.0, 0.5, 0.0)
> +relative probe rect rgb (0.524, 0.524, 0.476, 0.476) (0.5, 0.5, 0.0)
> --
> 1.9.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list