[Piglit] [PATCH 2/2] generated_tests: new compiler tests for NV_image_formats
Dylan Baker
dylan at pnwbakers.com
Wed Nov 9 20:10:49 UTC 2016
Quoting Dylan Baker (2016-11-09 12:08:34)
> Quoting Lionel Landwerlin (2016-11-09 03:39:33)
> > 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.
>
> A Short docstring here explaining what the generator does wouldn't be amiss.
> You could probably just copy your commit message.
>
> > +
> > +from __future__ import print_function, division, absolute_import
> > +import os.path
> > +from mako.template import Template
> > +from textwrap import dedent
>
> please sort these as:
> __future__
> python builtins
>
> 3rd party modules
>
> local modules
>
> (in this case mako is the only 3rd party module, everything else is correct.)
>
> > +
> > +from modules import utils
> > +
> > +
> > +def gen_header(status, norm16):
> > + """
> > + Generate a GLSL program header.
>
> Most of piglit puts the """ and the first lone of the docstring on the same line
>
> > +
> > + 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"))
>
> This line is really long
>
> > +
> > +
> > +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))
>
> no spaces between "=" in function calls or signatures, please
>
> > +
> > +
> > +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
>
> Since all my comments are just style nits, I don't need to see a v2.
> With the above addressed:
Oops, that should be "With the above addressed and Ilia's comments fixed"
Dylan
> Reviewed-by: Dylan Baker <dylan at pnwbakers.com>
>
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/piglit
>
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20161109/c4f4c442/attachment.sig>
More information about the Piglit
mailing list