[Piglit] [PATCH 1/8] glsl-4.00/ARB_texture_query_lod: Generate compiler tests for built-in functions
Matt Turner
mattst88 at gmail.com
Tue Mar 19 11:46:27 PDT 2013
For each sampler data type, generate a test for
(vertex, fragment) shader;
(glsl-4.00, glsl-1.30 + ARB_texture_query_lod).
The vertex shader tests confirm that textureQueryLod is not available in
the the vertex shader.
---
generated_tests/CMakeLists.txt | 4 +
generated_tests/gen_texture_query_lod_tests.py | 149 ++++++++++++++++++++++++
2 files changed, 153 insertions(+), 0 deletions(-)
create mode 100755 generated_tests/gen_texture_query_lod_tests.py
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 694a213..2b3293c 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -37,6 +37,9 @@ piglit_make_generated_tests(
non-lvalue_tests.list
gen_non-lvalue_tests.py)
piglit_make_generated_tests(
+ texture_query_lod_tests.list
+ gen_texture_query_lod_tests.py)
+piglit_make_generated_tests(
uniform-initializer_tests.list
gen_uniform_initializer_tests.py
uniform-initializer-templates/fs-initializer.template
@@ -57,4 +60,5 @@ add_custom_target(gen-tests ALL
constant_array_size_tests.list
interpolation_tests.list
non-lvalue_tests.list
+ texture_query_lod_tests.list
uniform-initializer_tests.list)
diff --git a/generated_tests/gen_texture_query_lod_tests.py b/generated_tests/gen_texture_query_lod_tests.py
new file mode 100755
index 0000000..1e1aad0
--- /dev/null
+++ b/generated_tests/gen_texture_query_lod_tests.py
@@ -0,0 +1,149 @@
+#!/usr/bin/env python2
+# coding=utf-8
+#
+# Copyright © 2013 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.
+
+import os
+import os.path
+from mako.template import Template
+from textwrap import dedent
+
+sampler_type_to_coord_type = {
+ 'sampler1D': 'float',
+ 'isampler1D': 'float',
+ 'usampler1D': 'float',
+
+ 'sampler2D': 'vec2',
+ 'isampler2D': 'vec2',
+ 'usampler2D': 'vec2',
+
+ 'sampler3D': 'vec3',
+ 'isampler3D': 'vec3',
+ 'usampler3D': 'vec3',
+
+ 'samplerCube': 'vec3',
+ 'isamplerCube': 'vec3',
+ 'usamplerCube': 'vec3',
+
+ 'sampler1DArray': 'float',
+ 'isampler1DArray': 'float',
+ 'usampler1DArray': 'float',
+
+ 'sampler2DArray': 'vec2',
+ 'isampler2DArray': 'vec2',
+ 'usampler2DArray': 'vec2',
+
+ 'samplerCubeArray': 'vec3',
+ 'isamplerCubeArray': 'vec3',
+ 'usamplerCubeArray': 'vec3',
+
+ 'sampler1DShadow': 'float',
+ 'sampler2DShadow': 'vec2',
+ 'samplerCubeShadow': 'vec3',
+ 'sampler1DArrayShadow': 'float',
+ 'sampler2DArrayShadow': 'vec2',
+ 'samplerCubeArrayShadow': 'vec3',
+}
+
+requirements = {
+ 'ARB_texture_query_lod': {
+ 'version': '1.30',
+ 'extension': 'GL_ARB_texture_query_lod'
+ },
+ 'glsl-4.00': {
+ 'version': '4.00',
+ 'extension': ''
+ }
+}
+
+template = Template(dedent("""\
+ /* [config]
+ % if execution_stage == 'fs':
+ * expect_result: pass
+ % else:
+ * expect_result: fail
+ % endif
+ * glsl_version: ${version}
+ % if extensions:
+ * required_extensions: ${" ".join(extensions)}
+ % endif
+ * [end config]
+ */
+
+ #version ${version.translate(None, '.')}
+ % for extension in extensions:
+ #extension ${extension} : enable
+ % endfor
+
+ uniform ${sampler_type} s;
+ % if execution_stage == 'fs':
+ varying ${coord_type} coord;
+ % else:
+ uniform ${coord_type} coord;
+ % endif
+
+ void main()
+ {
+ % if execution_stage == 'fs':
+ gl_FragColor.xy = textureQueryLod(s, coord);
+ % else:
+ gl_Position.xy = textureQueryLod(s, coord);
+ % endif
+ }
+"""))
+
+for api, requirement in requirements.iteritems():
+ for sampler_type, coord_type in sampler_type_to_coord_type.iteritems():
+ for execution_stage in ("vs", "fs"):
+ file_extension = 'frag' if execution_stage == 'fs' else 'vert'
+ filename = os.path.join("spec",
+ api,
+ "compiler",
+ "built-in-functions",
+ "{0}.{1}"\
+ .format(sampler_type,
+ file_extension))
+ print filename
+
+ dirname = os.path.dirname(filename)
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
+ version = requirement['version']
+ extensions = [requirement['extension']]
+
+ # samplerCubeArray types are part GLSL 4.00
+ # or GL_ARB_texture_cube_map_array.
+ if api == "ARB_texture_query_lod" and \
+ sampler_type in ['samplerCubeArray', \
+ 'isamplerCubeArray', \
+ 'usamplerCubeArray', \
+ 'samplerCubeArrayShadow']:
+ extensions += ['GL_ARB_texture_cube_map_array']
+
+ f = open(filename, "w")
+ f.write(template.render(version = version,
+ extensions = extensions,
+ execution_stage = execution_stage,
+ sampler_type = sampler_type,
+ coord_type = coord_type))
+ f.close()
--
1.7.8.6
More information about the Piglit
mailing list