[Piglit] [PATCH 4/4] Autogenerate get_enum_name functions from gl.xml.

Fabian Bieler fabianbieler at fastmail.fm
Sat Feb 22 01:02:26 PST 2014


Previously the functions where hand-written and lacked some enums.

Signed-off-by: Fabian Bieler <fabianbieler at fastmail.fm>
---
As nobody likes their inbox filled with 3000 lines of deleted case statements,
the full patch is zipped and attached.
The patch below is a truncated. Only CASE lines like
-	CASE(GL_ZERO)	// 0x0000
were removed.
 CMakeLists.txt                      |    1 +
 cmake/piglit_get_enum.cmake         |   50 +
 cmake/piglit_util.cmake             |   23 +
 tests/util/.gitignore               |    3 +
 tests/util/CMakeLists.gles1.txt     |    2 +-
 tests/util/CMakeLists.gles2.txt     |    2 +-
 tests/util/CMakeLists.gles3.txt     |    2 +-
 tests/util/gen-get-enum.py          |  285 ++++
 tests/util/piglit-util-gl-enum.c    | 3008 +----------------------------------
 tests/util/piglit-util-gles1-enum.c |   27 +
 tests/util/piglit-util-gles2-enum.c |   27 +
 tests/util/piglit-util-gles3-enum.c |  728 ---------
 12 files changed, 420 insertions(+), 3738 deletions(-)
 create mode 100644 cmake/piglit_get_enum.cmake
 create mode 100644 tests/util/gen-get-enum.py
 create mode 100644 tests/util/piglit-util-gles1-enum.c
 create mode 100644 tests/util/piglit-util-gles2-enum.c
 delete mode 100644 tests/util/piglit-util-gles3-enum.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 68a19b8..eede93c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -377,6 +377,7 @@ configure_file(
 
 include(cmake/piglit_util.cmake)
 include(cmake/piglit_dispatch.cmake)
+include(cmake/piglit_get_enum.cmake)
 
 include_directories(src)
 add_subdirectory(cmake/target_api)
diff --git a/cmake/piglit_get_enum.cmake b/cmake/piglit_get_enum.cmake
new file mode 100644
index 0000000..78d6b14
--- /dev/null
+++ b/cmake/piglit_get_enum.cmake
@@ -0,0 +1,50 @@
+# Copyright 2014 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 (including the next
+# paragraph) 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.
+
+set(piglit_get_enum_gen_output_dir ${CMAKE_BINARY_DIR}/tests/util)
+
+file(MAKE_DIRECTORY ${piglit_get_enum_gen_output_dir})
+
+set(piglit_get_enum_gen_inputs
+	${CMAKE_SOURCE_DIR}/tests/util/gen-get-enum.py
+	${CMAKE_SOURCE_DIR}/glapi/gl.xml
+	)
+
+set(piglit_get_enum_gen_outputs)
+foreach(api "gl" "gles1" "gles2")
+	set(output ${piglit_get_enum_gen_output_dir}/generated-get-enum-${api}.c)
+	list(APPEND piglit_get_enum_gen_outputs ${output})
+	add_custom_command(
+		OUTPUT ${output}
+		DEPENDS ${piglit_get_enum_gen_inputs}
+		COMMAND ${python} ${piglit_get_enum_gen_inputs} ${output} ${api}
+	)
+
+	add_custom_target(
+		piglit_get_enum_gen_${api}
+		DEPENDS ${output}
+		)
+endforeach()
+
+add_custom_target(
+	piglit_get_enum_gen
+	DEPENDS ${piglit_get_enum_gen_outputs}
+	)
diff --git a/cmake/piglit_util.cmake b/cmake/piglit_util.cmake
index d3cab44..e7f70e5 100644
--- a/cmake/piglit_util.cmake
+++ b/cmake/piglit_util.cmake
@@ -49,6 +49,27 @@ function(piglit_include_target_api)
 endfunction(piglit_include_target_api)
 
 #
+# function piglit_add_depend_get_enum
+#
+# Add dependency for the generated get_enum functions for the apropriate
+# target.
+#
+function(piglit_add_depend_get_enum name)
+
+    if(piglit_target_api STREQUAL "gl")
+        add_dependencies(${name} piglit_get_enum_gen_gl)
+    elseif(piglit_target_api STREQUAL "gles1")
+        add_dependencies(${name} piglit_get_enum_gen_gles1)
+    elseif(piglit_target_api STREQUAL "gles2")
+        add_dependencies(${name} piglit_get_enum_gen_gles2)
+    elseif(piglit_target_api STREQUAL "gles3")
+        # gles3 and 2 are compatible apis, so they use the same function here.
+        add_dependencies(${name} piglit_get_enum_gen_gles2)
+    endif()
+
+endfunction(piglit_add_depend_get_enum)
+
+#
 # function piglit_add_executable
 #
 # This function wraps `add_executable` and has the same signature.
@@ -61,6 +82,7 @@ function(piglit_add_executable name)
     list(REMOVE_AT ARGV 0)
     add_executable(${name} ${ARGV})
     add_dependencies(${name} piglit_dispatch_gen)
+    piglit_add_depend_get_enum(${name})
 
     install(TARGETS ${name} DESTINATION bin)
 
@@ -84,5 +106,6 @@ function(piglit_add_library name)
         install(TARGETS ${name} DESTINATION lib)
     endif(WIN32)
     add_dependencies(${name} piglit_dispatch_gen)
+    piglit_add_depend_get_enum(${name})
 
 endfunction(piglit_add_library)
diff --git a/tests/util/.gitignore b/tests/util/.gitignore
index 8fbd235..dce73dc 100644
--- a/tests/util/.gitignore
+++ b/tests/util/.gitignore
@@ -1,3 +1,6 @@
 config.h
 generated_dispatch.c
 generated_dispatch.h
+generated-get-enum-gl.c
+generated-get-enum-gles1.c
+generated-get-enum-gles2.c
diff --git a/tests/util/CMakeLists.gles1.txt b/tests/util/CMakeLists.gles1.txt
index 58cc67a..dd1f4a2 100644
--- a/tests/util/CMakeLists.gles1.txt
+++ b/tests/util/CMakeLists.gles1.txt
@@ -1,6 +1,6 @@
 set(UTIL_GL_SOURCES
 	${UTIL_GL_SOURCES}
-	piglit-util-gl-enum.c
+	piglit-util-gles1-enum.c
 	piglit-util-gles.c
 	)
 
diff --git a/tests/util/CMakeLists.gles2.txt b/tests/util/CMakeLists.gles2.txt
index d2501e3..9df57dc 100644
--- a/tests/util/CMakeLists.gles2.txt
+++ b/tests/util/CMakeLists.gles2.txt
@@ -5,7 +5,7 @@ set(UTIL_GL_SOURCES
 	piglit-dispatch-init.c
 	piglit-shader.c
 	piglit-shader-gles2.c
-	piglit-util-gl-enum.c
+	piglit-util-gles2-enum.c
 	piglit-util-gles.c
 	minmax-test.c
 	)
diff --git a/tests/util/CMakeLists.gles3.txt b/tests/util/CMakeLists.gles3.txt
index 1cb591f..c94bdd4 100644
--- a/tests/util/CMakeLists.gles3.txt
+++ b/tests/util/CMakeLists.gles3.txt
@@ -5,7 +5,7 @@ list(APPEND UTIL_GL_SOURCES
 	piglit-shader.c
 	piglit-shader-gles2.c # Compatible with gles3.
 	piglit-util-gles.c
-	piglit-util-gles3-enum.c
+	piglit-util-gles2-enum.c
 	piglit-vbo.cpp
 	)
 
diff --git a/tests/util/gen-get-enum.py b/tests/util/gen-get-enum.py
new file mode 100644
index 0000000..c3320dc
--- /dev/null
+++ b/tests/util/gen-get-enum.py
@@ -0,0 +1,285 @@
+#!/usr/bin/env python
+# Copyright 2014 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 (including the next
+# paragraph) 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.
+
+# This script generates a C file with functions that return a string for most
+# GLenum values.
+#
+# Invoke this script with 3 command line arguments: The path to gl.xml,
+# the C output filename and the target api (gl, gles1 or gles2).
+#
+#
+# The generated C file consists of the following functions:
+#
+#
+# const char *
+# piglit_get_gl_enum_name(GLenum param);
+#
+# const char *
+# piglit_get_prim_name(GLenum prim);
+#
+
+import os.path
+import sys
+from xml.etree import ElementTree
+
+
+# Generate a top-of-file comment cautioning that the file is
+# auto-generated and should not be manually edited.
+def generated_boilerplate():
+    return """\
+/**
+ * This file was automatically generated by the script {0!r}.
+ *
+ * DO NOT EDIT!
+ *
+ * To regenerate, run "make piglit_get_enum_gen" from the toplevel directory.
+ *
+ * Copyright 2014 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 (including the next
+ * paragraph) 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.
+ */
+""".format(os.path.basename(sys.argv[0]))
+
+
+# Data structure keeping track of all of the known enums and suffixes.
+#
+# - Api.name is the name of the api (gl, gles1 or gles2).
+#
+# - Api.enum_names is a list of enum names in this api.
+#
+# - Api.suffixes is a dict mapping suffixes (e.g.: ARB, EXT, MESA, ...) to their
+#                priority with 0 being the highest priority. This is used to
+#                determine which enum name to use in case of one value having
+#                multiple names.
+#
+# - Api.enums_by_value is a dict mapping enum values to a list of its names.
+#                      It does only include enums in the main namespace with
+#                      a value bigger than 256.
+#
+# - Api.primitive_types_by_value is a dict mapping primitive type enum values
+#                                to a list of its names.
+#
+class Api(object):
+    def __init__(self, xml_root, name):
+        assert name in ('gl', 'gles1', 'gles2')
+        self.name = name
+
+        self.parse_features_and_extensions(xml_root)
+
+        suffixes = self.parse_suffixes(xml_root)
+        self.sort_suffixes(suffixes)
+
+        enums = self.parse_enums(xml_root)
+        enums_by_value = self.invert_enum_dict(enums)
+        self.sort_enum_names(enums_by_value)
+        self.split_enum_dict(enums_by_value)
+
+
+    # Get all enum names for the desired api and all it's extensions.
+    def parse_features_and_extensions(self, xml_root):
+        core = [x
+            for x in xml_root.findall('feature')
+            if x.attrib['api'] == self.name]
+        extensions = [x
+            for x in xml_root.find('extensions').findall('extension')
+            if self.name in x.attrib['supported'].split('|')]
+        self.enum_names = [x.attrib['name']
+            for z in (core + extensions)
+            for y in z.findall('require')
+            for x in y.findall('enum')]
+
+
+    # Filtering enums that are not part of the main namespace is a bit ugly.
+    # No non-relevant groups of enums and all but one relevant group of enums
+    # have a "start" (and an "end") attribute.  All non-relevant enums and only
+    # a couple of relevant groups have a "name" attribute.  By combining these
+    # two conditions we filter the correct enums and are hopefully somewhat
+    # future-proof.
+    def parse_enums(self, xml_root):
+        enums = []
+        for xml_enums in xml_root.findall('enums'):
+            if xml_enums.attrib['namespace'] != 'GL':
+                continue
+            if 'type' in xml_enums.attrib:
+                if xml_enums.attrib['type'] == 'bitmask':
+                    continue
+            if 'group' in xml_enums.attrib:
+                if 'start' not in xml_enums.attrib:
+                    continue
+            enums += [
+                (xml_enum.attrib['name'], int(xml_enum.attrib['value'], base=0))
+                for xml_enum in xml_enums.findall('enum')
+                if xml_enum.attrib['name'] in self.enum_names]
+        return dict(enums)
+
+
+    # Extract a list of suffixes from the extension names.
+    #
+    # This depends on extensions beeing named GL_<suffix>_foobar.
+    @staticmethod
+    def parse_suffixes(xml_root):
+        extension_names = [x.attrib['name']
+            for x in xml_root.find('extensions').findall('extension')]
+        return list(set(x.split('_')[1]
+            for x in extension_names))
+
+
+    # Prioritize non-vendor suffixes and sort the rest alphabetically.
+    def sort_suffixes(self, suffixes):
+        if (self.name == 'gl'):
+            special_suffixes = ['ARB', 'KHR', 'EXT', 'OES']
+        else:
+            special_suffixes = ['OES', 'KHR', 'EXT', 'ARB']
+        vendor_suffixes = [x
+            for x in suffixes
+            if x not in special_suffixes]
+        vendor_suffixes.sort()
+        suffixes = special_suffixes + vendor_suffixes
+        self.suffixes = dict((x, i) for i, x in enumerate(suffixes))
+
+
+    # Invert enum dictionary.
+    #
+    # Because the input dictionary is not injective, we assign a list of names
+    # to each value.
+    @staticmethod
+    def invert_enum_dict(enums):
+        enums_by_value = dict()
+        for name, value in enums.items():
+            enums_by_value[value] = enums_by_value.get(value, [])
+            enums_by_value[value].append(name)
+        return enums_by_value
+
+
+    # Sorts enum name lists in place.
+    #
+    # Multiple enum names can have the same value. Usually they only differ by
+    # suffix (e.g. GL_COLOR_SUM, GL_COLOR_SUM_ARB and GL_COLOR_SUM_EXT).
+    # Prioritize suffix-less names over names with non-vendor-suffixes over the
+    # rest.
+    # Note that some enum names don't fall into this pattern and are ordered
+    # arbitraryly.
+    def sort_enum_names(self, enums_by_value):
+        for names in enums_by_value.values():
+            names.sort(key = lambda name:
+                self.suffixes.get(name.rpartition('_')[2], -1))
+
+
+    # Branch out primitive type enums into their own dictionary.
+    # At this point all enums with a value < 256 should be primitive types.
+    def split_enum_dict(self, enums_by_value):
+        self.primitive_types_by_value = dict(x
+            for x in enums_by_value.items()
+            if x[0] < 0x100)
+        self.enums_by_value = dict(x
+            for x in enums_by_value.items()
+            if x[0] >= 0x100)
+
+
+    # Generate a list of (value, names) pairs representing all enum values in
+    # the main namespace.  The resulting list is sorted by enum value.
+    # primitive_types -- if True build list only from primitive-name enums
+    #                    (GL_POINTS, GL_LINES, ...)
+    #                 -- if False build list only from non-primitive-name enums
+    #                    in the main namespace.
+    def compute_unique_enums(self, primitive_types=False):
+        if primitive_types:
+            enums_by_value = self.primitive_types_by_value
+        else:
+            enums_by_value = self.enums_by_value
+
+        return [x for x in sorted(enums_by_value.items())]
+
+
+# Read the given input file and return an Api object containing the
+# data in it.
+def read_api(filename, api_name):
+    tree = ElementTree.parse(filename)
+    return Api(tree.getroot(), api_name)
+
+
+# Generate the C source.
+def generate_code(api):
+    c_contents = [generated_boilerplate()]
+
+    c_contents.append("""
+const char *
+piglit_get_gl_enum_name(GLenum param)
+{
+	switch (param) {
+	case 0x0: return "GL_ZERO"; //GL_FALSE, GL_NO_ERROR, GL_NONE
+	case 0x1: return "GL_ONE"; //GL_TRUE
+""")
+
+    for value, names in api.compute_unique_enums(primitive_types=False):
+        c_contents.append('	case {0}: return "{1}"; //{2}\n'.format(
+            hex(value), names[0], ", ".join(names[1:])))
+
+    c_contents.append("""	default: return "(unrecognized enum)";
+	}
+}
+""")
+
+    c_contents.append("""
+const char *
+piglit_get_prim_name(GLenum prim)
+{
+	switch (prim) {
+""")
+
+    for value, names in api.compute_unique_enums(primitive_types=True):
+        c_contents.append('	case {0}: return "{1}"; //{2}\n'.format(
+            hex(value), names[0], ", ".join(names[1:])))
+
+    c_contents.append("""	default: return "(unrecognized enum)";
+	}
+}
+""")
+
+    return ''.join(c_contents)
+
+
+if __name__ == '__main__':
+    file_to_parse = sys.argv[1]
+    api_name = sys.argv[3]
+    api = read_api(file_to_parse, api_name)
+
+    c_contents = generate_code(api)
+    with open(sys.argv[2], 'w') as f:
+        f.write(c_contents)
diff --git a/tests/util/piglit-util-gl-enum.c b/tests/util/piglit-util-gl-enum.c
index 8deb58f..bbc074c 100644
--- a/tests/util/piglit-util-gl-enum.c
+++ b/tests/util/piglit-util-gl-enum.c
@@ -22,9 +22,6 @@
  */
 
 
-/* TODO: Automatically generate this file. */
-
-
 #if defined(_WIN32)
 #include <windows.h>
 #endif
@@ -39,3008 +36,5 @@
 #include "piglit-util-gl-common.h"
 
 
-const char *
-piglit_get_gl_enum_name(GLenum param)
-{
-#define CASE(x) case x: return #x;
-
-	switch (param) {
-
-	CASE(GL_ZERO)	// 0x0000
[SNIP]
-	CASE(GL_INVALID_INDEX)	// 0xFFFFFFFFu
-
-	default:
-		return "(unrecognized enum)";
-	}
-
-#undef CASE
-}
-
-
-const char *
-piglit_get_prim_name(GLenum prim)
-{
-	switch (prim) {
-	case GL_POINTS:
-		return "GL_POINTS";
-	case GL_LINES:
-		return "GL_LINES";
-	case GL_LINE_STRIP:
-		return "GL_LINE_STRIP";
-	case GL_LINE_LOOP:
-		return "GL_LINE_LOOP";
-	case GL_TRIANGLES:
-		return "GL_TRIANGLES";
-	case GL_TRIANGLE_STRIP:
-		return "GL_TRIANGLE_STRIP";
-	case GL_TRIANGLE_FAN:
-		return "GL_TRIANGLE_FAN";
-	case GL_QUADS:
-		return "GL_QUADS";
-	case GL_QUAD_STRIP:
-		return "GL_QUAD_STRIP";
-	case GL_POLYGON:
-		return "GL_POLYGON";
-	case GL_LINES_ADJACENCY:
-		return "GL_LINES_ADJACENCY";
-	case GL_LINE_STRIP_ADJACENCY:
-		return "GL_LINE_STRIP_ADJACENCY";
-	case GL_TRIANGLES_ADJACENCY:
-		return "GL_TRIANGLES_ADJACENCY";
-	case GL_TRIANGLE_STRIP_ADJACENCY:
-		return "GL_TRIANGLE_STRIP_ADJACENCY";
-	case GL_PATCHES:
-		return "GL_PATCHES";
-	default:
-		return "(unrecognized enum)";
-	}
-}
-
+#include "generated-get-enum-gl.c"
 
diff --git a/tests/util/piglit-util-gles1-enum.c b/tests/util/piglit-util-gles1-enum.c
new file mode 100644
index 0000000..85d8050
--- /dev/null
+++ b/tests/util/piglit-util-gles1-enum.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2014 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 (including the next
+ * paragraph) 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.
+ */
+
+
+#include "piglit-util-gl-common.h"
+
+#include "generated-get-enum-gles1.c"
diff --git a/tests/util/piglit-util-gles2-enum.c b/tests/util/piglit-util-gles2-enum.c
new file mode 100644
index 0000000..9e65594
--- /dev/null
+++ b/tests/util/piglit-util-gles2-enum.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2014 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 (including the next
+ * paragraph) 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.
+ */
+
+
+#include "piglit-util-gl-common.h"
+
+#include "generated-get-enum-gles2.c"
diff --git a/tests/util/piglit-util-gles3-enum.c b/tests/util/piglit-util-gles3-enum.c
deleted file mode 100644
index 8b0fcdc..0000000
--- a/tests/util/piglit-util-gles3-enum.c
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * Copyright 2012 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 (including the next
- * paragraph) 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.
- */
-
-/* TODO: Automatically generate this file. */
-
-#include "piglit-util-gl-common.h"
-
-const char *
-piglit_get_gl_enum_name(GLenum param)
-{
-#define CASE(x) case x: return #x;
-
-	switch (param) {
-
-	/* <GLES3/gl3.h> */
-
-	/* BlendingFactorDest */
-	CASE(GL_SRC_COLOR)                                      // 0x0300
[SNIP]
-	CASE(GL_TEXTURE_IMMUTABLE_LEVELS)                       // 0x8D63
-
-	default:
-		return "(unrecognized enum)";
-	}
-
-#undef CASE
-}
-
-const char *
-piglit_get_prim_name(GLenum prim)
-{
-	switch (prim) {
-	case GL_POINTS:
-		return "GL_POINTS";
-	case GL_LINES:
-		return "GL_LINES";
-	case GL_LINE_STRIP:
-		return "GL_LINE_STRIP";
-	case GL_LINE_LOOP:
-		return "GL_LINE_LOOP";
-	case GL_TRIANGLES:
-		return "GL_TRIANGLES";
-	case GL_TRIANGLE_STRIP:
-		return "GL_TRIANGLE_STRIP";
-	case GL_TRIANGLE_FAN:
-		return "GL_TRIANGLE_FAN";
-	default:
-		return "(unrecognized enum)";
-	}
-}
-- 
1.8.3.2


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Autogenerate-get_enum_name-functions-from-gl.xml.patch.xz
Type: application/x-xz
Size: 25756 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140222/dce367b2/attachment-0001.bin>


More information about the Piglit mailing list