[Piglit] [PATCH 38/45] gen_interpolation_tests.py: put template in templates dir

Dylan Baker baker.dylan.c at gmail.com
Wed Nov 12 15:46:20 PST 2014


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/CMakeLists.txt                     |  4 +-
 generated_tests/gen_interpolation_tests.py         | 85 ++--------------------
 .../template.shader_test.mako                      | 74 +++++++++++++++++++
 3 files changed, 82 insertions(+), 81 deletions(-)
 create mode 100644 generated_tests/templates/gen_interpolation_tests/template.shader_test.mako

diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 55b718e..a59c54a 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -37,7 +37,9 @@ piglit_make_generated_tests(
 	)
 piglit_make_generated_tests(
 	interpolation_tests.list
-	gen_interpolation_tests.py)
+	gen_interpolation_tests.py
+	templates/gen_interpolation_tests/template.shader_test.mako
+	)
 piglit_make_generated_tests(
 	non-lvalue_tests.list
 	gen_non-lvalue_tests.py
diff --git a/generated_tests/gen_interpolation_tests.py b/generated_tests/gen_interpolation_tests.py
index b912e67..4f1428b 100644
--- a/generated_tests/gen_interpolation_tests.py
+++ b/generated_tests/gen_interpolation_tests.py
@@ -69,86 +69,11 @@ This program outputs, to stdout, the name of each file it generates.
 
 from __future__ import print_function
 import os
-import textwrap
-
-from mako.template import Template
-
-TEMPLATE = Template(textwrap.dedent("""\
-%if args.builtin_variable:
-# Test proper interpolation of ${args.vs_variable}
-%else:
-# Test proper interpolation of a non-built-in variable
-%endif
-%if args.interpolation_qualifier:
-# When qualified with ${args.interpolation_qualifier}
-%else:
-# When no interpolation qualifier present
-%endif
-# And ShadeModel is ${args.shade_model}
-%if args.clipping == 'fixed':
-# And clipping via fixed planes
-%elif args.clipping == 'vertex':
-# And clipping via gl_ClipVertex
-%elif args.clipping == 'distance':
-# And clipping via gl_ClipDistance
-%endif
-
-[require]
-GLSL >= ${args.glsl_version}
-
-[vertex shader]
-${args.vs_input} vec4 vertex;
-${args.vs_input} vec4 input_data;
-% if args.interpolation_qualifier or not args.builtin_variable:
-${args.interpolation_qualifier} ${args.vs_output} vec4 ${args.vs_variable};
-% endif
-
-void main()
-{
-    gl_Position = gl_ModelViewProjectionMatrix * vertex;
-    ${args.vs_variable} = input_data;
-  %if args.clipping == 'distance':
-    gl_ClipDistance[0] = -1.75 - vertex.z;
-  %elif args.clipping == 'vertex':
-    gl_ClipVertex = vertex;
-  %endif
-}
-
-[fragment shader]
-% if args.interpolation_qualifier or not args.builtin_variable:
-${args.interpolation_qualifier} ${args.fs_input} vec4 ${args.fs_variable};
-% endif
-
-void main()
-{
-    gl_FragColor = ${args.fs_variable};
-}
-
-[vertex data]
-% for v in args.vertex_data():
-${v}
-% endfor
-
-[test]
-frustum -${args.frustum_near} ${args.frustum_near} -${args.frustum_near} ${args.frustum_near} ${args.frustum_near} ${args.frustum_far}
-clear color 0.0 0.0 0.0 0.0
-clear
-enable GL_VERTEX_PROGRAM_TWO_SIDE
-shade model ${args.shade_model}
-
-% if args.clipping == 'distance':
-enable GL_CLIP_PLANE0
-% elif args.clipping == 'vertex':
-enable GL_CLIP_PLANE0
-clip plane 0 0.0 0.0 -1.0 -1.75
-% endif
-
-draw arrays GL_TRIANGLES 0 3
-
-% for x, y, r, g, b, a in args.probe_data():
-relative probe rgba (${x}, ${y}) (${r}, ${g}, ${b}, ${a})
-% endfor
-"""))
+
+from templates import template_file
+
+TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]),
+                         'template.shader_test.mako')
 
 
 class Test(object):
diff --git a/generated_tests/templates/gen_interpolation_tests/template.shader_test.mako b/generated_tests/templates/gen_interpolation_tests/template.shader_test.mako
new file mode 100644
index 0000000..aa830b4
--- /dev/null
+++ b/generated_tests/templates/gen_interpolation_tests/template.shader_test.mako
@@ -0,0 +1,74 @@
+%if args.builtin_variable:
+# Test proper interpolation of ${args.vs_variable}
+%else:
+# Test proper interpolation of a non-built-in variable
+%endif
+%if args.interpolation_qualifier:
+# When qualified with ${args.interpolation_qualifier}
+%else:
+# When no interpolation qualifier present
+%endif
+# And ShadeModel is ${args.shade_model}
+%if args.clipping == 'fixed':
+# And clipping via fixed planes
+%elif args.clipping == 'vertex':
+# And clipping via gl_ClipVertex
+%elif args.clipping == 'distance':
+# And clipping via gl_ClipDistance
+%endif
+
+[require]
+GLSL >= ${args.glsl_version}
+
+[vertex shader]
+${args.vs_input} vec4 vertex;
+${args.vs_input} vec4 input_data;
+% if args.interpolation_qualifier or not args.builtin_variable:
+${args.interpolation_qualifier} ${args.vs_output} vec4 ${args.vs_variable};
+% endif
+
+void main()
+{
+    gl_Position = gl_ModelViewProjectionMatrix * vertex;
+    ${args.vs_variable} = input_data;
+  %if args.clipping == 'distance':
+    gl_ClipDistance[0] = -1.75 - vertex.z;
+  %elif args.clipping == 'vertex':
+    gl_ClipVertex = vertex;
+  %endif
+}
+
+[fragment shader]
+% if args.interpolation_qualifier or not args.builtin_variable:
+${args.interpolation_qualifier} ${args.fs_input} vec4 ${args.fs_variable};
+% endif
+
+void main()
+{
+    gl_FragColor = ${args.fs_variable};
+}
+
+[vertex data]
+% for v in args.vertex_data():
+${v}
+% endfor
+
+[test]
+frustum -${args.frustum_near} ${args.frustum_near} -${args.frustum_near} ${args.frustum_near} ${args.frustum_near} ${args.frustum_far}
+clear color 0.0 0.0 0.0 0.0
+clear
+enable GL_VERTEX_PROGRAM_TWO_SIDE
+shade model ${args.shade_model}
+
+% if args.clipping == 'distance':
+enable GL_CLIP_PLANE0
+% elif args.clipping == 'vertex':
+enable GL_CLIP_PLANE0
+clip plane 0 0.0 0.0 -1.0 -1.75
+% endif
+
+draw arrays GL_TRIANGLES 0 3
+
+% for x, y, r, g, b, a in args.probe_data():
+relative probe rgba (${x}, ${y}) (${r}, ${g}, ${b}, ${a})
+% endfor
-- 
2.1.3



More information about the Piglit mailing list