[Piglit] [PATCH 11/14] glapi: Add parsing of GLES2/gl2ext.h.
Paul Berry
stereotype441 at gmail.com
Wed Jun 12 14:14:29 PDT 2013
On 5 June 2013 16:14, Eric Anholt <eric at anholt.net> wrote:
> Weirdly, the gl3ext.h has no entries currently, and to access
> extensions from GLES3 you need to include this GLES2 header.
>
> We now have code-generated piglit-dispatch support for all of desktop,
> GLES2, and GLES3.
> ---
> cmake/piglit_glapi.cmake | 1 +
> glapi/parse_glspec.py | 25 ++++++++++++++++++++++++-
> tests/util/piglit-dispatch.h | 4 ++++
> 3 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/cmake/piglit_glapi.cmake b/cmake/piglit_glapi.cmake
> index 899c7ee..59d4d42 100644
> --- a/cmake/piglit_glapi.cmake
> +++ b/cmake/piglit_glapi.cmake
> @@ -35,6 +35,7 @@ set(piglit_glapi_inputs
> ${piglit_glapi_src_dir}/enum.spec
> ${piglit_glapi_src_dir}/enumext.spec
> ${piglit_glapi_src_dir}/GLES3/gl3.h
> + ${piglit_glapi_src_dir}/GLES2/gl2ext.h
> )
>
> add_custom_command(
> diff --git a/glapi/parse_glspec.py b/glapi/parse_glspec.py
> index 163de70..8952850 100644
> --- a/glapi/parse_glspec.py
> +++ b/glapi/parse_glspec.py
> @@ -453,10 +453,17 @@ class Api(object):
> # 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.
> + #
> + # The gl2ext.h is split into groups of functions prefixed
> + # by the extension name in a comment.
> 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'
> + else:
> + m = re.match(r'/\* (GL_.*) \*/', line)
> + if m:
> + category = m.group(1).replace('GL_', '')
>
> m = re.match(r'GL_APICALL', line)
> if m:
> @@ -484,6 +491,20 @@ class Api(object):
>
> self.add_function(name, return_type, param_names,
> param_types, category)
>
> + # Since we don't have alias information for
> + # extensions, assume that pretty much anything
> + # with the same base name as a core function is
> + # aliased with it.
> + #
> + # glTexImage3DOES is an exception because it
> + # doesn't have the border argument.
> + if name != 'TexImage3DOES':
> + corename = name
> + for suffix in ('ARB', 'EXT', 'KHR', 'OES', 'NV',
> 'AMD', 'IMG', 'QCOM', 'INTEL'):
> + corename = corename.replace(suffix, '')
> + if corename in self.functions:
> + self.synonyms.add_alias(corename, name)
> +
>
I'd feel slightly more comfortable if we can (a) reduce the number of
hardcoded strings in the body of the code, and (b) only match these
suffixes when they appear at the end of the function name. How about
something like this instead?
(At the top of parse_glspec.py, with the other regexps)
EXTENSION_SUFFIX_REGEXP =
re.compile(r'(ARB|EXT|KHR|OES|NV|AMD|IMG|QCOM|INTEL)$')
And then instead of the three lines above beginning "corename = name", do
this:
corename = EXTENSION_SUFFIX_REGEXP.sub('', name)
With that change, this patch is:
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
> # 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:
> @@ -534,5 +555,7 @@ if __name__ == '__main__':
> api.read_enumext_spec(f)
> with open(sys.argv[5]) as f:
> api.read_gles_header(f)
> - with open(sys.argv[6], 'w') as f:
> + with open(sys.argv[6]) as f:
> + api.read_gles_header(f)
> + with open(sys.argv[7], 'w') as f:
> f.write(api.to_json())
> diff --git a/tests/util/piglit-dispatch.h b/tests/util/piglit-dispatch.h
> index 0b00891..669aecc 100644
> --- a/tests/util/piglit-dispatch.h
> +++ b/tests/util/piglit-dispatch.h
> @@ -122,12 +122,16 @@ struct _cl_event;
> typedef GLintptr GLvdpauSurfaceNV;
> typedef unsigned short GLhalfNV;
>
> +typedef void *GLeglImageOES;
> +
> typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint
> id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
>
> typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint
> id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
>
> typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum
> severity,GLsizei length,const GLchar *message,GLvoid *userParam);
>
> +typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint
> id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
> +
> typedef void (APIENTRY *piglit_dispatch_function_ptr)(void);
>
> typedef piglit_dispatch_function_ptr
> (*piglit_get_core_proc_address_function_ptr)(const char *, int);
> --
> 1.8.3.rc0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130612/336e4abc/attachment.html>
More information about the Piglit
mailing list