[Piglit] [PATCH 5/6] generators/gen_vs_in_fp64: Rewrite the columns test generator
Dylan Baker
dylan at pnwbakers.com
Tue Jun 7 21:15:12 UTC 2016
This rewrites the columns generator to use a single template rather than
the inherited template. The net result is that these tests are generated
in 1/3 of the time.
These are the minority tests from this generator. I measure that they
take about .3 seconds to generate (with this patch). So while this is
saving us a little bit of time, it's not going to make a big difference.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
generated_tests/CMakeLists.txt | 1 +
generated_tests/gen_vs_in_fp64.py | 2 +-
.../gen_vs_in_fp64/columns.shader_test.mako | 137 +++++++++++++++++++++
.../columns_execution.vert.shader_test.mako | 41 ------
.../gen_vs_in_fp64/columns_shader.vert.mako | 17 ---
5 files changed, 139 insertions(+), 59 deletions(-)
create mode 100644 generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/columns_execution.vert.shader_test.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/columns_shader.vert.mako
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 0b9048f..4c21c8a 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -191,6 +191,7 @@ piglit_make_generated_tests(
piglit_make_generated_tests(
vs_in_fp64.list
gen_vs_in_fp64.py
+ templates/gen_vs_in_fp64/columns.shader_test.mako
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
diff --git a/generated_tests/gen_vs_in_fp64.py b/generated_tests/gen_vs_in_fp64.py
index 815ce1a..bd9e8d6 100644
--- a/generated_tests/gen_vs_in_fp64.py
+++ b/generated_tests/gen_vs_in_fp64.py
@@ -346,7 +346,7 @@ class ColumnsTestTuple(TestTuple):
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(
+ 'columns.shader_test.mako').render_unicode(
ver=self._ver,
mat=self._mat,
columns=self._columns,
diff --git a/generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako
new file mode 100644
index 0000000..0da2678
--- /dev/null
+++ b/generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako
@@ -0,0 +1,137 @@
+## encoding=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 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 _version(ver):
+ 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 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 rows(in_type):
+ if 'vec' in in_type or 'mat' in in_type:
+ return int(in_type[-1:])
+ else:
+ return 1
+
+%>
+<% glsl, glsl_int = _version(ver) %>
+
+[require]
+GLSL >= ${glsl}
+% if ver == 'GL_ARB_vertex_attrib_64bit':
+ GL_ARB_gpu_shader_fp64
+ ${ver}
+% endif
+
+[vertex shader]
+#version ${glsl_int}
+% if ver == 'GL_ARB_vertex_attrib_64bit':
+ #extension GL_ARB_gpu_shader_fp64 : require
+ #extension GL_ARB_vertex_attrib_64bit : require
+% endif
+
+uniform ${mat} expected;
+
+in ${mat} value;
+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);
+ % for idx, column in enumerate(columns):
+ % if column == 1:
+ if (value[${idx}] != expected[${idx}]) {
+ fs_color = RED;
+ return;
+ }
+ ## XXX: should we break here?
+ % endif
+ % endfor
+ fs_color = GREEN;
+}
+
+[fragment shader]
+#version 150
+
+in vec4 fs_color;
+out vec4 color;
+
+void main()
+{
+ color = fs_color;
+}
+
+[vertex data]
+piglit_vertex/vec3/3\
+ % for i in range(cols(mat)):
+ value/${mat}/${rows(mat)}${'/{}'.format(i) if 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(cols(mat)):
+ % for j in range(rows(mat)):
+${dvalues[(d + i * rows(mat) + j) % len(dvalues)]} \
+ % endfor
+ \
+ % endfor
+
+ % endfor
+% endfor
+
+[test]
+% for d in range(len(dvalues)):
+
+ uniform ${mat} expected\
+ % for i in range(cols(mat)):
+ % for j in range(rows(mat)):
+ ${dvalues[(d + i * 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
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
deleted file mode 100644
index d345653..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/columns_execution.vert.shader_test.mako
+++ /dev/null
@@ -1,41 +0,0 @@
-## 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
deleted file mode 100644
index c150121..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/columns_shader.vert.mako
+++ /dev/null
@@ -1,17 +0,0 @@
-## 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>
--
2.8.3
More information about the Piglit
mailing list