[Piglit] [PATCH 10/21] interpolation-qualifier...: put templates in templates dir

Dylan Baker baker.dylan.c at gmail.com
Mon Nov 24 13:17:29 PST 2014


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/CMakeLists.txt                     |   8 +-
 .../interpolation-qualifier-built-in-variable.py   | 232 ++-------------------
 .../fs-unused.shader_test.mako                     |  35 ++++
 .../fs-vs-unused.shader_test.mako                  |  40 ++++
 .../vs-fs-flip.shader_test.mako                    |  41 ++++
 .../vs-fs.shader_test.mako                         |  34 +++
 .../vs-unused.shader_test.mako                     |  35 ++++
 7 files changed, 215 insertions(+), 210 deletions(-)
 create mode 100644 generated_tests/templates/interpolation-qualifier-built-in-variable/fs-unused.shader_test.mako
 create mode 100644 generated_tests/templates/interpolation-qualifier-built-in-variable/fs-vs-unused.shader_test.mako
 create mode 100644 generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs-flip.shader_test.mako
 create mode 100644 generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs.shader_test.mako
 create mode 100644 generated_tests/templates/interpolation-qualifier-built-in-variable/vs-unused.shader_test.mako

diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index d6187ca..42d63ad 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -84,7 +84,13 @@ piglit_make_generated_tests(
 	generate-cl-relational-builtins.py)
 piglit_make_generated_tests(
 	interpolation-qualifier-built-in-variable.list
-	interpolation-qualifier-built-in-variable.py)
+	interpolation-qualifier-built-in-variable.py
+	templates/interpolation-qualifier-built-in-variable/fs-vs-unused.shader_test.mako
+	templates/interpolation-qualifier-built-in-variable/vs-unused.shader_test.mako
+	templates/interpolation-qualifier-built-in-variable/fs-unused.shader_test.mako
+	templates/interpolation-qualifier-built-in-variable/vs-fs-flip.shader_test.mako
+	templates/interpolation-qualifier-built-in-variable/vs-fs.shader_test.mako
+	)
 piglit_make_generated_tests(
 	texture_lod_tests.list
 	gen_texture_lod_tests.py
diff --git a/generated_tests/interpolation-qualifier-built-in-variable.py b/generated_tests/interpolation-qualifier-built-in-variable.py
index 75e03ea..9b0313a 100644
--- a/generated_tests/interpolation-qualifier-built-in-variable.py
+++ b/generated_tests/interpolation-qualifier-built-in-variable.py
@@ -23,9 +23,10 @@
 
 from __future__ import print_function
 import os
-from textwrap import dedent
 
-from mako.template import Template
+from templates import template_dir
+
+TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
 
 interpolation_modes = [
     'flat',
@@ -60,42 +61,6 @@ vertex_shader_to_fragment_shader_variable_map = {
     'gl_BackSecondaryColor': 'gl_SecondaryColor'
 }
 
-template = Template(dedent("""\
-    # Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
-    #
-    #     "If gl_Color is redeclared with an interpolation qualifier, then
-    #     gl_FrontColor and gl_BackColor (if they are written to) must
-    #     also be redeclared with the same interpolation qualifier, and
-    #     vice versa. If gl_SecondaryColor is redeclared with an
-    #     interpolation qualifier, then gl_FrontSecondaryColor and
-    #     gl_BackSecondaryColor (if they are written to) must also be
-    #     redeclared with the same interpolation qualifier, and vice
-    #     versa. This qualifier matching on predeclared variables is only
-    #     required for variables that are statically used within the
-    #     shaders in a program."
-    #
-    # Even though some of the other rules for interpolation qualifier
-    # matching changed in 4.x specifications, this rule has remained the
-    # same.
-    [require]
-    GLSL >= 1.30
-    
-    [vertex shader]
-    % if vs_mode != 'default':
-    ${vs_mode} out vec4 ${vs_variable};
-    % endif
-    void main() { gl_Position = vec4(0); ${vs_variable} = vec4(0); }
-    
-    [fragment shader]
-    % if fs_mode != 'default':
-    ${fs_mode} in vec4 ${fs_variable};
-    % endif
-    out vec4 c;
-    void main() { c = ${fs_variable}; }
-    
-    [test]
-    link error
-    """))
 
 for fs_mode in interpolation_modes:
     for vs_mode in interpolation_modes:
@@ -118,49 +83,12 @@ for fs_mode in interpolation_modes:
                 os.makedirs(dirname)
 
             with open(filename, 'w') as f:
-                f.write(template.render(
+                f.write(TEMPLATES.get_template('vs-fs.shader_test.mako').render(
                     vs_mode=vs_mode,
                     vs_variable=var,
                     fs_mode=fs_mode,
                     fs_variable=vertex_shader_to_fragment_shader_variable_map[var]))
 
-template = Template(dedent("""\
-    # Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
-    #
-    #     "If gl_Color is redeclared with an interpolation qualifier, then
-    #     gl_FrontColor and gl_BackColor (if they are written to) must
-    #     also be redeclared with the same interpolation qualifier, and
-    #     vice versa. If gl_SecondaryColor is redeclared with an
-    #     interpolation qualifier, then gl_FrontSecondaryColor and
-    #     gl_BackSecondaryColor (if they are written to) must also be
-    #     redeclared with the same interpolation qualifier, and vice
-    #     versa. This qualifier matching on predeclared variables is only
-    #     required for variables that are statically used within the
-    #     shaders in a program."
-    #
-    # Even though some of the other rules for interpolation qualifier
-    # matching changed in 4.x specifications, this rule has remained the
-    # same.
-    #
-    # We interpret the sentence "variables that are statically used within the
-    # shaders in a program" to mean static use of the variable in a shader stage
-    # invokes the redeclaration requirement for that stage only.  This is based on
-    # the additional text "..gl_FrontColor and gl_BackColor (if they are written
-    # to) must also be redeclared with the same interpolation qualifier..."
-    [require]
-    GLSL >= 1.30
-    
-    [vertex shader]
-    ${vs_mode} out vec4 ${vs_variable};
-    void main() { gl_Position = vec4(0); ${vs_variable} = vec4(0); }
-    
-    [fragment shader]
-    out vec4 c;
-    void main() { c = vec4(0); }
-    
-    [test]
-    link success
-    """))
 
 for vs_mode in interpolation_modes:
     if vs_mode == 'default':
@@ -181,46 +109,11 @@ for vs_mode in interpolation_modes:
             os.makedirs(dirname)
 
         with open(filename, 'w') as f:
-            f.write(template.render(vs_mode=vs_mode,
-                                    vs_variable=var))
-
-template = Template(dedent("""\
-    # Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
-    #
-    #     "If gl_Color is redeclared with an interpolation qualifier, then
-    #     gl_FrontColor and gl_BackColor (if they are written to) must
-    #     also be redeclared with the same interpolation qualifier, and
-    #     vice versa. If gl_SecondaryColor is redeclared with an
-    #     interpolation qualifier, then gl_FrontSecondaryColor and
-    #     gl_BackSecondaryColor (if they are written to) must also be
-    #     redeclared with the same interpolation qualifier, and vice
-    #     versa. This qualifier matching on predeclared variables is only
-    #     required for variables that are statically used within the
-    #     shaders in a program."
-    #
-    # Even though some of the other rules for interpolation qualifier
-    # matching changed in 4.x specifications, this rule has remained the
-    # same.
-    #
-    # We interpret the sentence "variables that are statically used within the
-    # shaders in a program" to mean static use of the variable in a shader stage
-    # invokes the redeclaration requirement for that stage only.  This is based on
-    # the additional text "..gl_FrontColor and gl_BackColor (if they are written
-    # to) must also be redeclared with the same interpolation qualifier..."
-    [require]
-    GLSL >= 1.30
-    
-    [vertex shader]
-    void main() { gl_Position = vec4(0); }
-    
-    [fragment shader]
-    ${fs_mode} in vec4 ${fs_variable};
-    out vec4 c;
-    void main() { c = ${fs_variable}; }
-    
-    [test]
-    link success
-    """))
+            f.write(
+                TEMPLATES.get_template('vs-unused.shader_test.mako').render(
+                    vs_mode=vs_mode,
+                    vs_variable=var))
+
 
 for fs_mode in interpolation_modes:
     if fs_mode == 'default':
@@ -242,55 +135,13 @@ for fs_mode in interpolation_modes:
             os.makedirs(dirname)
 
         with open(filename, 'w') as f:
-            f.write(template.render(
+            f.write(TEMPLATES.get_template('fs-unused.shader_test.mako').render(
                 vs_mode=vs_mode,
                 vs_variable=var,
                 fs_mode=fs_mode,
                 fs_variable=vertex_shader_to_fragment_shader_variable_map[var]))
 
 
-template = Template(dedent("""\
-    # Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
-    #
-    #     "If gl_Color is redeclared with an interpolation qualifier, then
-    #     gl_FrontColor and gl_BackColor (if they are written to) must
-    #     also be redeclared with the same interpolation qualifier, and
-    #     vice versa. If gl_SecondaryColor is redeclared with an
-    #     interpolation qualifier, then gl_FrontSecondaryColor and
-    #     gl_BackSecondaryColor (if they are written to) must also be
-    #     redeclared with the same interpolation qualifier, and vice
-    #     versa. This qualifier matching on predeclared variables is only
-    #     required for variables that are statically used within the
-    #     shaders in a program."
-    #
-    # Even though some of the other rules for interpolation qualifier
-    # matching changed in 4.x specifications, this rule has remained the
-    # same.
-    #
-    # We interpret the sentence "variables that are statically used within the
-    # shaders in a program" to mean static use of the variable in any shader in
-    # the program invokes the redeclaration requirement.  Since neither shader
-    # accesses any built-in variables, linking should succeed no matter what the
-    # interpolation qualifiers say.
-    [require]
-    GLSL >= 1.30
-    
-    [vertex shader]
-    % if vs_mode != 'default':
-    ${vs_mode} out vec4 ${vs_variable};
-    % endif
-    void main() { gl_Position = vec4(0); }
-    
-    [fragment shader]
-    % if fs_mode != 'default':
-    ${fs_mode} in vec4 ${fs_variable};
-    % endif
-    out vec4 c;
-    void main() { c = vec4(0); }
-    
-    [test]
-    link success
-    """))
 
 for fs_mode in interpolation_modes:
     for vs_mode in interpolation_modes:
@@ -313,52 +164,14 @@ for fs_mode in interpolation_modes:
                 os.makedirs(dirname)
 
             with open(filename, 'w') as f:
-                f.write(template.render(
-                    vs_mode=vs_mode,
-                    vs_variable=var,
-                    fs_mode=fs_mode,
-                    fs_variable=vertex_shader_to_fragment_shader_variable_map[var]))
+                f.write(TEMPLATES.get_template(
+                    'fs-vs-unused.shader_test.mako').render(
+                        vs_mode=vs_mode,
+                        vs_variable=var,
+                        fs_mode=fs_mode,
+                        fs_variable=vertex_shader_to_fragment_shader_variable_map[var]))
 
 
-template = Template(dedent("""\
-    # Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
-    #
-    #     "If gl_Color is redeclared with an interpolation qualifier, then
-    #     gl_FrontColor and gl_BackColor (if they are written to) must
-    #     also be redeclared with the same interpolation qualifier, and
-    #     vice versa. If gl_SecondaryColor is redeclared with an
-    #     interpolation qualifier, then gl_FrontSecondaryColor and
-    #     gl_BackSecondaryColor (if they are written to) must also be
-    #     redeclared with the same interpolation qualifier, and vice
-    #     versa. This qualifier matching on predeclared variables is only
-    #     required for variables that are statically used within the
-    #     shaders in a program."
-    #
-    # Even though some of the other rules for interpolation qualifier
-    # matching changed in 4.x specifications, this rule has remained the
-    # same.
-    [require]
-    GLSL >= 1.30
-    
-    [vertex shader]
-    % if fs_mode != 'default':
-    ${fs_mode} out vec4 ${this_side_variable};
-    % endif
-    % if vs_mode != 'default':
-    ${vs_mode} out vec4 ${other_side_variable};
-    % endif
-    void main() { gl_Position = vec4(0); ${this_side_variable} = vec4(0); ${other_side_variable} = vec4(1); }
-    
-    [fragment shader]
-    % if fs_mode != 'default':
-    ${fs_mode} in vec4 ${fs_variable};
-    % endif
-    out vec4 c;
-    void main() { c = ${fs_variable}; }
-    
-    [test]
-    link error
-    """))
 
 for fs_mode in interpolation_modes:
     for vs_mode in interpolation_modes:
@@ -381,9 +194,10 @@ for fs_mode in interpolation_modes:
                 os.makedirs(dirname)
 
             with open(filename, 'w') as f:
-                f.write(template.render(
-                    vs_mode=vs_mode,
-                    this_side_variable=this_side,
-                    other_side_variable=other_side,
-                    fs_mode=fs_mode,
-                    fs_variable=vertex_shader_to_fragment_shader_variable_map[this_side]))
+                f.write(TEMPLATES.get_template(
+                    'vs-fs-flip.shader_test.mako').render(
+                        vs_mode=vs_mode,
+                        this_side_variable=this_side,
+                        other_side_variable=other_side,
+                        fs_mode=fs_mode,
+                        fs_variable=vertex_shader_to_fragment_shader_variable_map[this_side]))
diff --git a/generated_tests/templates/interpolation-qualifier-built-in-variable/fs-unused.shader_test.mako b/generated_tests/templates/interpolation-qualifier-built-in-variable/fs-unused.shader_test.mako
new file mode 100644
index 0000000..9edcc00
--- /dev/null
+++ b/generated_tests/templates/interpolation-qualifier-built-in-variable/fs-unused.shader_test.mako
@@ -0,0 +1,35 @@
+# Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
+#
+#     "If gl_Color is redeclared with an interpolation qualifier, then
+#     gl_FrontColor and gl_BackColor (if they are written to) must
+#     also be redeclared with the same interpolation qualifier, and
+#     vice versa. If gl_SecondaryColor is redeclared with an
+#     interpolation qualifier, then gl_FrontSecondaryColor and
+#     gl_BackSecondaryColor (if they are written to) must also be
+#     redeclared with the same interpolation qualifier, and vice
+#     versa. This qualifier matching on predeclared variables is only
+#     required for variables that are statically used within the
+#     shaders in a program."
+#
+# Even though some of the other rules for interpolation qualifier
+# matching changed in 4.x specifications, this rule has remained the
+# same.
+#
+# We interpret the sentence "variables that are statically used within the
+# shaders in a program" to mean static use of the variable in a shader stage
+# invokes the redeclaration requirement for that stage only.  This is based on
+# the additional text "..gl_FrontColor and gl_BackColor (if they are written
+# to) must also be redeclared with the same interpolation qualifier..."
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+void main() { gl_Position = vec4(0); }
+
+[fragment shader]
+${fs_mode} in vec4 ${fs_variable};
+out vec4 c;
+void main() { c = ${fs_variable}; }
+
+[test]
+link success
diff --git a/generated_tests/templates/interpolation-qualifier-built-in-variable/fs-vs-unused.shader_test.mako b/generated_tests/templates/interpolation-qualifier-built-in-variable/fs-vs-unused.shader_test.mako
new file mode 100644
index 0000000..81e2240
--- /dev/null
+++ b/generated_tests/templates/interpolation-qualifier-built-in-variable/fs-vs-unused.shader_test.mako
@@ -0,0 +1,40 @@
+# Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
+#
+#     "If gl_Color is redeclared with an interpolation qualifier, then
+#     gl_FrontColor and gl_BackColor (if they are written to) must
+#     also be redeclared with the same interpolation qualifier, and
+#     vice versa. If gl_SecondaryColor is redeclared with an
+#     interpolation qualifier, then gl_FrontSecondaryColor and
+#     gl_BackSecondaryColor (if they are written to) must also be
+#     redeclared with the same interpolation qualifier, and vice
+#     versa. This qualifier matching on predeclared variables is only
+#     required for variables that are statically used within the
+#     shaders in a program."
+#
+# Even though some of the other rules for interpolation qualifier
+# matching changed in 4.x specifications, this rule has remained the
+# same.
+#
+# We interpret the sentence "variables that are statically used within the
+# shaders in a program" to mean static use of the variable in any shader in
+# the program invokes the redeclaration requirement.  Since neither shader
+# accesses any built-in variables, linking should succeed no matter what the
+# interpolation qualifiers say.
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+% if vs_mode != 'default':
+${vs_mode} out vec4 ${vs_variable};
+% endif
+void main() { gl_Position = vec4(0); }
+
+[fragment shader]
+% if fs_mode != 'default':
+${fs_mode} in vec4 ${fs_variable};
+% endif
+out vec4 c;
+void main() { c = vec4(0); }
+
+[test]
+link success
diff --git a/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs-flip.shader_test.mako b/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs-flip.shader_test.mako
new file mode 100644
index 0000000..719216c
--- /dev/null
+++ b/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs-flip.shader_test.mako
@@ -0,0 +1,41 @@
+# Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
+#
+#     "If gl_Color is redeclared with an interpolation qualifier, then
+#     gl_FrontColor and gl_BackColor (if they are written to) must
+#     also be redeclared with the same interpolation qualifier, and
+#     vice versa. If gl_SecondaryColor is redeclared with an
+#     interpolation qualifier, then gl_FrontSecondaryColor and
+#     gl_BackSecondaryColor (if they are written to) must also be
+#     redeclared with the same interpolation qualifier, and vice
+#     versa. This qualifier matching on predeclared variables is only
+#     required for variables that are statically used within the
+#     shaders in a program."
+#
+# Even though some of the other rules for interpolation qualifier
+# matching changed in 4.x specifications, this rule has remained the
+# same.
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+% if fs_mode != 'default':
+${fs_mode} out vec4 ${this_side_variable};
+% endif
+% if vs_mode != 'default':
+${vs_mode} out vec4 ${other_side_variable};
+% endif
+void main() {
+    gl_Position = vec4(0);
+    ${this_side_variable} = vec4(0);
+    ${other_side_variable} = vec4(1);
+}
+
+[fragment shader]
+% if fs_mode != 'default':
+${fs_mode} in vec4 ${fs_variable};
+% endif
+out vec4 c;
+void main() { c = ${fs_variable}; }
+
+[test]
+link error
diff --git a/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs.shader_test.mako b/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs.shader_test.mako
new file mode 100644
index 0000000..953b457
--- /dev/null
+++ b/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-fs.shader_test.mako
@@ -0,0 +1,34 @@
+# Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
+#
+#     "If gl_Color is redeclared with an interpolation qualifier, then
+#     gl_FrontColor and gl_BackColor (if they are written to) must
+#     also be redeclared with the same interpolation qualifier, and
+#     vice versa. If gl_SecondaryColor is redeclared with an
+#     interpolation qualifier, then gl_FrontSecondaryColor and
+#     gl_BackSecondaryColor (if they are written to) must also be
+#     redeclared with the same interpolation qualifier, and vice
+#     versa. This qualifier matching on predeclared variables is only
+#     required for variables that are statically used within the
+#     shaders in a program."
+#
+# Even though some of the other rules for interpolation qualifier
+# matching changed in 4.x specifications, this rule has remained the
+# same.
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+% if vs_mode != 'default':
+${vs_mode} out vec4 ${vs_variable};
+% endif
+void main() { gl_Position = vec4(0); ${vs_variable} = vec4(0); }
+
+[fragment shader]
+% if fs_mode != 'default':
+${fs_mode} in vec4 ${fs_variable};
+% endif
+out vec4 c;
+void main() { c = ${fs_variable}; }
+
+[test]
+link error
diff --git a/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-unused.shader_test.mako b/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-unused.shader_test.mako
new file mode 100644
index 0000000..a9dda69
--- /dev/null
+++ b/generated_tests/templates/interpolation-qualifier-built-in-variable/vs-unused.shader_test.mako
@@ -0,0 +1,35 @@
+# Section 4.3.7 (Interpolation) of the GLSL 1.30 spec says:
+#
+#     "If gl_Color is redeclared with an interpolation qualifier, then
+#     gl_FrontColor and gl_BackColor (if they are written to) must
+#     also be redeclared with the same interpolation qualifier, and
+#     vice versa. If gl_SecondaryColor is redeclared with an
+#     interpolation qualifier, then gl_FrontSecondaryColor and
+#     gl_BackSecondaryColor (if they are written to) must also be
+#     redeclared with the same interpolation qualifier, and vice
+#     versa. This qualifier matching on predeclared variables is only
+#     required for variables that are statically used within the
+#     shaders in a program."
+#
+# Even though some of the other rules for interpolation qualifier
+# matching changed in 4.x specifications, this rule has remained the
+# same.
+#
+# We interpret the sentence "variables that are statically used within the
+# shaders in a program" to mean static use of the variable in a shader stage
+# invokes the redeclaration requirement for that stage only.  This is based on
+# the additional text "..gl_FrontColor and gl_BackColor (if they are written
+# to) must also be redeclared with the same interpolation qualifier..."
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+${vs_mode} out vec4 ${vs_variable};
+void main() { gl_Position = vec4(0); ${vs_variable} = vec4(0); }
+
+[fragment shader]
+out vec4 c;
+void main() { c = vec4(0); }
+
+[test]
+link success
-- 
2.1.3



More information about the Piglit mailing list