[Piglit] [RESEND RFC 15/25] gen_tcs_input_tests.py: use textwrap.dedent

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Wed Oct 21 10:20:24 PDT 2015


From: Dylan Baker <baker.dylan.c at gmail.com>

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/gen_tcs_input_tests.py | 191 +++++++++++++++++----------------
 1 file changed, 96 insertions(+), 95 deletions(-)

diff --git a/generated_tests/gen_tcs_input_tests.py b/generated_tests/gen_tcs_input_tests.py
index 9e761af..535074a 100644
--- a/generated_tests/gen_tcs_input_tests.py
+++ b/generated_tests/gen_tcs_input_tests.py
@@ -41,6 +41,7 @@ from __future__ import print_function, division, absolute_import
 import os
 import sys
 import random
+import textwrap
 
 from six.moves import range
 
@@ -178,101 +179,101 @@ class Test(object):
 
     def generate(self):
         """Generates and writes the test to disc."""
-        test = \
-"""# Test generated by:
-# {generator_command}
-# Test tessellation control shader inputs
-[require]
-GLSL >= 1.50
-GL_ARB_tessellation_shader
-
-[vertex shader]
-uniform struct S0 {{
-        {self.var_type_full} v;
-}} reference[12];
-
-out {self.interface_name} {{
-        {self.var_type_full} {self.var_name};
-}} {self.interface_vs_instance};
-
-void main()
-{{
-        {self.interface_vs_instance}{self.vs_var_ref} = reference[gl_VertexID].v;
-}}
-
-[tessellation control shader]
-#extension GL_ARB_tessellation_shader : require
-layout(vertices = 3) out;
-
-uniform struct S0 {{
-        {self.var_type_full} v;
-}} reference[12];
-
-in {self.interface_name} {{
-        {self.var_type_full} {self.var_name};
-}} {self.interface_tcs_instance}[];
-
-out int pass[];
-
-void main()
-{{
-        const int vertices_in = 3;
-        int local_pass = 1;
-        for (int i = 0; i < vertices_in; ++i) {{
-                int vertex_ID = gl_PrimitiveID * vertices_in + i;
-                if ({self.interface_tcs_instance}[i]{self.tcs_var_ref} != reference[vertex_ID].v)
-                        local_pass = 0;
-        }}
-        pass[gl_InvocationID] = local_pass;
-        gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
-        gl_TessLevelInner = float[2](1.0, 1.0);
-}}
-
-[tessellation evaluation shader]
-#extension GL_ARB_tessellation_shader : require
-layout(quads) in;
-
-in int pass[];
-
-out vec4 vert_color;
-
-void main()
-{{
-        const vec4 red = vec4(1, 0, 0, 1);
-        const vec4 green = vec4(0, 1, 0, 1);
-        vec2[3] position = vec2[3](
-                vec2(float(gl_PrimitiveID / 2) - 1.0, float(gl_PrimitiveID % 2) - 1.0),
-                vec2(float(gl_PrimitiveID / 2) - 0.0, float(gl_PrimitiveID % 2) - 1.0),
-                vec2(float(gl_PrimitiveID / 2) - 1.0, float(gl_PrimitiveID % 2) - 0.0)
-        );
-        gl_Position = vec4(position[0]
-                    + (position[1] - position[0]) * gl_TessCoord[0]
-                    + (position[2] - position[0]) * gl_TessCoord[1], 0.0, 1.0);
-        vert_color = green;
-        if (pass[0] == 0 || pass[1] == 0 || pass[2] == 0) {{
-                vert_color = red;
-        }}
-}}
-
-[fragment shader]
-
-in vec4 vert_color;
-
-out vec4 frag_color;
-
-void main()
-{{
-        frag_color = vert_color;
-}}
-
-[test]
-{self.uniform_string}
-draw arrays GL_PATCHES 0 12
-relative probe rgb (0.25, 0.25) (0.0, 1.0, 0.0)
-relative probe rgb (0.75, 0.25) (0.0, 1.0, 0.0)
-relative probe rgb (0.25, 0.75) (0.0, 1.0, 0.0)
-relative probe rgb (0.75, 0.75) (0.0, 1.0, 0.0)
-"""
+        test = textwrap.dedent("""\
+            # Test generated by:
+            # {generator_command}
+            # Test tessellation control shader inputs
+            [require]
+            GLSL >= 1.50
+            GL_ARB_tessellation_shader
+
+            [vertex shader]
+            uniform struct S0 {{
+                    {self.var_type_full} v;
+            }} reference[12];
+
+            out {self.interface_name} {{
+                    {self.var_type_full} {self.var_name};
+            }} {self.interface_vs_instance};
+
+            void main()
+            {{
+                    {self.interface_vs_instance}{self.vs_var_ref} = reference[gl_VertexID].v;
+            }}
+
+            [tessellation control shader]
+            #extension GL_ARB_tessellation_shader : require
+            layout(vertices = 3) out;
+
+            uniform struct S0 {{
+                    {self.var_type_full} v;
+            }} reference[12];
+
+            in {self.interface_name} {{
+                    {self.var_type_full} {self.var_name};
+            }} {self.interface_tcs_instance}[];
+
+            out int pass[];
+
+            void main()
+            {{
+                    const int vertices_in = 3;
+                    int local_pass = 1;
+                    for (int i = 0; i < vertices_in; ++i) {{
+                            int vertex_ID = gl_PrimitiveID * vertices_in + i;
+                            if ({self.interface_tcs_instance}[i]{self.tcs_var_ref} != reference[vertex_ID].v)
+                                    local_pass = 0;
+                    }}
+                    pass[gl_InvocationID] = local_pass;
+                    gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
+                    gl_TessLevelInner = float[2](1.0, 1.0);
+            }}
+
+            [tessellation evaluation shader]
+            #extension GL_ARB_tessellation_shader : require
+            layout(quads) in;
+
+            in int pass[];
+
+            out vec4 vert_color;
+
+            void main()
+            {{
+                    const vec4 red = vec4(1, 0, 0, 1);
+                    const vec4 green = vec4(0, 1, 0, 1);
+                    vec2[3] position = vec2[3](
+                            vec2(float(gl_PrimitiveID / 2) - 1.0, float(gl_PrimitiveID % 2) - 1.0),
+                            vec2(float(gl_PrimitiveID / 2) - 0.0, float(gl_PrimitiveID % 2) - 1.0),
+                            vec2(float(gl_PrimitiveID / 2) - 1.0, float(gl_PrimitiveID % 2) - 0.0)
+                    );
+                    gl_Position = vec4(position[0]
+                                + (position[1] - position[0]) * gl_TessCoord[0]
+                                + (position[2] - position[0]) * gl_TessCoord[1], 0.0, 1.0);
+                    vert_color = green;
+                    if (pass[0] == 0 || pass[1] == 0 || pass[2] == 0) {{
+                            vert_color = red;
+                    }}
+            }}
+
+            [fragment shader]
+
+            in vec4 vert_color;
+
+            out vec4 frag_color;
+
+            void main()
+            {{
+                    frag_color = vert_color;
+            }}
+
+            [test]
+            {self.uniform_string}
+            draw arrays GL_PATCHES 0 12
+            relative probe rgb (0.25, 0.25) (0.0, 1.0, 0.0)
+            relative probe rgb (0.75, 0.25) (0.0, 1.0, 0.0)
+            relative probe rgb (0.25, 0.75) (0.0, 1.0, 0.0)
+            relative probe rgb (0.75, 0.75) (0.0, 1.0, 0.0)
+            """)
 
         test = test.format(self=self, generator_command=" ".join(sys.argv))
 
-- 
2.6.1



More information about the Piglit mailing list