Commit 3140a4e1 authored by Eric Anholt's avatar Eric Anholt

glapi: Add parsing of GLES2/gl2ext.h.

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.

v2: Express the corename substitution as a regexp. (suggestion by Paul)
Reviewed-by: Paul Berry's avatarPaul Berry <stereotype441@gmail.com>
parent 8f3392a2
......@@ -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(
......
......@@ -129,7 +129,7 @@ GLSPEC_ATTRIBUTE_REGEXP = re.compile(r'^\s+(\w+)\s+(.*)$')
GL_VERSION_REGEXP = re.compile('^VERSION_([0-9])_([0-9])(_DEPRECATED)?$')
GLES_VERSION_REGEXP = re.compile('^GL_ES_VERSION_([0-9])_([0-9])(_DEPRECATED)?$')
ENUM_REGEXP = re.compile(r'^\s+(\w+)\s+=\s+(\w+)$')
EXTENSION_SUFFIX_REGEXP = re.compile(r'(ARB|EXT|KHR|OES|NV|AMD|IMG|QCOM|INTEL)$')
# Convert a type into a canonical form that is consistent about its
# use of spaces.
......@@ -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:
......@@ -479,6 +486,18 @@ 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 = EXTENSION_SUFFIX_REGEXP.sub('', name)
if corename in self.functions:
self.synonyms.add_alias(corename, name)
# 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:
......@@ -529,5 +548,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())
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment