[Piglit] [PATCH 13/24] gen_texture_query_lod_tests.py: Use if __name__ == __main__ pattern

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


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/gen_texture_query_lod_tests.py | 77 ++++++++++++++------------
 1 file changed, 42 insertions(+), 35 deletions(-)

diff --git a/generated_tests/gen_texture_query_lod_tests.py b/generated_tests/gen_texture_query_lod_tests.py
index d5dd315..00eb007 100644
--- a/generated_tests/gen_texture_query_lod_tests.py
+++ b/generated_tests/gen_texture_query_lod_tests.py
@@ -105,43 +105,50 @@ TEMPLATE = Template(dedent("""\
     void main()
     {
         % if execution_stage == 'fs':
-        gl_FragColor.xy = textureQuery${Lod}(s, coord);
+        gl_FragColor.xy = textureQuery${lod}(s, coord);
         % else:
-        gl_Position.xy = textureQuery${Lod}(s, coord);
+        gl_Position.xy = textureQuery${lod}(s, coord);
         % endif
     }
 """))
 
-for api, requirement in REQUIREMENTS.iteritems():
-    Lod = 'Lod' if api == 'glsl-4.00' else 'LOD'
-
-    for sampler_type, coord_type in SAMPLER_TYPE_TO_COORD_TYPE.iteritems():
-        for execution_stage in ("vs", "fs"):
-            file_extension = 'frag' if execution_stage == 'fs' else 'vert'
-            filename = os.path.join(
-                "spec", api.lower(), "compiler", "built-in-functions",
-                "textureQuery{0}-{1}.{2}".format(Lod, sampler_type,
-                                                 file_extension))
-            print(filename)
-
-            dirname = os.path.dirname(filename)
-            if not os.path.exists(dirname):
-                os.makedirs(dirname)
-
-            version = requirement['version']
-            extensions = [requirement['extension']] if requirement['extension'] else []
-
-            # samplerCubeArray types are part GLSL 4.00
-            # or GL_ARB_texture_cube_map_array.
-            if api == "ARB_texture_query_lod" and sampler_type in [
-                    'samplerCubeArray', 'isamplerCubeArray',
-                    'usamplerCubeArray', 'samplerCubeArrayShadow']:
-                extensions += ['GL_ARB_texture_cube_map_array']
-
-            with open(filename, "w") as f:
-                f.write(TEMPLATE.render(version=version,
-                                        extensions=extensions,
-                                        execution_stage=execution_stage,
-                                        sampler_type=sampler_type,
-                                        coord_type=coord_type,
-                                        Lod=Lod))
+
+def main():
+    """Main function."""
+    for api, requirement in REQUIREMENTS.iteritems():
+        lod = 'Lod' if api == 'glsl-4.00' else 'LOD'
+
+        for sampler_type, coord_type in SAMPLER_TYPE_TO_COORD_TYPE.iteritems():
+            for execution_stage in ("vs", "fs"):
+                file_extension = 'frag' if execution_stage == 'fs' else 'vert'
+                filename = os.path.join(
+                    "spec", api.lower(), "compiler", "built-in-functions",
+                    "textureQuery{0}-{1}.{2}".format(lod, sampler_type,
+                                                     file_extension))
+                print(filename)
+
+                dirname = os.path.dirname(filename)
+                if not os.path.exists(dirname):
+                    os.makedirs(dirname)
+
+                version = requirement['version']
+                extensions = [requirement['extension']] if requirement['extension'] else []
+
+                # samplerCubeArray types are part GLSL 4.00
+                # or GL_ARB_texture_cube_map_array.
+                if api == "ARB_texture_query_lod" and sampler_type in [
+                        'samplerCubeArray', 'isamplerCubeArray',
+                        'usamplerCubeArray', 'samplerCubeArrayShadow']:
+                    extensions += ['GL_ARB_texture_cube_map_array']
+
+                with open(filename, "w") as f:
+                    f.write(TEMPLATE.render(version=version,
+                                            extensions=extensions,
+                                            execution_stage=execution_stage,
+                                            sampler_type=sampler_type,
+                                            coord_type=coord_type,
+                                            lod=lod))
+
+
+if __name__ == '__main__':
+    main()
-- 
2.1.3



More information about the Piglit mailing list