[Piglit] [PATCH 1/3] ARB_tessellation_shader: Test with geom shader

Ilia Mirkin imirkin at alum.mit.edu
Wed Nov 25 08:51:06 PST 2015


On Wed, Nov 25, 2015 at 11:12 AM, Glenn Kennard <glenn.kennard at gmail.com> wrote:
> Use a geometry shader/fragment shader combo to
> visualize the tessellation.
> ---
>  .../execution/tess_with_geometry.shader_test       | 110 +++++++++++++++++++++
>  1 file changed, 110 insertions(+)
>  create mode 100644 tests/spec/arb_tessellation_shader/execution/tess_with_geometry.shader_test
>
> diff --git a/tests/spec/arb_tessellation_shader/execution/tess_with_geometry.shader_test b/tests/spec/arb_tessellation_shader/execution/tess_with_geometry.shader_test
> new file mode 100644
> index 0000000..ae2eecc
> --- /dev/null
> +++ b/tests/spec/arb_tessellation_shader/execution/tess_with_geometry.shader_test
> @@ -0,0 +1,110 @@
> +[require]
> +GLSL >= 1.50
> +GL_ARB_tessellation_shader
> +
> +[vertex shader]

[vertex shader passthrough]

> +in vec4 vertex;
> +
> +void main()
> +{
> +       gl_Position = vertex;
> +}
> +
> +[tessellation control shader]
> +#extension GL_ARB_tessellation_shader : require
> +layout(vertices = 3) out;
> +
> +void main() {
> +       gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
> +       gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
> +       gl_TessLevelInner = float[2](4.0, 4.0);
> +}

Don't need this...

> +
> +[tessellation evaluation shader]
> +#extension GL_ARB_tessellation_shader : require
> +layout(triangles) in;
> +out vec4 color;
> +
> +void main() {
> +       gl_Position =
> +               gl_in[0].gl_Position * gl_TessCoord[0] +
> +               gl_in[1].gl_Position * gl_TessCoord[1] +
> +               gl_in[2].gl_Position * gl_TessCoord[2];
> +       color = tan(vec4(gl_TessCoord[0], gl_TessCoord[1], gl_TessCoord[2], 1.0));
> +}
> +
> +[geometry shader]
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +in vec4 color[3];
> +
> +out vec4 color2;
> +out vec3 bary;
> +
> +void main() {
> +       color2 = color[0];
> +       bary = vec3(1.0, 0.0, 0.0);
> +       gl_Position = gl_in[0].gl_Position;
> +       EmitVertex();
> +
> +       color2 = color[1];
> +       bary = vec3(0.0, 1.0, 0.0);
> +       gl_Position = gl_in[1].gl_Position;
> +       EmitVertex();
> +
> +       color2 = color[2];
> +       bary = vec3(0.0, 0.0, 1.0);
> +       gl_Position = gl_in[2].gl_Position;
> +       EmitVertex();
> +}
> +
> +[fragment shader]
> +in vec4 color2;
> +in vec3 bary;
> +
> +void main()
> +{
> +       vec3 a = smoothstep(vec3(0.0), fwidth(bary), bary);
> +       float edge = min(min(a.x, a.y), a.z);

Hmmm... my outside top/left/bottom/right edges aren't white but rather
blended with the underlying color (50% if I had to guess). Any
thoughts on why this might be? Something wrong with nouveau? The
shader?

> +       gl_FragColor = mix(vec4(1.0), color2, edge);
> +}
> +
> +[vertex data]
> +vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> +-1.0  1.0
> +-1.0  1.0
> + 1.0 -1.0
> + 1.0  1.0
> +
> +
> +[test]
> +clear color 0.5 0.5 0.5 1.0
> +clear
> +patch parameter vertices 3
> +
> +# these two should yield the same results
> +#draw arrays GL_PATCHES 0 3
> +#draw arrays GL_PATCHES 3 3

Remove these comments?

> +draw arrays GL_PATCHES 0 6
> +
> +tolerance 0.15 0.15 0.15 0.0
> +
> +# first patch check colors close to the corners are correct
> +relative probe rgba ( 0.064 , 0.016 ) ( 1.0 , 0.0 , 0.0 , 1.0 )
> +relative probe rgba ( 0.872 , 0.016 ) ( 0.0 , 1.0 , 0.0 , 1.0 )
> +relative probe rgba ( 0.016 , 0.872 ) ( 0.0 , 0.0 , 1.0 , 1.0 )
> +
> +# second patch
> +relative probe rgba ( 0.064 , 0.984 ) ( 1.0 , 0.0 , 0.0 , 1.0 )
> +relative probe rgba ( 0.98 , 0.12 ) ( 0.0 , 1.0 , 0.0 , 1.0 )
> +relative probe rgba ( 0.888 , 0.872 ) ( 0.0 , 0.0 , 1.0 , 1.0 )
> +
> +# check that color close to center of first patch is correct
> +# since the vertex color computation is nonlinear we can tell if the patches
> +# have been tessellated or not
> +relative probe rgba ( 0.364, 0.336 ) ( 0.306, 0.388, 0.353, 1.0 )
> +
> +# second patch
> +relative probe rgba ( 0.624, 0.66 ) ( 0.306, 0.388, 0.353, 1.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