[Piglit] [PATCH 1/4] arb_vertex_attrib_64bit: Adds double vertex input tests generator (v2)

Alejandro Piñeiro apinheiro at igalia.com
Fri May 20 08:00:38 UTC 2016


Im not really used to the piglit/mako code, so in the end you would need
someone else reviews, or just go ahead with Dave ack. In any case I have
some comments. See below.

On 20/05/16 01:25, Andres Gomez wrote:
> Generator which create test combinations of different vertex inputs
> types, including a double derived type. Note that this generator
> creates a big amount of test: ~6000.
>
> v2:
> - Include tests with interleaved u/int derived types.
> - Values are never repeated in a shader variable to avoid identical
>   array members or columns in the same matrix (Alejandro).

Really nitpicky nitpick: when v2 patches are sent to the list, "v2" is
included on the prefix on blocks. So "[PATCH 1/4 v2]", not a "(v2)"
suffix at the end. Usually it is easier to just let use git-send do that
work for you (git send-email -v2).

>
> Also, removed one redundant test.
>
> Acked-by: Dave Airlie <airlied at redhat.com>
> Signed-off-by: Andres Gomez <agomez at igalia.com>
> ---
>  generated_tests/CMakeLists.txt                     |   9 +
>  generated_tests/gen_vs_in_fp64.py                  | 398 +++++++++++++++++++++
>  generated_tests/templates/gen_vs_in_fp64/base.mako |  27 ++
>  .../columns_execution.vert.shader_test.mako        |  41 +++
>  .../gen_vs_in_fp64/columns_shader.vert.mako        |  17 +
>  .../gen_vs_in_fp64/execution.vert.shader_test.mako |  32 ++
>  .../templates/gen_vs_in_fp64/execution_base.mako   |  85 +++++
>  .../regular_execution.vert.shader_test.mako        |  67 ++++
>  .../gen_vs_in_fp64/regular_shader.vert.mako        |  19 +
>  .../templates/gen_vs_in_fp64/shader.vert.mako      |  16 +
>  .../templates/gen_vs_in_fp64/shader_base.mako      |  12 +
>  .../execution/vs-dvec3-input.shader_test           |  37 --
>  12 files changed, 723 insertions(+), 37 deletions(-)
>  create mode 100644 generated_tests/gen_vs_in_fp64.py
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/base.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/columns_execution.vert.shader_test.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/columns_shader.vert.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/execution_base.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/regular_execution.vert.shader_test.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/shader.vert.mako
>  create mode 100644 generated_tests/templates/gen_vs_in_fp64/shader_base.mako
>  delete mode 100644 tests/spec/arb_vertex_attrib_64bit/execution/vs-dvec3-input.shader_test
>
> diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
> index 1e69486..0b9048f 100644
> --- a/generated_tests/CMakeLists.txt
> +++ b/generated_tests/CMakeLists.txt
> @@ -188,6 +188,14 @@ piglit_make_generated_tests(
>  	templates/gen_variable_index_write_tests/vs.shader_test.mako
>  	templates/gen_variable_index_write_tests/fs.shader_test.mako
>  	templates/gen_variable_index_write_tests/helpers.mako)
> +piglit_make_generated_tests(
> +	vs_in_fp64.list
> +	gen_vs_in_fp64.py
> +	templates/gen_vs_in_fp64/base.mako
> +	templates/gen_vs_in_fp64/execution.vert.shader_test.mako
> +	templates/gen_vs_in_fp64/execution_base.mako
> +	templates/gen_vs_in_fp64/shader.vert.mako
> +	templates/gen_vs_in_fp64/shader_base.mako)
>  
>  # OpenCL Test generators
>  piglit_make_generated_tests(
> @@ -238,6 +246,7 @@ add_custom_target(gen-gl-tests
>  			gen_extensions_defined.list
>  			vp-tex.list
>  			variable_index_write_tests.list
> +			vs_in_fp64.list
>  )
>  
>  # Create a custom target for generating OpenCL tests
> diff --git a/generated_tests/gen_vs_in_fp64.py b/generated_tests/gen_vs_in_fp64.py
> new file mode 100644
> index 0000000..04bb8de
> --- /dev/null
> +++ b/generated_tests/gen_vs_in_fp64.py
> @@ -0,0 +1,398 @@
> +# coding=utf-8
> +#
> +# Copyright © 2016 Intel Corporation
> +#
> +# Permission is hereby granted, free of charge, to any person obtaining a
> +# copy of this software and associated documentation files (the "Software"),
> +# to deal in the Software without restriction, including without limitation
> +# the rights to use, copy, modify, merge, publish, distribute, sublicense,
> +# and/or sell copies of the Software, and to permit persons to whom the
> +# Software is furnished to do so, subject to the following conditions:
> +#
> +# The above copyright notice and this permission notice (including the next
> +# paragraph) shall be included in all copies or substantial portions of the
> +# Software.
> +#
> +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> +# DEALINGS IN THE SOFTWARE.
> +
> +"""Generate fp64 vertex shader input tests."""
> +
> +from __future__ import print_function, division, absolute_import
> +import abc
> +import argparse
> +import itertools
> +import os
> +
> +from templates import template_dir
> +from modules import utils
> +
> +TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
> +
> +# Hard limit so we don't generate useless tests that cannot be run in any existing HW.
> +MAX_VERTEX_ATTRIBS = 32

Any reason to use a hardcode value instead of just asking it before
generating it? I think that this value would be too big for older hw, so
you would get those useless tests there. Unless the idea is having tests
failing on older hw due, ans fully passing only on newer hw.

> +
> +# pylint: disable=bad-whitespace,line-too-long
> +DOUBLE_INFS            = ['0xfff0000000000000', # -inf
> +                          '0x7ff0000000000000'] # +inf
> +
> +DOUBLE_NEG_ZERO        = ['0x8000000000000000'] # Negative underflow (-0.0)
> +
> +DOUBLE_POS_ZERO        = ['0x0000000000000000'] # Positive underflow (+0.0)
> +
> +# Double values causing an underflow to zero in any other type
> +DOUBLE_DENORMAL_VALUES = ['0x800fffffffffffff', # Negative maximum denormalized -- Denormalized may be flushed to 0
> +                          '0x8000000000000001', # Negative minimum denormalized -- Denormalized may be flushed to 0
> +                          '0x0000000000000001', # Positive minimum denormalized -- Denormalized may be flushed to 0
> +                          '0x000fffffffffffff'] # Positive maximum denormalized -- Denormalized may be flushed to 0
> +
> +DOUBLE_NORMAL_VALUES   = ['0xffefffffffffffff', # Negative maximum normalized
> +                          '0xcb1e35ed24eb6496', # -7.23401345e+53
> +                          '0xc8b1381a93a87849', # -1.5e+42
> +                          '0xc7efffffefffffff', # Negative maximum float normalized
> +                          '0xc170000000000000', # -16777216.0
> +                          '0xc014000000000000', # -5.0
> +                          '0xbfff25ce60000000', # -1.9467300176620483
> +                          '0x8010000000000000', # Negative minimum normalized
> +                          '0x0010000000000000', # Positive minimum normalized
> +                          '0x3fff25ce60000000', # +1.9467300176620483
> +                          '0x4014000000000000', # +5.0
> +                          '0x4170000000000000', # +16777216.0
> +                          '0x47efffffefffffff', # Positive maximum float normalized
> +                          '0x48b1381a93a87849', # +1.5e+42
> +                          '0x4b1e35ed24eb6496', # +7.23401345e+53
> +                          '0x7fefffffffffffff'] # Positive maximum normalized
> +
> +DSCALAR_TYPES          = ['double']
> +
> +DVEC_TYPES             = ['dvec2', 'dvec3', 'dvec4']
> +
> +DMAT_TYPES             = ['dmat2', 'dmat2x3', 'dmat2x4',
> +                          'dmat3x2', 'dmat3', 'dmat3x4',
> +                          'dmat4x2', 'dmat4x3', 'dmat4']
> +
> +FSCALAR_TYPES          = ['float']
> +
> +FVEC_TYPES             = ['vec2', 'vec3', 'vec4']
> +
> +FMAT_TYPES             = ['mat2', 'mat2x3', 'mat2x4',
> +                          'mat3x2', 'mat3', 'mat3x4',
> +                          'mat4x2', 'mat4x3', 'mat4']
> +
> +ISCALAR_TYPES          = ['int']
> +
> +IVEC_TYPES             = ['ivec2', 'ivec3', 'ivec4']
> +
> +USCALAR_TYPES          = ['uint']
> +
> +UVEC_TYPES             = ['uvec2', 'uvec3', 'uvec4']
> +
> +HEX_VALUES_32BIT       = ['0xc21620c5', # -3.7532        float, -1038737211 int, 3256230085 uint
> +                          '0x75bc289b', #  4.7703e32     float,  1975265435 int, 1975265435 uint
> +                          '0x54c1c081', #  6.6572e12     float,  1421983873 int, 1421983873 uint
> +                          '0x878218f8', # -1.9575e-34    float, -1038737211 int, 2273450232 uint
> +                          '0x7e0857ed', #  4.5307886e+37 float,  2114476013 int, 2114476013 uint
> +                          '0x2bb561bf', #  1.2887954e-12 float,   733307327 int,  733307327 uint
> +                          '0xff7fffff', # -3.4028235e+38 float,    -8388609 int, 4286578687 uint
> +                          '0xcb800000', # -16777216.0    float,  -880803840 int, 3414163456 uint
> +                          '0xc0a00000', # -5.0           float, -1063256064 int, 3231711232 uint
> +                          '0xbff92e73', # -1.9467300     float, -1074188685 int, 3220778611 uint
> +                          '0x80800000', # -1.1754944e-38 float, -2139095040 int, 2155872256 uint
> +                          '0x00000000', #  0.0           float,           0 int,          0 uint
> +                          '0x00800000', #  1.1754944e-38 float,     8388608 int,    8388608 uint
> +                          '0x3ff92e73', #  1.9467300     float,  1073294963 int, 1073294963 uint
> +                          '0x40a00000', #  5.0           float,  1084227584 int, 1084227584 uint
> +                          '0x4b800000', #  16777216.0    float,  1266679808 int, 1266679808 uint
> +                          '0x7f7fffff'] #  3.4028235e+38 float,  2139095039 int, 2139095039 uint
> +
> +
> +# pylint: enable=bad-whitespace,line-too-long
> +
> +
> +class TestTuple(object):
> +    """A float64 derived and other type derived tuple to generate the
> +       needed conversion tests.
> +    """
> +
> +    @staticmethod
> +    def rows(in_type):
> +        """Calculates the amounts of rows in a basic GLSL type."""
> +        if 'vec' in in_type or 'mat' in in_type:
> +            return int(in_type[-1:])
> +        else:
> +            return 1
> +
> +    @staticmethod
> +    def cols(in_type):
> +        """Calculates the amounts of columns in a basic GLSL type."""
> +        if 'mat' in in_type:
> +            if 'x' in in_type:
> +                return int(in_type[-3:][:1])
> +            else:
> +                return int(in_type[-1:])
> +        else:
> +            return 1
> +
> +    @staticmethod
> +    def get_dir_name(ver):
> +        """Returns the directory name to save tests given a GLSL version."""
> +
> +        assert isinstance(ver, str)
> +        if ver.startswith('GL_'):
> +            feature_dir = ver[3:].lower()
> +        else:
> +            feature_dir = 'glsl-{}.{}'.format(ver[0], ver[1:])
> +
> +        return os.path.join('spec', feature_dir, 'execution',
> +                            'vs_in')
> +
> +    def __init__(self, ver, names_only):
> +        assert isinstance(ver, str)
> +        assert isinstance(names_only, bool)
> +
> +        self._ver = ver
> +        self._names_only = names_only
> +        self._filenames = []
> +
> +    @abc.abstractmethod
> +    def _generate(self):
> +        """Generates the test files for conversions to float64."""
> +
> +    @property
> +    def filenames(self):
> +        """Returns the test file names this tuple will generate."""
> +        if self._filenames == []:
> +            tmp = self._names_only
> +            self._names_only = True
> +            self.generate_test_files()
> +            self._names_only = tmp
> +        return self._filenames
> +
> +    def generate_test_files(self):
> +        """Generate the GLSL parser tests."""
> +        self._filenames = []
> +
> +        self._generate()
> +
> +
> +class RegularTestTuple(TestTuple):
> +    """Derived class for conversion tests using regular values within the
> +       edges of the used types.
> +    """
> +
> +    @staticmethod
> +    def create_in_types_array(*types_arrays):
> +        """Creates vertex input combinations."""
> +
> +        in_types_array = []
> +        for product_item in itertools.product(*types_arrays):
> +            in_types_array.append(product_item)
> +
> +        return in_types_array
> +
> +    @staticmethod
> +    def create_tests(glsl_vers, in_types_array, position_orders, arrays_array, names_only):
> +        """Creates combinations for flat qualifier tests."""
> +
> +        assert isinstance(glsl_vers, list)
> +        assert isinstance(in_types_array, list)
> +        assert isinstance(position_orders, list)
> +        assert isinstance(arrays_array, list)
> +        assert isinstance(names_only, bool)
> +
> +        if not names_only:
> +            for ver in glsl_vers:
> +                utils.safe_makedirs(TestTuple.get_dir_name(ver))
> +
> +        for in_types, position_order, arrays, ver in itertools.product(in_types_array,
> +                                                                       position_orders,
> +                                                                       arrays_array,
> +                                                                       glsl_vers):
> +            num_vs_in = 1 # We use an additional vec3 piglit_vertex input
> +            for idx, in_type in enumerate(in_types):
> +                if ((in_type.startswith('dvec') or in_type.startswith('dmat'))
> +                    and (in_type.endswith('3') or in_type.endswith('4'))):
> +                    multiplier = 2
> +                else:
> +                    multiplier = 1
> +                num_vs_in += TestTuple.cols(in_type) * arrays[idx] * multiplier
> +                # dvec* and dmat* didn't appear in GLSL until 4.20
> +                if (in_type.startswith('dvec') or in_type.startswith('dmat')) and ver == '410':
> +                    ver = '420'

I don't get this. So if we are using dvecs or dmats on 410, we just
"upgrade" the version to be 420? Why not just assume that 410 is wrong
(see below for further comments on this)?

> +            # Skip the test if it needs too many inputs
> +            if num_vs_in > MAX_VERTEX_ATTRIBS:
> +                continue
> +
> +            yield ver, in_types, position_order, arrays, num_vs_in, names_only
> +
> +    @staticmethod
> +    def all_tests(names_only):
> +        """Creates all the combinations for flat qualifier tests."""
> +
> +        assert isinstance(names_only, bool)
> +
> +        # We need additional directories for GLSL 420
> +        if not names_only:
> +            utils.safe_makedirs(TestTuple.get_dir_name('420'))
> +        for test_args in (list(RegularTestTuple.create_tests(
> +                ['GL_ARB_vertex_attrib_64bit', '410'],

What is the reason to call create_tests with 410. Shouldn't it be 420?
As far as I understand this call, it is creating tests if the extension
is supported for any GL version, or on the gl version that supports it
on core. But this functionality is not part of the core until 420. Why
not calling with 420 instead of 410? And after all, as Im saying on my
previous comment, you are tweaking the version anyway.

> +                RegularTestTuple.create_in_types_array(
> +                    DSCALAR_TYPES + DVEC_TYPES + DMAT_TYPES,
> +                    FSCALAR_TYPES + FVEC_TYPES + FMAT_TYPES
> +                    + ISCALAR_TYPES + IVEC_TYPES
> +                    + USCALAR_TYPES + UVEC_TYPES),
> +                [1, 2, 3],
> +                [[1, 1], [1, 3], [5, 1], [5, 3]],
> +                names_only))):
> +            yield RegularTestTuple(*test_args)
> +        for test_args in (list(RegularTestTuple.create_tests(
> +                ['GL_ARB_vertex_attrib_64bit', '410'],
> +                RegularTestTuple.create_in_types_array(
> +                    FSCALAR_TYPES + FVEC_TYPES + FMAT_TYPES
> +                    + ISCALAR_TYPES + IVEC_TYPES
> +                    + USCALAR_TYPES + UVEC_TYPES,
> +                    DSCALAR_TYPES + DVEC_TYPES + DMAT_TYPES),
> +                [1, 2, 3],
> +                [[1, 1], [1, 2], [3, 1], [3, 2]],
> +                names_only))):
> +            yield RegularTestTuple(*test_args)
> +        for test_args in (list(RegularTestTuple.create_tests(
> +                ['GL_ARB_vertex_attrib_64bit', '410'],
> +                RegularTestTuple.create_in_types_array(
> +                    DSCALAR_TYPES + DVEC_TYPES + DMAT_TYPES,
> +                    DSCALAR_TYPES + DVEC_TYPES + DMAT_TYPES),
> +                [1, 2, 3],
> +                [[1, 1], [1, 2], [3, 1], [3, 2]],
> +                names_only))):
> +            yield RegularTestTuple(*test_args)
> +        for test_args in (list(RegularTestTuple.create_tests(
> +                ['GL_ARB_vertex_attrib_64bit', '410'],
> +                RegularTestTuple.create_in_types_array(
> +                    DSCALAR_TYPES + DVEC_TYPES + DMAT_TYPES),
> +                [1, 2],
> +                [[1], [5]],
> +                names_only))):
> +            yield RegularTestTuple(*test_args)
> +
> +    def __init__(self, ver, in_types, position_order, arrays, num_vs_in, names_only):
> +        assert ver in ('GL_ARB_vertex_attrib_64bit', '410', '420')

Related with my previous comment, why not just
('GL_ARB_vertex_attrib_64bit', '420')? What having 410 there provides?
> +        assert isinstance(in_types, tuple)
> +        assert isinstance(position_order, int)
> +        assert (position_order > 0) and (position_order - 1 <= len(in_types))
> +        assert isinstance(arrays, list)
> +        assert isinstance(num_vs_in, int) and (num_vs_in <= MAX_VERTEX_ATTRIBS)
> +        super(RegularTestTuple, self).__init__(ver, names_only)
> +
> +        self._in_types = in_types
> +        self._position_order = position_order
> +        self._arrays = arrays
> +        self._num_vs_in = num_vs_in
> +
> +    def _generate(self):
> +        """Generate GLSL parser tests."""
> +
> +        filename = os.path.join(TestTuple.get_dir_name(self._ver), 'vs-input')
> +        for idx, in_type in enumerate(self._in_types):
> +            if idx == self._position_order - 1:
> +                filename += '-position'
> +            filename += '-{}{}'.format(
> +                in_type, '-array{}'.format(
> +                    self._arrays[idx]) if self._arrays[idx] - 1 else '')
> +        if self._position_order > len(self._in_types):
> +            filename += '-position'
> +        filename += '.shader_test'
> +
> +        self._filenames.append(filename)
> +
> +        if not self._names_only:
> +            with open(filename, 'w') as test_file:
> +                test_file.write(TEMPLATES.get_template(
> +                    'regular_execution.vert.shader_test.mako').render_unicode(
> +                        ver=self._ver,
> +                        in_types=self._in_types,
> +                        position_order=self._position_order,
> +                        arrays=self._arrays,
> +                        num_vs_in=self._num_vs_in,
> +                        dvalues=DOUBLE_NORMAL_VALUES + DOUBLE_POS_ZERO,
> +                        hvalues=HEX_VALUES_32BIT))
> +
> +
> +class ColumnsTestTuple(TestTuple):
> +    """Derived class for conversion tests using regular values within the
> +       edges of the used types.
> +    """
> +
> +    @staticmethod
> +    def all_tests(names_only):
> +        """Creates all the combinations for flat qualifier tests."""
> +
> +        assert isinstance(names_only, bool)
> +        glsl_vers = ['GL_ARB_vertex_attrib_64bit', '420']
> +
> +        if not names_only:
> +            for ver in glsl_vers:
> +                utils.safe_makedirs(TestTuple.get_dir_name(ver))
> +
> +        for mat in DMAT_TYPES:
> +            for columns in itertools.product(range(2), repeat=TestTuple.cols(mat)):
> +                if (0 not in columns) or (1 not in columns):
> +                    continue
> +                for ver in glsl_vers:
> +                    yield ColumnsTestTuple(ver, mat, columns, names_only)
> +
> +    def __init__(self, ver, mat, columns, names_only):
> +        assert ver in ('GL_ARB_vertex_attrib_64bit', '420')
> +        super(ColumnsTestTuple, self).__init__(ver, names_only)
> +
> +        self._mat = mat
> +        self._columns = columns
> +
> +    def _generate(self):
> +        """Generate GLSL parser tests."""
> +
> +        filename = os.path.join(TestTuple.get_dir_name(self._ver),
> +                                'vs-input-columns-{}'.format(self._mat))
> +        for idx, column in enumerate(self._columns):
> +            if column == 1:
> +                filename += '-{}'.format(idx)
> +        filename += '.shader_test'
> +
> +        self._filenames.append(filename)
> +
> +        if not self._names_only:
> +            with open(filename, 'w') as test_file:
> +                test_file.write(TEMPLATES.get_template(
> +                    'columns_execution.vert.shader_test.mako').render_unicode(
> +                        ver=self._ver,
> +                        mat=self._mat,
> +                        columns=self._columns,
> +                        dvalues=DOUBLE_NORMAL_VALUES + DOUBLE_POS_ZERO))
> +
> +
> +def main():
> +    """Main function."""
> +
> +    parser = argparse.ArgumentParser(
> +        description="Generate non-flat interpolation qualifier tests with fp64 types")
> +    parser.add_argument(
> +        '--names-only',
> +        dest='names_only',
> +        action='store_true',
> +        default=False,
> +        help="Don't output files, just generate a list of filenames to stdout")
> +    args = parser.parse_args()
> +
> +    for test in (list(RegularTestTuple.all_tests(args.names_only)) +
> +                 list(ColumnsTestTuple.all_tests(args.names_only))):
> +        test.generate_test_files()
> +        for filename in test.filenames:
> +            print(filename)
> +
> +
> +if __name__ == '__main__':
> +    main()
> diff --git a/generated_tests/templates/gen_vs_in_fp64/base.mako b/generated_tests/templates/gen_vs_in_fp64/base.mako
> new file mode 100644
> index 0000000..fb00d8c
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/base.mako
> @@ -0,0 +1,27 @@
> +## coding=utf-8
> +<%def name="versioning()"><%
> +    if ver == 'GL_ARB_vertex_attrib_64bit':
> +        glsl_version_int = '150'
> +    else:
> +        glsl_version_int = ver
> +
> +    glsl_version = '{}.{}'.format(glsl_version_int[0], glsl_version_int[1:3])
> +
> +    return (glsl_version, glsl_version_int)
> +%></%def>\
> +<%def name="cols(in_type)"><%
> +    if 'mat' in in_type:
> +        if 'x' in in_type:
> +            return int(in_type[-3:][:1])
> +        else:
> +            return int(in_type[-1:])
> +    else:
> +        return 1
> +%></%def>\
> +<%def name="rows(in_type)"><%
> +    if 'vec' in in_type or 'mat' in in_type:
> +        return int(in_type[-1:])
> +    else:
> +        return 1
> +%></%def>\
> +${next.body()}\
> diff --git a/generated_tests/templates/gen_vs_in_fp64/columns_execution.vert.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/columns_execution.vert.shader_test.mako
> new file mode 100644
> index 0000000..d345653
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/columns_execution.vert.shader_test.mako
> @@ -0,0 +1,41 @@
> +## coding=utf-8
> +<%inherit file="execution.vert.shader_test.mako"/>\
> +<%! from six.moves import range %>\
> +<%block name="vertex_data">\
> +piglit_vertex/vec3/3\
> +% for i in range(self.cols(mat)):
> + value/${mat}/${self.rows(mat)}${'/{}'.format(i) if self.cols(mat) > 1 else ''}\
> +% endfor
> +
> +% for d in range(len(dvalues)):
> +% for vertex in ('-1.0 -1.0  0.0', ' 1.0 -1.0  0.0', ' 1.0  1.0  0.0', '-1.0  1.0  0.0'):
> +${vertex} \
> +% for i in range(self.cols(mat)):
> + \
> +% for j in range(self.rows(mat)):
> +  ${dvalues[(d + i * self.rows(mat) + j) % len(dvalues)]}\
> +% endfor
> +% endfor
> +
> +% endfor
> +% endfor
> +</%block>
> +<%block name="test_commands">\
> +% for d in range(len(dvalues)):
> +
> +uniform ${mat} expected\
> +% for i in range(self.cols(mat)):
> +% for j in range(self.rows(mat)):
> + ${dvalues[(d + i * self.rows(mat) + j) % len(dvalues)]}\
> +% endfor
> +% endfor
> +
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +draw arrays GL_TRIANGLE_FAN ${d * 4} 4
> +probe all rgba 0.0 1.0 0.0 1.0
> +% endfor
> +</%block>
> +<%block name="vertex_shader">\
> +<%include file="columns_shader.vert.mako"/>\
> +</%block>
> \ No newline at end of file
> diff --git a/generated_tests/templates/gen_vs_in_fp64/columns_shader.vert.mako b/generated_tests/templates/gen_vs_in_fp64/columns_shader.vert.mako
> new file mode 100644
> index 0000000..c150121
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/columns_shader.vert.mako
> @@ -0,0 +1,17 @@
> +## coding=utf-8
> +<%inherit file="shader.vert.mako"/>\
> +<%block name="global_variables">\
> +uniform ${mat} expected;
> +
> +in ${mat} value;
> +</%block>
> +<%block name="main">\
> +% for idx, column in enumerate(columns):
> +% if column == 1:
> +    if (value[${idx}] != expected[${idx}]) {
> +        fs_color = RED;
> +	return;
> +    }
> +% endif
> +% endfor
> +</%block>
> diff --git a/generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako
> new file mode 100644
> index 0000000..fc70997
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako
> @@ -0,0 +1,32 @@
> +## coding=utf-8
> +<%inherit file="base.mako"/>\
> +<%
> +    (glsl_version, glsl_version_int) = self.versioning()
> +%>\
> +[require]
> +GLSL >= ${glsl_version}
> +% if ver == 'GL_ARB_vertex_attrib_64bit':
> +GL_ARB_gpu_shader_fp64
> +${ver}
> +% endif
> +<%block name="require"/>\
> +
> +[vertex shader]
> +<%block name="vertex_shader"/>\
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 fs_color;
> +out vec4 color;
> +
> +void main()
> +{
> +    color = fs_color;
> +}
> +
> +[vertex data]
> +<%block name="vertex_data"/>\
> +
> +[test]\
> +<%block name="test_commands"/>\
> diff --git a/generated_tests/templates/gen_vs_in_fp64/execution_base.mako b/generated_tests/templates/gen_vs_in_fp64/execution_base.mako
> new file mode 100644
> index 0000000..b36f7a8
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/execution_base.mako
> @@ -0,0 +1,85 @@
> +## coding=utf-8
> +<%inherit file="base.mako"/>\
> +<%
> +    (glsl_version, glsl_version_int) = self.versioning()
> +
> +    def rows(in_type):
> +        if 'vec' in in_type or 'mat' in in_type:
> +            return int(in_type[-1:])
> +        else:
> +            return 1
> +
> +    def cols(in_type):
> +        if 'mat' in in_type:
> +            if 'x' in in_type:
> +                return int(in_type[-3:][:1])
> +            else:
> +                return int(in_type[-1:])
> +        else:
> +            return 1
> +%>\
> +<%! from six.moves import range %>\
> +[require]
> +GLSL >= ${glsl_version}
> +% if ver == 'GL_ARB_vertex_attrib_64bit':
> +GL_ARB_gpu_shader_fp64
> +${ver}
> +% endif
> +GL_MAX_VERTEX_ATTRIBS >= ${num_vs_in}
> +${next.body()}\
> +[vertex data]
> +% for idx, in_type in enumerate(in_types):
> +% if idx == position_order - 1:
> +piglit_vertex/vec3/3 \
> +% endif
> +% for i in range(arrays[idx]):
> +% for j in range(cols(in_type)):
> +value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${in_type}/${rows(in_type)}${'/{}'.format(j) if cols(in_type) > 1 else ''} \
> +% endfor
> +% endfor
> +% endfor
> +% if position_order > len(in_types):
> +piglit_vertex/vec3/3\
> +% endif
> +
> +% for d in range(len(dvalues)):
> +% for vertex in ('-1.0 -1.0  0.0', ' 1.0 -1.0  0.0', ' 1.0  1.0  0.0', '-1.0  1.0  0.0'):
> +% for idx, in_type in enumerate(in_types):
> +% if idx == position_order - 1:
> +${vertex}   \
> +% endif
> +% for i in range(arrays[idx]):
> +% for j in range(cols(in_type)):
> +% for k in range(rows(in_type)):
> +${dvalues[(d + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + k) % 4]}  \
> +% endfor
> + \
> +% endfor
> +% endfor
> +% endfor
> +% if position_order > len(in_types):
> +${vertex}\
> +% endif
> +
> +% endfor
> +% endfor
> +
> +[test]
> +% for d in range(len(dvalues)):
> +% for idx, in_type in enumerate(in_types):
> +% for i in range(arrays[idx]):
> +uniform ${in_type} expected${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}\
> +% for j in range(cols(in_type)):
> +% for k in range(rows(in_type)):
> + ${dvalues[(d + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + k) % 4]}\
> +% endfor
> +% endfor
> +
> +% endfor
> +% endfor
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +draw arrays GL_TRIANGLE_FAN ${d * 4} 4
> +probe all rgba 0.0 1.0 0.0 1.0
> +
> +% endfor
> diff --git a/generated_tests/templates/gen_vs_in_fp64/regular_execution.vert.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/regular_execution.vert.shader_test.mako
> new file mode 100644
> index 0000000..d3fd08c
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/regular_execution.vert.shader_test.mako
> @@ -0,0 +1,67 @@
> +## coding=utf-8
> +<%inherit file="execution.vert.shader_test.mako"/>\
> +<%! from six.moves import range %>\
> +<%block name="require">\
> +GL_MAX_VERTEX_ATTRIBS >= ${num_vs_in}
> +</%block>
> +<%block name="vertex_data">\
> +% for idx, in_type in enumerate(in_types):
> +% if idx == position_order - 1:
> +piglit_vertex/vec3/3 \
> +% endif
> +% for i in range(arrays[idx]):
> +% for j in range(self.cols(in_type)):
> +value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${in_type}/${self.rows(in_type)}${'/{}'.format(j) if self.cols(in_type) > 1 else ''} \
> +% endfor
> +% endfor
> +% endfor
> +% if position_order > len(in_types):
> +piglit_vertex/vec3/3\
> +% endif
> +
> +% for d in range(len(dvalues)):
> +% for vertex in ('-1.0 -1.0  0.0', ' 1.0 -1.0  0.0', ' 1.0  1.0  0.0', '-1.0  1.0  0.0'):
> +% for idx, in_type in enumerate(in_types):
> +% if idx == position_order - 1:
> +${vertex}   \
> +% endif
> +% for i in range(arrays[idx]):
> +% for j in range(self.cols(in_type)):
> +% for k in range(self.rows(in_type)):
> +${dvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(hvalues)]}  \
> +% endfor
> + \
> +% endfor
> +% endfor
> +% endfor
> +% if position_order > len(in_types):
> +${vertex}\
> +% endif
> +
> +% endfor
> +% endfor
> +</%block>
> +<%block name="test_commands">\
> +% for d in range(len(dvalues)):
> +
> +% for idx, in_type in enumerate(in_types):
> +% for i in range(arrays[idx]):
> +uniform ${in_type} expected${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}\
> +% for j in range(self.cols(in_type)):
> +% for k in range(self.rows(in_type)):
> + ${dvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(hvalues)]}\
> +% endfor
> +% endfor
> +
> +% endfor
> +% endfor
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +draw arrays GL_TRIANGLE_FAN ${d * 4} 4
> +probe all rgba 0.0 1.0 0.0 1.0
> +% endfor
> +</%block>
> +<%block name="vertex_shader">\
> +<%include file="regular_shader.vert.mako"/>\
> +</%block>
> +
> diff --git a/generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako b/generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako
> new file mode 100644
> index 0000000..49fe2d6
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako
> @@ -0,0 +1,19 @@
> +## coding=utf-8
> +<%inherit file="shader.vert.mako"/>\
> +<%block name="global_variables">\
> +% for idx, in_type in enumerate(in_types):
> +uniform ${in_type} expected${idx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''};
> +% endfor
> +
> +% for idx, in_type in enumerate(in_types):
> +in ${in_type} value${idx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''};
> +% endfor
> +</%block>
> +<%block name="main">\
> +% for idx, in_type in enumerate(in_types):
> +    if (value${idx} != expected${idx}) {
> +        fs_color = RED;
> +	return;
> +    }
> +% endfor
> +</%block>
> diff --git a/generated_tests/templates/gen_vs_in_fp64/shader.vert.mako b/generated_tests/templates/gen_vs_in_fp64/shader.vert.mako
> new file mode 100644
> index 0000000..3f80c71
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/shader.vert.mako
> @@ -0,0 +1,16 @@
> +## coding=utf-8
> +<%inherit file="shader_base.mako"/>\
> +<%block name="global_variables"/>\
> +
> +in vec3 piglit_vertex;
> +out vec4 fs_color;
> +
> +#define RED vec4(1.0, 0.0, 0.0, 1.0)
> +#define GREEN vec4(0.0, 1.0, 0.0, 1.0)
> +
> +void main()
> +{
> +    gl_Position = vec4(piglit_vertex, 1.0);
> +<%block name="main"/>\
> +    fs_color = GREEN;
> +}
> diff --git a/generated_tests/templates/gen_vs_in_fp64/shader_base.mako b/generated_tests/templates/gen_vs_in_fp64/shader_base.mako
> new file mode 100644
> index 0000000..a86d5eb
> --- /dev/null
> +++ b/generated_tests/templates/gen_vs_in_fp64/shader_base.mako
> @@ -0,0 +1,12 @@
> +## coding=utf-8
> +<%inherit file="base.mako"/>\
> +<%
> +    (glsl_version, glsl_version_int) = self.versioning()
> +%>\
> +#version ${glsl_version_int}
> +% if ver == 'GL_ARB_vertex_attrib_64bit':
> +#extension GL_ARB_gpu_shader_fp64 : require
> +#extension GL_ARB_vertex_attrib_64bit : require
> +% endif
> +
> +${next.body()}\
> diff --git a/tests/spec/arb_vertex_attrib_64bit/execution/vs-dvec3-input.shader_test b/tests/spec/arb_vertex_attrib_64bit/execution/vs-dvec3-input.shader_test
> deleted file mode 100644
> index d338c6c..0000000
> --- a/tests/spec/arb_vertex_attrib_64bit/execution/vs-dvec3-input.shader_test
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -# test truncating a double holds precision
> -[require]
> -GLSL >= 1.50
> -GL_ARB_gpu_shader_fp64
> -GL_ARB_vertex_attrib_64bit
> -
> -[vertex shader]
> -#version 150
> -#extension GL_ARB_gpu_shader_fp64 : require
> -#extension GL_ARB_vertex_attrib_64bit : require
> -in dvec3 vertex;
> -void main()
> -{
> -        gl_Position = vec4(vertex, 1.0);
> -}
> -
> -[fragment shader]
> -#version 150
> -#extension GL_ARB_gpu_shader_fp64 : require
> -
> -void main()
> -{
> -  gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
> -}
> -
> -[vertex data]
> -vertex/double/3
> --1.0 -1.0 0.0
> - 1.0 -1.0 0.0
> - 1.0  1.0 0.0
> --1.0  1.0 0.0
> -
> -[test]
> -clear color 0.0 0.0 1.0 0.0
> -clear
> -draw arrays GL_TRIANGLE_FAN 0 4
> -probe rgba 0 0 0.0 1.0 0.0 1.0




More information about the Piglit mailing list