[Piglit] [PATCH 09/10] gen_builtin_uniform_tests.py: Add tessellation control shader tests.
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jul 27 17:40:09 PDT 2015
On Mon, Jul 27, 2015 at 8:02 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Fabian Bieler <fabianbieler at fastmail.fm>
>
> v2: fixed by Marek
>
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
> ---
> generated_tests/gen_builtin_uniform_tests.py | 137 ++++++++++++++++++++++++++-
> tests/shaders/shader_runner.c | 9 ++
> 2 files changed, 142 insertions(+), 4 deletions(-)
>
> diff --git a/generated_tests/gen_builtin_uniform_tests.py b/generated_tests/gen_builtin_uniform_tests.py
> index c88add5..009a05d 100644
> --- a/generated_tests/gen_builtin_uniform_tests.py
> +++ b/generated_tests/gen_builtin_uniform_tests.py
> @@ -397,6 +397,12 @@ class ShaderTest(object):
> self.rect_height,
> probe_vector[0], probe_vector[1], probe_vector[2], probe_vector[3])
>
> + def extensions(self):
> + ext = []
> + if self._signature.extension:
> + ext.append(self._signature.extension)
> + return ext
> +
> def make_additional_requirements(self):
> """Return a string that should be included in the test's
> [require] section.
> @@ -418,6 +424,22 @@ class ShaderTest(object):
> """
> return None
>
> + def make_tess_ctrl_shader(self):
> + """Return the tessellation control shader for this test
> + (or None if this test doesn't require a geometry shader).
> + No need to reimplement this function in classes that don't
> + use geometry shaders.
> + """
> + return None
> +
> + def make_tess_eval_shader(self):
> + """Return the tessellation evaluation shader for this test
> + (or None if this test doesn't require a geometry shader).
> + No need to reimplement this function in classes that don't
> + use geometry shaders.
> + """
> + return None
> +
> def make_geometry_shader(self):
> """Return the geometry shader for this test (or None if this
> test doesn't require a geometry shader). No need to
> @@ -471,8 +493,8 @@ class ShaderTest(object):
> shader, after the built-in function is called.
> """
> shader = ''
> - if self._signature.extension:
> - shader += '#extension GL_{0} : require\n'.format(self._signature.extension)
> + for ext in self.extensions():
> + shader += '#extension GL_{0} : require\n'.format(ext)
> shader += additional_declarations
> for i in range(len(self._signature.argtypes)):
> shader += 'uniform {0} arg{1};\n'.format(
> @@ -521,8 +543,8 @@ class ShaderTest(object):
> def filename(self):
> argtype_names = '-'.join(
> str(argtype) for argtype in self._signature.argtypes)
> - if self._signature.extension:
> - subdir = self._signature.extension.lower()
> + if self.extensions():
> + subdir = self.extensions()[0].lower()
> else:
> subdir = 'glsl-{0:1.2f}'.format(float(self.glsl_version()) / 100)
> return os.path.join(
> @@ -543,6 +565,16 @@ class ShaderTest(object):
> shader_test += '[vertex shader]\n'
> shader_test += vs
> shader_test += '\n'
> + tcs = self.make_tess_ctrl_shader()
> + if tcs:
> + shader_test += '[tessellation control shader]\n'
> + shader_test += tcs
> + shader_test += '\n'
> + tes = self.make_tess_eval_shader()
> + if tes:
> + shader_test += '[tessellation evaluation shader]\n'
> + shader_test += tes
> + shader_test += '\n'
> gs = self.make_geometry_shader()
> if gs:
> shader_test += '[geometry shader]\n'
> @@ -605,6 +637,102 @@ void main()
> return shader
>
>
> +class TessellationShaderTest(ShaderTest):
> + """Abstract class for tests that exercise the built-in in
> + tessellation shaders.
> + """
> +
> + def glsl_version(self):
> + return max(150, ShaderTest.glsl_version(self))
> +
> + def make_additional_requirements(self):
> + return 'GL_ARB_tessellation_shader'
> +
> + def extensions(self):
> + ext = []
> + if self._signature.extension:
> + ext.append(self._signature.extension)
> + ext.append("ARB_tessellation_shader")
> + return ext
> +
> + def draw_command(self, test_num):
> + x = (test_num % self.tests_per_row) * self.rect_width
> + y = (test_num // self.tests_per_row) * self.rect_height
> + assert(y < self.test_rows)
> + return 'draw rect ortho patch {0} {1} {2} {3}\n'.format(x, y,
> + self.rect_width,
> + self.rect_height)
> +
> + def make_vertex_shader(self):
> + shader = \
> +"""in vec4 piglit_vertex;
> +out vec4 vertex_to_tcs;
> +
> +void main()
> +{
> + vertex_to_tcs = piglit_vertex;
> +}
> +"""
> + return shader
> +
> + def make_fragment_shader(self):
> + shader = \
> +"""in vec4 color_to_fs;
> +
> +void main()
> +{
> + gl_FragColor = color_to_fs;
> +}
> +"""
> + return shader
> +
> +
> +class TessCtrlShaderTest(TessellationShaderTest):
> + """Derived class for tests that exercise the built-in in a
> + tessellation control shader.
> + """
> +
> + def test_prefix(self):
> + return 'tcs'
> +
> + def make_tess_ctrl_shader(self):
> + additional_declarations = \
> +"""layout(vertices = 4) out;
> +in vec4 vertex_to_tcs[];
> +out vec4 vertex_to_tes[];
> +patch out vec4 color_to_tes;
> +"""
> + body = \
> +""" vertex_to_tes[gl_InvocationID] = vertex_to_tcs[gl_InvocationID];
> + color_to_tes = tmp_color;
> + gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
> + gl_TessLevelInner = float[2](1.0, 1.0);
> +"""
> + shader = self.make_test_shader(
> + additional_declarations,
> + ' vec4 tmp_color;\n',
> + 'tmp_color',
> + body)
> + return shader
> +
> + def make_tess_eval_shader(self):
> + shader = \
> +"""#extension GL_ARB_tessellation_shader : require
> +layout(quads) in;
> +
> +in vec4 vertex_to_tes[];
> +patch in vec4 color_to_tes;
> +out vec4 color_to_fs;
> +void main() {
> + gl_Position = mix(mix(vertex_to_tes[0], vertex_to_tes[1], gl_TessCoord.x),
> + mix(vertex_to_tes[2], vertex_to_tes[3], gl_TessCoord.x),
> + gl_TessCoord.y);
FWIW I liked your quads thing a lot better, i.e. vec4(2 *
gl_TessCoord.xy - 1, 0, 1);
Removes the need for the tcs complexity too.
Either way,
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
> + color_to_fs = color_to_tes;
> +}
> +"""
> + return shader
> +
> +
> class GeometryShaderTest(ShaderTest):
> """Derived class for tests that exercise the built-in in a
> geometry shader.
> @@ -731,6 +859,7 @@ def all_tests():
> if use_if and signature.rettype != glsl_bool:
> continue
> yield VertexShaderTest(signature, test_vectors, use_if)
> + yield TessCtrlShaderTest(signature, test_vectors, use_if)
> yield GeometryShaderTest(signature, test_vectors, use_if)
> yield FragmentShaderTest(signature, test_vectors, use_if)
> yield ComputeShaderTest(signature, test_vectors, use_if)
> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
> index 24c86ac..be6e6ae 100644
> --- a/tests/shaders/shader_runner.c
> +++ b/tests/shaders/shader_runner.c
> @@ -2506,6 +2506,15 @@ piglit_display(void)
> get_floats(line + 13, c, 8);
> piglit_draw_rect_tex(c[0], c[1], c[2], c[3],
> c[4], c[5], c[6], c[7]);
> + } else if (string_match("draw rect ortho patch", line)) {
> + program_must_be_in_use();
> + program_subroutine_uniforms();
> + get_floats(line + 21, c, 4);
> +
> + piglit_draw_rect_custom(-1.0 + 2.0 * (c[0] / piglit_width),
> + -1.0 + 2.0 * (c[1] / piglit_height),
> + 2.0 * (c[2] / piglit_width),
> + 2.0 * (c[3] / piglit_height), true);
> } else if (string_match("draw rect ortho", line)) {
> program_must_be_in_use();
> program_subroutine_uniforms();
> --
> 2.1.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list