[Piglit] [PATCH 6/6] generators/gen_vs_in_fp64: reimplement require_execution template
Dylan Baker
dylan at pnwbakers.com
Tue Jun 7 21:15:13 UTC 2016
This cuts the runtime for this generator by 3/4 on my system. That's 4
minutes to 1 minute. That's pretty impressive, and for both my system
and for our CI system this is a nice improvement. The generated files
are the same, minus whitespace changes (diff -NaurBw notes no
differences).
While I think the new template is more readable than the original code,
and it is definitely faster, it does introduce more code duplication
that could be cleaned up in a follow on patch.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
generated_tests/CMakeLists.txt | 6 +-
generated_tests/gen_vs_in_fp64.py | 2 +-
generated_tests/templates/gen_vs_in_fp64/base.mako | 27 ----
.../gen_vs_in_fp64/execution.vert.shader_test.mako | 32 ----
.../templates/gen_vs_in_fp64/execution_base.mako | 85 -----------
.../gen_vs_in_fp64/regular.shader_test.mako | 161 +++++++++++++++++++++
.../regular_execution.vert.shader_test.mako | 67 ---------
.../gen_vs_in_fp64/regular_shader.vert.mako | 19 ---
.../templates/gen_vs_in_fp64/shader.vert.mako | 16 --
.../templates/gen_vs_in_fp64/shader_base.mako | 12 --
10 files changed, 163 insertions(+), 264 deletions(-)
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/base.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/execution_base.mako
create mode 100644 generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/regular_execution.vert.shader_test.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/shader.vert.mako
delete mode 100644 generated_tests/templates/gen_vs_in_fp64/shader_base.mako
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 4c21c8a..7240572 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -192,11 +192,7 @@ 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
- templates/gen_vs_in_fp64/shader.vert.mako
- templates/gen_vs_in_fp64/shader_base.mako)
+ templates/gen_vs_in_fp64/regular.shader_test.mako)
# OpenCL Test generators
piglit_make_generated_tests(
diff --git a/generated_tests/gen_vs_in_fp64.py b/generated_tests/gen_vs_in_fp64.py
index bd9e8d6..fcc87f5 100644
--- a/generated_tests/gen_vs_in_fp64.py
+++ b/generated_tests/gen_vs_in_fp64.py
@@ -292,7 +292,7 @@ class RegularTestTuple(TestTuple):
if not self._names_only:
with open(filename, 'w') as test_file:
test_file.write(TEMPLATES.get_template(
- 'regular_execution.vert.shader_test.mako').render_unicode(
+ 'regular.shader_test.mako').render_unicode(
ver=self._ver,
in_types=self._in_types,
position_order=self._position_order,
diff --git a/generated_tests/templates/gen_vs_in_fp64/base.mako b/generated_tests/templates/gen_vs_in_fp64/base.mako
deleted file mode 100644
index fb00d8c..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/base.mako
+++ /dev/null
@@ -1,27 +0,0 @@
-## coding=utf-8
-<%def name="versioning()"><%
- 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>\
-<%def name="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>\
-<%def name="rows(in_type)"><%
- if 'vec' in in_type or 'mat' in in_type:
- return int(in_type[-1:])
- else:
- return 1
-%></%def>\
-${next.body()}\
diff --git a/generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako
deleted file mode 100644
index fc70997..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/execution.vert.shader_test.mako
+++ /dev/null
@@ -1,32 +0,0 @@
-## coding=utf-8
-<%inherit file="base.mako"/>\
-<%
- (glsl_version, glsl_version_int) = self.versioning()
-%>\
-[require]
-GLSL >= ${glsl_version}
-% if ver == 'GL_ARB_vertex_attrib_64bit':
-GL_ARB_gpu_shader_fp64
-${ver}
-% endif
-<%block name="require"/>\
-
-[vertex shader]
-<%block name="vertex_shader"/>\
-
-[fragment shader]
-#version 150
-
-in vec4 fs_color;
-out vec4 color;
-
-void main()
-{
- color = fs_color;
-}
-
-[vertex data]
-<%block name="vertex_data"/>\
-
-[test]\
-<%block name="test_commands"/>\
diff --git a/generated_tests/templates/gen_vs_in_fp64/execution_base.mako b/generated_tests/templates/gen_vs_in_fp64/execution_base.mako
deleted file mode 100644
index b36f7a8..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/execution_base.mako
+++ /dev/null
@@ -1,85 +0,0 @@
-## coding=utf-8
-<%inherit file="base.mako"/>\
-<%
- (glsl_version, glsl_version_int) = self.versioning()
-
- def rows(in_type):
- if 'vec' in in_type or 'mat' in in_type:
- return int(in_type[-1:])
- else:
- return 1
-
- 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
-%>\
-<%! from six.moves import range %>\
-[require]
-GLSL >= ${glsl_version}
-% if ver == 'GL_ARB_vertex_attrib_64bit':
-GL_ARB_gpu_shader_fp64
-${ver}
-% endif
-GL_MAX_VERTEX_ATTRIBS >= ${num_vs_in}
-${next.body()}\
-[vertex data]
-% for idx, in_type in enumerate(in_types):
-% if idx == position_order - 1:
-piglit_vertex/vec3/3 \
-% endif
-% for i in range(arrays[idx]):
-% for j in range(cols(in_type)):
-value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${in_type}/${rows(in_type)}${'/{}'.format(j) if cols(in_type) > 1 else ''} \
-% endfor
-% endfor
-% endfor
-% if position_order > len(in_types):
-piglit_vertex/vec3/3\
-% endif
-
-% 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'):
-% for idx, in_type in enumerate(in_types):
-% if idx == position_order - 1:
-${vertex} \
-% endif
-% for i in range(arrays[idx]):
-% for j in range(cols(in_type)):
-% for k in range(rows(in_type)):
-${dvalues[(d + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + k) % 4]} \
-% endfor
- \
-% endfor
-% endfor
-% endfor
-% if position_order > len(in_types):
-${vertex}\
-% endif
-
-% endfor
-% endfor
-
-[test]
-% for d in range(len(dvalues)):
-% for idx, in_type in enumerate(in_types):
-% for i in range(arrays[idx]):
-uniform ${in_type} expected${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}\
-% for j in range(cols(in_type)):
-% for k in range(rows(in_type)):
- ${dvalues[(d + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + k) % 4]}\
-% endfor
-% endfor
-
-% 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/regular.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
new file mode 100644
index 0000000..b727b5e
--- /dev/null
+++ b/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
@@ -0,0 +1,161 @@
+## 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
+GL_MAX_VERTEX_ATTRIBS >= ${num_vs_in}
+
+[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
+
+% for idx, in_type in enumerate(in_types):
+ uniform ${in_type} expected${idx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''};
+% endfor
+% for idx, in_type in enumerate(in_types):
+ in ${in_type} value${idx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''};
+% endfor
+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, in_type in enumerate(in_types):
+ if (value${idx} != expected${idx}) {
+ fs_color = RED;
+ return;
+ }
+ ## XXX: should this have a break?
+ % endfor
+ fs_color = GREEN;
+}
+
+[fragment shader]
+#version 150
+
+in vec4 fs_color;
+out vec4 color;
+
+void main()
+{
+ color = fs_color;
+}
+
+[vertex data]
+% for idx, in_type in enumerate(in_types):
+ % if idx == position_order - 1:
+ piglit_vertex/vec3/3 \
+ % endif
+ % for i in range(arrays[idx]):
+ % for j in range(cols(in_type)):
+ value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${in_type}/${rows(in_type)}${'/{}'.format(j) if cols(in_type) > 1 else ''} \
+ % endfor
+ % endfor
+% endfor
+% if position_order > len(in_types):
+ piglit_vertex/vec3/3\
+% endif
+
+% 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'):
+ % for idx, in_type in enumerate(in_types):
+ % if idx == position_order - 1:
+ ${vertex} \
+ % endif
+ % for i in range(arrays[idx]):
+ % for j in range(cols(in_type)):
+ % for k in range(rows(in_type)):
+ ${dvalues[(d + (i * cols(in_type) + j) * rows(in_type) + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + (i * cols(in_type) + j) * rows(in_type) + k) % len(hvalues)]} \
+ % endfor
+ \
+ % endfor
+ % endfor
+ % endfor
+ % if position_order > len(in_types):
+ ${vertex}\
+ % endif
+
+ % endfor
+% endfor
+
+[test]
+% for d in range(len(dvalues)):
+
+ % for idx, in_type in enumerate(in_types):
+ % for i in range(arrays[idx]):
+ uniform ${in_type} expected${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}\
+ % for j in range(cols(in_type)):
+ % for k in range(rows(in_type)):
+ ${dvalues[(d + (i * cols(in_type) + j) * rows(in_type) + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + (i * cols(in_type) + j) * rows(in_type) + k) % len(hvalues)]}\
+ % endfor
+ % endfor
+
+ % 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/regular_execution.vert.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/regular_execution.vert.shader_test.mako
deleted file mode 100644
index d3fd08c..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/regular_execution.vert.shader_test.mako
+++ /dev/null
@@ -1,67 +0,0 @@
-## coding=utf-8
-<%inherit file="execution.vert.shader_test.mako"/>\
-<%! from six.moves import range %>\
-<%block name="require">\
-GL_MAX_VERTEX_ATTRIBS >= ${num_vs_in}
-</%block>
-<%block name="vertex_data">\
-% for idx, in_type in enumerate(in_types):
-% if idx == position_order - 1:
-piglit_vertex/vec3/3 \
-% endif
-% for i in range(arrays[idx]):
-% for j in range(self.cols(in_type)):
-value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${in_type}/${self.rows(in_type)}${'/{}'.format(j) if self.cols(in_type) > 1 else ''} \
-% endfor
-% endfor
-% endfor
-% if position_order > len(in_types):
-piglit_vertex/vec3/3\
-% endif
-
-% 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'):
-% for idx, in_type in enumerate(in_types):
-% if idx == position_order - 1:
-${vertex} \
-% endif
-% for i in range(arrays[idx]):
-% for j in range(self.cols(in_type)):
-% for k in range(self.rows(in_type)):
-${dvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(hvalues)]} \
-% endfor
- \
-% endfor
-% endfor
-% endfor
-% if position_order > len(in_types):
-${vertex}\
-% endif
-
-% endfor
-% endfor
-</%block>
-<%block name="test_commands">\
-% for d in range(len(dvalues)):
-
-% for idx, in_type in enumerate(in_types):
-% for i in range(arrays[idx]):
-uniform ${in_type} expected${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}\
-% for j in range(self.cols(in_type)):
-% for k in range(self.rows(in_type)):
- ${dvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(dvalues)] if in_type.startswith('d') else hvalues[(d + (i * self.cols(in_type) + j) * self.rows(in_type) + k) % len(hvalues)]}\
-% endfor
-% endfor
-
-% 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="regular_shader.vert.mako"/>\
-</%block>
-
diff --git a/generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako b/generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako
deleted file mode 100644
index 49fe2d6..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/regular_shader.vert.mako
+++ /dev/null
@@ -1,19 +0,0 @@
-## coding=utf-8
-<%inherit file="shader.vert.mako"/>\
-<%block name="global_variables">\
-% for idx, in_type in enumerate(in_types):
-uniform ${in_type} expected${idx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''};
-% endfor
-
-% for idx, in_type in enumerate(in_types):
-in ${in_type} value${idx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''};
-% endfor
-</%block>
-<%block name="main">\
-% for idx, in_type in enumerate(in_types):
- if (value${idx} != expected${idx}) {
- fs_color = RED;
- return;
- }
-% endfor
-</%block>
diff --git a/generated_tests/templates/gen_vs_in_fp64/shader.vert.mako b/generated_tests/templates/gen_vs_in_fp64/shader.vert.mako
deleted file mode 100644
index 3f80c71..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/shader.vert.mako
+++ /dev/null
@@ -1,16 +0,0 @@
-## coding=utf-8
-<%inherit file="shader_base.mako"/>\
-<%block name="global_variables"/>\
-
-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);
-<%block name="main"/>\
- fs_color = GREEN;
-}
diff --git a/generated_tests/templates/gen_vs_in_fp64/shader_base.mako b/generated_tests/templates/gen_vs_in_fp64/shader_base.mako
deleted file mode 100644
index a86d5eb..0000000
--- a/generated_tests/templates/gen_vs_in_fp64/shader_base.mako
+++ /dev/null
@@ -1,12 +0,0 @@
-## coding=utf-8
-<%inherit file="base.mako"/>\
-<%
- (glsl_version, glsl_version_int) = self.versioning()
-%>\
-#version ${glsl_version_int}
-% if ver == 'GL_ARB_vertex_attrib_64bit':
-#extension GL_ARB_gpu_shader_fp64 : require
-#extension GL_ARB_vertex_attrib_64bit : require
-% endif
-
-${next.body()}\
--
2.8.3
More information about the Piglit
mailing list