[Piglit] [PATCH 10/14] glapi: Parse the GLES3 core header for piglit-dispatch.

Eric Anholt eric at anholt.net
Wed Jun 5 16:14:27 PDT 2013


This gets us piglit-dispatch support for all the core functions of
GLES2/3.
---
 cmake/piglit_glapi.cmake |  1 +
 glapi/parse_glspec.py    | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/cmake/piglit_glapi.cmake b/cmake/piglit_glapi.cmake
index 368c1ca..899c7ee 100644
--- a/cmake/piglit_glapi.cmake
+++ b/cmake/piglit_glapi.cmake
@@ -34,6 +34,7 @@ set(piglit_glapi_inputs
 	${piglit_glapi_src_dir}/gl.spec
 	${piglit_glapi_src_dir}/enum.spec
 	${piglit_glapi_src_dir}/enumext.spec
+	${piglit_glapi_src_dir}/GLES3/gl3.h
 	)
 
 add_custom_command(
diff --git a/glapi/parse_glspec.py b/glapi/parse_glspec.py
index ef6143c..163de70 100644
--- a/glapi/parse_glspec.py
+++ b/glapi/parse_glspec.py
@@ -447,6 +447,43 @@ class Api(object):
             for alias in attributes['alias']:
                 self.synonyms.add_alias(name, alias)
 
+    def read_gles_header(self, f):
+        category = 'GL_ES_VERSION_2_0'
+        for line in f:
+            # The GLES gl3.h has typedefs, tokens, and prototypes,
+            # each listed after a comment indicating whether they're
+            # part of 2.0 core or 3.0 core.
+            if re.match(r'/\* OpenGL ES 2.0 \*/', line):
+                category = 'GL_ES_VERSION_2_0'
+            elif re.match(r'/\* OpenGL ES 3.0 \*/', line):
+                category = 'GL_ES_VERSION_3_0'
+
+            m = re.match(r'GL_APICALL', line)
+            if m:
+                # We do the regexp in two parts to make sure that we
+                # actually do catch all the GL_APICALLs.
+                m = re.match(r'^GL_APICALL\s*(.*)\s*GL_APIENTRY\s*gl(\w*)\s\((.*)\).*$', line)
+                return_type, name, args = m.groups()
+
+                return_type = return_type.strip()
+                args = args.split(', ')
+
+                if args[0] == 'void':
+                    args.remove('void')
+                param_names = [None] * len(args)
+                param_types = [None] * len(args)
+                i = 0
+                for arg in args:
+                    splitloc = max(arg.rfind(' '), arg.rfind('*'))
+                    param_type = arg[:splitloc + 1]
+                    param_name = arg[splitloc + 1:]
+
+                    param_types[i] = param_type
+                    param_names[i] = param_name
+                    i += 1
+
+                self.add_function(name, return_type, param_names, param_types, category)
+
     # Convert each line in the enumext.spec file into a key/value pair
     # in self.enums, mapping an enum name to a dict.  For example, the
     # following enumext.spec input:
@@ -495,5 +532,7 @@ if __name__ == '__main__':
         api.read_enumext_spec(f)
     with open(sys.argv[4]) as f:
         api.read_enumext_spec(f)
-    with open(sys.argv[5], 'w') as f:
+    with open(sys.argv[5]) as f:
+        api.read_gles_header(f)
+    with open(sys.argv[6], 'w') as f:
         f.write(api.to_json())
-- 
1.8.3.rc0



More information about the Piglit mailing list