summaryrefslogtreecommitdiff
path: root/generated_tests
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2015-03-26 17:44:43 -0700
committerDylan Baker <baker.dylan.c@gmail.com>2015-06-09 15:08:25 -0700
commited872266bf104f91997f2524f9cbb64f4fba064f (patch)
tree77afdf0a4f1a34054e098ee64b3b5f22df77fe83 /generated_tests
parent8de771e67db8ad97a77a1cc7c7bbd4316167dafb (diff)
generators: port variable-index-read.sh to python
This patch replaces a bash based generator with a python generator. This has the obvious advantage of remove a large swath of generated tests from the check-in, and prevents modification of a generated file. It also is much faster than the bash generator, so running at compile time isn't a problem. There are no functional differences between the bash generated versions and the python generated versions, only whitespace/line-wrapping differences, and small changes to the copyright header. All tests that passed with the bash versions pass with the python versions on the i965 driver with multiple hardware revisions. Tested with python2.7 and python3.3 v2: - rename generated test .list file (Emil) - Use a shared function to add the license text (also removes a typo in the text spotted by Emil) Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com> Acked-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'generated_tests')
-rw-r--r--generated_tests/CMakeLists.txt9
-rw-r--r--generated_tests/gen_variable_index_read_tests.py261
-rw-r--r--generated_tests/modules/utils.py22
-rw-r--r--generated_tests/templates/gen_variable_index_read_tests/fs.shader_test.mako31
-rw-r--r--generated_tests/templates/gen_variable_index_read_tests/helpers.mako238
-rw-r--r--generated_tests/templates/gen_variable_index_read_tests/vs.shader_test.mako31
6 files changed, 591 insertions, 1 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 5036a5db6..665d661ff 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -120,6 +120,12 @@ piglit_make_generated_tests(
piglit_make_generated_tests(
shader_image_load_store_tests.list
gen_shader_image_load_store_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
+ templates/gen_variable_index_read_tests/fs.shader_test.mako
+ templates/gen_variable_index_read_tests/helpers.mako)
# OpenCL Test generators
piglit_make_generated_tests(
@@ -161,11 +167,12 @@ add_custom_target(gen-gl-tests
constant_array_size_tests_fp64.list
shader_precision_tests.list
shader_image_load_store_tests.list
+ variable_index_read_tests.list
)
# Create a custom target for generating OpenCL tests
# This is not added to the default target, instead it is added
-# as a dependency of gen-etsts if OpenCL tests are enabled
+# as a dependency of gen-tests if OpenCL tests are enabled
add_custom_target(gen-cl-tests
DEPENDS builtin_cl_int_tests.list
builtin_cl_math_tests.list
diff --git a/generated_tests/gen_variable_index_read_tests.py b/generated_tests/gen_variable_index_read_tests.py
new file mode 100644
index 000000000..c92248b46
--- /dev/null
+++ b/generated_tests/gen_variable_index_read_tests.py
@@ -0,0 +1,261 @@
+# Copyright (c) 2015 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 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 tests for glsl 1.10 and 1.20 variable index reads."""
+
+from __future__ import print_function, absolute_import, division
+import os
+import itertools
+
+from six.moves import range
+
+from templates import template_dir
+from modules.utils import lazy_property, safe_makedirs
+
+TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
+FS_TEMPLATE = TEMPLATES.get_template('fs.shader_test.mako')
+VS_TEMPLATE = TEMPLATES.get_template('vs.shader_test.mako')
+DIRNAME = os.path.join('spec', 'glsl-{}', 'execution', 'variable-indexing')
+
+
+class TestParams(object):
+ """Parameters for a single test.
+
+ This is all of the non-formatting logic of the test. Each property is
+ wrapped with a lazy_property decorator, which means the data is cached
+ after it is calculated once.
+
+ """
+ def __init__(self, matrix_dim, array_dim, mode, index_value, col,
+ expect_type, glsl_version):
+ self.matrix_dim = matrix_dim
+ self.array_dim = array_dim
+ self.mode = mode
+ self.index_value = index_value
+ self.col = col
+ self.expect_type = expect_type
+
+ assert glsl_version in [110, 120]
+ self.glsl_version = glsl_version
+
+ @lazy_property
+ def idx(self):
+ if self.array_dim != 0:
+ return '[{}]'.format(self.index_value)
+ else:
+ return ''
+
+ @lazy_property
+ def cxr_type(self):
+ return 'mat{0}x{0}'.format(self.matrix_dim)
+
+ @lazy_property
+ def base_type(self):
+ if self.glsl_version == 120:
+ return self.cxr_type
+ else:
+ return 'mat{}'.format(self.matrix_dim)
+
+ @lazy_property
+ def type(self):
+ if self.array_dim != 0 and self.glsl_version == 120:
+ return '{}[{}]'.format(self.base_type, self.array_dim)
+ else:
+ return self.base_type
+
+ @lazy_property
+ def dim(self):
+ if self.array_dim != 0 and self.glsl_version == 110:
+ return '[{}]'.format(self.array_dim)
+ else:
+ # XXX: should this be an error?
+ return ''
+
+ @lazy_property
+ def row(self):
+ if self.expect_type == 'float':
+ return '[row]'
+ else:
+ # XXX: Should this be an error?
+ return ''
+
+ @lazy_property
+ def test_sizes(self):
+ if self.array_dim == 0:
+ return [1]
+ elif self.index_value == 'index':
+ return list(range(1, 1 + self.array_dim))
+ else:
+ return [2]
+
+ @lazy_property
+ def test_columns(self):
+ if self.col == 'col':
+ return list(range(1, 1 + self.matrix_dim))
+ else:
+ return [2]
+
+ @lazy_property
+ def test_rows(self):
+ if self.expect_type == 'float':
+ return list(range(1, 1 + self.matrix_dim))
+ else:
+ return [1]
+
+ @lazy_property
+ def test_array_dim(self):
+ if (self.mode == 'uniform' and
+ self.glsl_version == 110 and
+ self.array_dim != 0 and
+ self.index_value != 'index'):
+ return self.index_value + 1
+ else:
+ return self.array_dim
+
+ @lazy_property
+ def varying_comps(self):
+ if self.array_dim != 0:
+ return 4 + self.matrix_dim**2 * self.array_dim
+ else:
+ return 4 + self.matrix_dim**2
+
+ @lazy_property
+ def formated_version(self):
+ return '{:.2f}'.format(float(self.glsl_version) / 100)
+
+
+def make_fs(name, params):
+ """Generate a fragment shader test."""
+ dirname = DIRNAME.format(params.formated_version)
+ safe_makedirs(dirname)
+ with open(os.path.join(dirname, name), 'w') as f:
+ f.write(FS_TEMPLATE.render_unicode(params=params))
+ print(name)
+
+
+def make_vs(name, params):
+ """Generate a vertex shader test."""
+ dirname = DIRNAME.format(params.formated_version)
+ safe_makedirs(dirname)
+ with open(os.path.join(dirname, name), 'w') as f:
+ f.write(VS_TEMPLATE.render_unicode(params=params))
+ print(name)
+
+
+def main():
+ """Generate the tests."""
+ modes = ['temp', 'uniform', 'varying']
+ array_dims = [0, 3]
+ matrix_dims = [2, 3, 4]
+ glsl_versions = [110, 120]
+ iter_ = itertools.product(modes, array_dims, matrix_dims, glsl_versions)
+ for mode, array_dim, matrix_dim, glsl_version in iter_:
+ if array_dim != 0:
+ arr = 'array-'
+ idx_text = 'index-'
+
+ # TODO: This can certainly be rolled up into a loop
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-col-row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 'col', 'float',
+ glsl_version))
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 1, 'float',
+ glsl_version))
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-col-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 'col',
+ 'vec{}'.format(matrix_dim), glsl_version))
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 1,
+ 'vec{}'.format(matrix_dim), glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-col-row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 'col', 'float',
+ glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 1, 'float',
+ glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-col-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 'col',
+ 'vec{}'.format(matrix_dim), glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 1, 1,
+ 'vec{}'.format(matrix_dim), glsl_version))
+ else:
+ arr = ''
+ idx_text = ''
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-{idx_text}col-row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 'col', 'float',
+ glsl_version))
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-{idx_text}row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 1, 'float',
+ glsl_version))
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-{idx_text}col-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 'col',
+ 'vec{}'.format(matrix_dim), glsl_version))
+
+ make_fs(
+ 'fs-{mode}-{arr}mat{matrix_dim}-{idx_text}rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 1,
+ 'vec{}'.format(matrix_dim), glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-{idx_text}col-row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 'col', 'float',
+ glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-{idx_text}row-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 1, 'float',
+ glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-{idx_text}col-rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 'col',
+ 'vec{}'.format(matrix_dim), glsl_version))
+
+ make_vs(
+ 'vs-{mode}-{arr}mat{matrix_dim}-{idx_text}rd.shader_test'.format(**locals()),
+ TestParams(matrix_dim, array_dim, mode, 'index', 1,
+ 'vec{}'.format(matrix_dim), glsl_version))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/generated_tests/modules/utils.py b/generated_tests/modules/utils.py
index 28893834f..5495ad800 100644
--- a/generated_tests/modules/utils.py
+++ b/generated_tests/modules/utils.py
@@ -23,6 +23,7 @@
from __future__ import print_function, absolute_import
import os
import errno
+import functools
def safe_makedirs(dirs):
@@ -43,3 +44,24 @@ def safe_makedirs(dirs):
pass
else:
raise
+
+
+class lazy_property(object):
+ """Decorator for lazy property loading.
+
+ A property decorated with this class will execute it's code the first time
+ it's run, but will store the value after that. This is useful for values
+ that are either 1) expensive to compute, or 2) need to be computed only
+ once and then read multiple times
+
+ """
+ def __init__(self, func):
+ functools.wraps(func)
+ self.__func = func
+
+ def __get__(self, obj, cls):
+ if not obj:
+ return self
+ value = self.__func(obj)
+ setattr(obj, self.__func.__name__, value)
+ return value
diff --git a/generated_tests/templates/gen_variable_index_read_tests/fs.shader_test.mako b/generated_tests/templates/gen_variable_index_read_tests/fs.shader_test.mako
new file mode 100644
index 000000000..39b0be5f7
--- /dev/null
+++ b/generated_tests/templates/gen_variable_index_read_tests/fs.shader_test.mako
@@ -0,0 +1,31 @@
+## Copyright (c) 2015 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 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.
+
+<%namespace name="helpers" file="helpers.mako"/>
+
+${helpers.license()}
+
+${helpers.emit_header(params)}
+
+${helpers.emit_vs(params, 0)}
+
+${helpers.emit_fs(params, 1)}
+
+${helpers.emit_test_vectors(params)}
diff --git a/generated_tests/templates/gen_variable_index_read_tests/helpers.mako b/generated_tests/templates/gen_variable_index_read_tests/helpers.mako
new file mode 100644
index 000000000..cb0bff41e
--- /dev/null
+++ b/generated_tests/templates/gen_variable_index_read_tests/helpers.mako
@@ -0,0 +1,238 @@
+## Copyright (c) 2015 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 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 six.moves import range
+
+ def dedent(text):
+ return '\n'.join(l.lstrip() for l in text.splitlines())
+
+ def newlines(text):
+ return '\n'.join(l for l in text.splitlines() if l.strip())
+%>
+
+<%def name="license()">
+# 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 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.
+</%def>
+
+<%def name="emit_header(params)" filter="dedent,newlines">
+ ## Generated test, do not edit
+ [require]
+ GLSL >= ${params.formated_version}
+ % if params.mode == 'varying':
+ GL_MAX_VARYING_COMPONENTS >= ${params.varying_comps}
+ % endif
+</%def>
+
+<%def name="matrix_data(first, dim, delim=', ')" filter="trim,dedent,newlines">
+ ${delim.join(str(float(x)) for x in range(first, first + dim**2))}
+</%def>
+
+<%def name="emit_matrix_array_initializer(matrix_dim, array_dim, base_type)" filter="trim,newlines">
+ % for c in range(array_dim):
+${base_type}(${matrix_data(c * matrix_dim**2 + 1, matrix_dim)})\
+ % if c < array_dim - 1:
+, \
+ % endif
+ % endfor
+</%def>
+
+<%def name="emit_set_matrix(params)" filter="dedent,newlines">
+ % if params.array_dim != 0:
+ % if params.mode == 'temp':
+ % if params.glsl_version == 120:
+ ${params.type} m${params.dim} = ${params.type}(${emit_matrix_array_initializer(params.matrix_dim, params.array_dim, params.base_type)});
+ % else:
+ ${params.type} m${params.dim};
+ % endif
+ % endif
+ % if params.glsl_version == 110 or params.mode == 'varying':
+ % for i in range(params.array_dim):
+ m[${i}] = mat${params.matrix_dim}(${matrix_data(1 + i * params.matrix_dim**2, params.matrix_dim)});
+ % endfor
+ % endif
+ % else:
+ % if params.mode == 'temp':
+ ${params.type} m = ${params.type}(${matrix_data(1, params.matrix_dim)});
+ % else:
+ m = ${params.type}(${matrix_data(1, params.matrix_dim)});
+ % endif
+ % endif
+</%def>
+
+<%def name="emit_globals(params)" filter="dedent,newlines">
+ % if params.array_dim != 0 and params.index_value == 'index':
+ uniform int index;
+ % endif
+
+ % if params.col == 'col':
+ uniform int col;
+ % endif
+
+ % if params.expect_type == 'float':
+ uniform int row;
+ % endif
+
+ uniform ${params.expect_type} expect;
+
+ % if params.glsl_version == 120 and params.mode == 'uniform':
+ % if params.array_dim == 0:
+ ${params.mode} ${params.type} m = ${params.type}(${matrix_data(1, params.matrix_dim)});
+ % else:
+ ${params.mode} ${params.type} m${params.dim} = ${params.type}(${emit_matrix_array_initializer(params.matrix_dim, params.array_dim, params.base_type)});
+ % endif
+ % elif params.mode != 'temp':
+ ${params.mode} ${params.type} m${params.dim};
+ % endif
+ varying vec4 color;
+</%def>
+
+## TODO: convert do_compare into a bool
+<%def name="emit_vs(params, do_compare)" filter="newlines">
+[vertex shader]
+${emit_globals(params)}
+
+void main()
+{
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ % if params.mode == 'varying' or (params.mode == 'temp' and do_compare != 0):
+ ${emit_set_matrix(params)}
+ % endif
+
+ % if do_compare != 0:
+ % if params.mode == 'varying':
+ /* From page 23 (page 30 of the PDF) of the GLSL 1.10 spec:
+ *
+ * "A vertex shader may also read varying variables, getting back the
+ * same values it has written. Reading a varying variable in a vertex
+ * shader returns undefined values if it is read before being
+ * written."
+ */
+ % endif
+ ## TODO: Could probably simplify this with the use of params.row
+ % if params.expect_type == 'float':
+ color = (m${params.idx}[${params.col}][row] == expect) \
+ % else:
+ color = (m${params.idx}[${params.col}] == expect) \
+ % endif
+ ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
+ % endif
+}
+</%def>
+
+## TODO: convert do_compare into a bool
+<%def name="emit_fs(params, do_compare)" filter="newlines">
+[fragment shader]
+${emit_globals(params)}
+
+void main()
+{
+ % if do_compare == 0 and params.mode == 'varying':
+ /* There is some trickery here. The fragment shader has to actually use
+ * the varyings generated by the vertex shader, or the compiler (more
+ * likely the linker) might demote the varying outputs to just be vertex
+ * shader global variables. Since the point of the test is the vertex
+ * shader reading from a varying, that would defeat the test.
+ */
+ % endif
+ % if do_compare != 0 or params.mode == 'varying':
+ % if params.mode == 'temp':
+ ${emit_set_matrix(params)}
+ % endif
+ gl_FragColor = (m${params.idx}[${params.col}]${params.row} == expect) \
+ % if do_compare == 0:
+ ? color : vec4(1.0, 0.0, 0.0, 1.0);
+ % else:
+ ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
+ % endif
+ % else:
+ gl_FragColor = color;
+ % endif
+}
+</%def>
+
+<%def name="emit_test_vectors(params)" filter="dedent">
+ <%block filter="newlines">
+ [test]
+ clear color 0.5 0.5 0.5 0.5
+ clear
+ ortho
+ % if params.mode == 'uniform' and params.glsl_version == 110 and params.test_array_dim == 0:
+ uniform ${params.cxr_type} m ${matrix_data(1, params.matrix_dim, delim=' ')}
+ % endif
+
+ </%block>
+ % for size in params.test_sizes:
+ <%block filter="newlines">
+ % if params.mode == 'uniform' and params.glsl_version == 110 and params.test_array_dim != 0:
+ % for c in range(params.test_array_dim):
+ uniform ${params.cxr_type} m[${c}] ${matrix_data(1 + c * params.matrix_dim**2, params.matrix_dim, delim=' ')}
+ % endfor
+ % endif
+ % if params.test_array_dim != 0 and params.index_value == 'index':
+ uniform int index ${size - 1}
+ % endif
+ </%block>
+ <% x_base = ((size - 1) * (15 * params.matrix_dim + 10)) %>
+ % for column in params.test_columns:
+ <%block filter="newlines">
+ % if params.col == 'col':
+ uniform int col ${column - 1}
+ % endif
+ </%block>
+
+ % for row in params.test_rows:
+ <%block filter="newlines">
+ <% expect = (size - 1) * params.matrix_dim**2 + (column - 1) * params.matrix_dim + row %>
+ % if params.expect_type == 'float':
+ uniform int row ${row - 1}
+ uniform float expect ${expect}
+ % else:
+ uniform ${params.expect_type} expect ${' '.join(str(i) for i in range(expect, expect + params.matrix_dim))}
+ % endif
+
+ <%
+ x = x_base + 15 * column - 10
+ y = 15 * row - 10
+ %>
+ draw rect ${x} ${y} 10 10
+ probe rgb ${x + 5} ${y + 5} 0.0 1.0 0.0
+ </%block>
+
+ % endfor
+ % endfor
+ % endfor
+</%def>
diff --git a/generated_tests/templates/gen_variable_index_read_tests/vs.shader_test.mako b/generated_tests/templates/gen_variable_index_read_tests/vs.shader_test.mako
new file mode 100644
index 000000000..b2f8138f0
--- /dev/null
+++ b/generated_tests/templates/gen_variable_index_read_tests/vs.shader_test.mako
@@ -0,0 +1,31 @@
+## Copyright (c) 2015 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 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.
+
+<%namespace name="helpers" file="helpers.mako"/>
+
+${helpers.license()}
+
+${helpers.emit_header(params)}
+
+${helpers.emit_vs(params, 1)}
+
+${helpers.emit_fs(params, 0)}
+
+${helpers.emit_test_vectors(params)}