[Piglit] [PATCH 2/2] generated_tests: new compiler tests for NV_image_formats

Ilia Mirkin imirkin at alum.mit.edu
Wed Nov 9 13:57:15 UTC 2016


The extra ext is only required for unorm and snorm formats, not all 16-bit
ones.

On Nov 9, 2016 6:39 AM, "Lionel Landwerlin" <lionel.g.landwerlin at intel.com>
wrote:

> This tests that the compiler accepts the new layout formats introduced by
> NV_image_formats and also it's correct interaction with the
> EXT_texture_norm16 specification.
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> ---
>  generated_tests/CMakeLists.txt                     |   4 +
>  .../gen_shader_image_nv_image_formats_tests.py     | 230
> +++++++++++++++++++++
>  2 files changed, 234 insertions(+)
>  create mode 100644 generated_tests/gen_shader_
> image_nv_image_formats_tests.py
>
> diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.
> txt
> index ff43af5..fd38afe 100644
> --- a/generated_tests/CMakeLists.txt
> +++ b/generated_tests/CMakeLists.txt
> @@ -163,6 +163,9 @@ piglit_make_generated_tests(
>         shader_image_load_store_tests.list
>         gen_shader_image_load_store_tests.py)
>  piglit_make_generated_tests(
> +       shader_image_nv_image_formats_tests.list
> +       gen_shader_image_nv_image_formats_tests.py)
> +piglit_make_generated_tests(
>         variable_index_read_tests.list
>         gen_variable_index_read_tests.py
>         templates/gen_variable_index_read_tests/vs.shader_test.mako
> @@ -242,6 +245,7 @@ add_custom_target(gen-gl-tests
>                         conversion_fp64.list
>                         shader_precision_tests.list
>                         shader_image_load_store_tests.list
> +                       shader_image_nv_image_formats_tests.list
>                         variable_index_read_tests.list
>                         gen_extensions_defined.list
>                         vp-tex.list
> diff --git a/generated_tests/gen_shader_image_nv_image_formats_tests.py
> b/generated_tests/gen_shader_image_nv_image_formats_tests.py
> new file mode 100644
> index 0000000..9b1861d
> --- /dev/null
> +++ b/generated_tests/gen_shader_image_nv_image_formats_tests.py
> @@ -0,0 +1,230 @@
> +# coding=utf-8
> +#
> +# Copyright (C) 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.
> +
> +from __future__ import print_function, division, absolute_import
> +import os.path
> +from mako.template import Template
> +from textwrap import dedent
> +
> +from modules import utils
> +
> +
> +def gen_header(status, norm16):
> +    """
> +    Generate a GLSL program header.
> +
> +    Generate header code for ARB_shader_image_load_store GLSL parser
> +    tests that are expected to give status as result.
> +    """
> +    return dedent("""
> +        /*
> +         * [config]
> +         * expect_result: {0}
> +         * glsl_version: 3.10 es
> +         * require_extensions: GL_NV_image_formats {1}
> +         * [end config]
> +         */
> +        #version 310 es
> +        #extension GL_NV_image_formats : enable
> +    """.format(status, "GL_EXT_texture_norm16" if norm16 else
> "!GL_EXT_texture_norm16"))
> +
> +
> +def gen(name, src, tests):
> +    """
> +    Expand a source template for the provided list of test definitions.
> +
> +    Generate a GLSL parser test for each of the elements of the
> +    'tests' iterable, each of them should be a dictionary of
> +    definitions that will be used as environment to render the source
> +    template.
> +
> +    The file name of each test will be the concatenation of the 'name'
> +    argument with the 'name' item from the respective test dictionary.
> +    """
> +    template = Template(dedent(src))
> +
> +    for t in product([{'name': name}], tests):
> +        filename = os.path.join('spec',
> +                                'nv_image_formats',
> +                                'compiler',
> +                                '{0}.{1}'.format(t['name'],
> +                                                 t['shader_stage']))
> +        print(filename)
> +
> +        dirname = os.path.dirname(filename)
> +        utils.safe_makedirs(dirname)
> +
> +        with open(filename, 'w') as f:
> +            f.write(template.render(header = gen_header, **t))
> +
> +
> +shader_stages = [
> +    {'shader_stage': 'frag'},
> +    {'shader_stage': 'vert'}
> +]
> +
> +
> +image_types = [
> +    {
> +        'name': '2d',
> +        'image_type': 'image2D',
> +    },
> +    {
> +        'name': '3d',
> +        'image_type': 'image3D',
> +    },
> +    {
> +        'name': '2d-array',
> +        'image_type': 'image2DArray',
> +    },
> +    {
> +        'name': 'cube',
> +        'image_type': 'imageCube',
> +    }
> +]
> +
> +
> +def product(ps, *qss):
> +    """
> +    Generate the cartesian product of a number of lists of dictionaries.
> +
> +    Each generated element will be the union of some combination of
> +    elements from the iterable arguments.  The resulting value of each
> +    'name' item will be the concatenation of names of the respective
> +    element combination separated with dashes.
> +    """
> +    for q in (product(*qss) if qss else [{}]):
> +        for p in ps:
> +            r = dict(p, **q)
> +            r['name'] = '-'.join(s['name'] for s in (p, q) if
> s.get('name'))
> +            yield r
> +
> +
> +def main():
> +    """Main function."""
> +    #
> +    # Test image declarations.
> +    #
> +    gen('declaration-allow-floating-point', """\
> +        ${header('pass', True)}
> +
> +        layout(rg32f) readonly uniform highp ${image_type} img_rg32f;
> +        layout(rg16f) readonly uniform highp ${image_type} img_rg16f;
> +        layout(r16f) readonly uniform highp ${image_type} img_r16f;
> +        layout(r11f_g11f_b10f) readonly uniform highp ${image_type}
> img_r11g11b10f;
> +
> +        void main()
> +        {
> +        }
> +    """, product(image_types, shader_stages))
> +
> +
> +    gen('declaration-allow-unorm', """\
> +        ${header('pass', True)}
> +
> +        layout(rgba16) readonly uniform highp ${image_type} img_rgba16;
> +        layout(rgb10_a2) readonly uniform highp ${image_type}
> img_rgb10_a2;
> +        layout(rg16) readonly uniform highp ${image_type} img_rg16;
> +        layout(rg8) readonly uniform highp ${image_type} img_rg8;
> +        layout(r16) readonly uniform highp ${image_type} img_r16;
> +        layout(r8) readonly uniform highp ${image_type} img_r8;
> +
> +        void main()
> +        {
> +        }
> +    """, product(image_types, shader_stages))
> +
> +
> +    gen('declaration-allow-snorm', """\
> +        ${header('pass', True)}
> +
> +        layout(rgba16_snorm) readonly uniform highp ${image_type}
> img_rgba16;
> +        layout(rg16_snorm) readonly uniform highp ${image_type}
> img_rgb10_a2;
> +        layout(rg8_snorm) readonly uniform highp ${image_type} img_rg16;
> +        layout(r16_snorm) readonly uniform highp ${image_type} img_rg8;
> +        layout(r8_snorm) readonly uniform highp ${image_type} img_r16;
> +
> +        void main()
> +        {
> +        }
> +    """, product(image_types, shader_stages))
> +
> +
> +    gen('declaration-allow-uint', """\
> +        ${header('pass', True)}
> +
> +        layout(rgb10_a2ui) readonly uniform highp u${image_type}
> img_rgb10_a2ui;
> +        layout(rg32ui) readonly uniform highp u${image_type} img_rg32ui;
> +        layout(rg16ui) readonly uniform highp u${image_type} img_rg16ui;
> +        layout(rg8ui) readonly uniform highp u${image_type} img_rg8ui;
> +        layout(r16ui) readonly uniform highp u${image_type} img_r16ui;
> +        layout(r8ui) readonly uniform highp u${image_type} img_r8ui;
> +
> +        void main()
> +        {
> +        }
> +    """, product(image_types, shader_stages))
> +
> +
> +    gen('declaration-allow-int', """\
> +        ${header('pass', True)}
> +
> +        layout(rg32i) readonly uniform highp i${image_type} img_rg32i;
> +        layout(rg16i) readonly uniform highp i${image_type} img_rg16i;
> +        layout(rg8i) readonly uniform highp i${image_type} img_rg8i;
> +        layout(r16i) readonly uniform highp i${image_type} img_r16i;
> +        layout(r8i) readonly uniform highp i${image_type} img_r8i;
> +
> +        void main()
> +        {
> +        }
> +    """, product(image_types, shader_stages))
> +
> +
> +    gen('declaration-disallow-16bit', """\
> +        ${header('fail', False)}
> +
> +        layout(rg16i) readonly uniform highp i${image_type} img_rg16i;
> +        layout(r16i) readonly uniform highp i${image_type} img_r16i;
> +
> +        layout(rg16ui) readonly uniform highp u${image_type} img_rg16ui;
> +        layout(r16ui) readonly uniform highp u${image_type} img_r16ui;
> +
> +        layout(r16f) readonly uniform highp ${image_type} img_r16f;
> +
> +        layout(rgba16) readonly uniform highp ${image_type} img_rgba16;
> +        layout(rg16) readonly uniform highp ${image_type} img_rg16;
> +        layout(r16) readonly uniform highp ${image_type} img_r16;
> +
> +        layout(rgba16_snorm) readonly uniform highp ${image_type}
> img_rgba16_snorm;
> +        layout(rg16_snorm) readonly uniform highp ${image_type}
> img_rgb10_a2_snorm;
> +        layout(r16_snorm) readonly uniform highp ${image_type}
> img_rg8_snorm;
> +
> +        void main()
> +        {
> +        }
> +    """, product(image_types, shader_stages))
> +
> +
> +if __name__ == '__main__':
> +    main()
> --
> 2.10.2
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20161109/a37bd465/attachment-0001.html>


More information about the Piglit mailing list