mesa/es: Generate code for special functions.

es_generator.py did not generate code for special functions.  They were
supposed to be defined elsewhere.  But as a result, parameter checking
was also skipped.  This commit changes the way special functions are
called so that parameter checking is always performed.

When there is nothing to check, the check functions becomes macros
expanding to the real functions, as an optimization.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
Chia-I Wu 2009-11-23 14:40:32 +08:00 committed by Brian Paul
parent f7d23dfef5
commit a2d21f67f9
6 changed files with 37 additions and 20 deletions

View file

@ -133,7 +133,7 @@ class Function(object):
if force_skip_desc:
self._skip_desc = True
else:
self._skip_desc = (self.is_external or func_node.prop("skip_desc") == "true")
self._skip_desc = (func_node.prop("skip_desc") == "true")
self._categories = categories

View file

@ -15,6 +15,10 @@
parameters. A <desc> can enumerate the valid values of a parameter. It
can also specify the error code when an invalid value is given, and etc.
By nesting <desc>s, they can create dependency between parameters.
A function can be marked as external. It means that the function cannot
be dispatched to the corresponding mesa function, if one exists, directly,
and requires an external implementation.
-->
<apispec>
@ -1284,6 +1288,7 @@
<value name="GL_RENDERER"/>
<value name="GL_VERSION"/>
<value name="GL_EXTENSIONS"/>
<value name="GL_SHADING_LANGUAGE_VERSION" category="GLES2.0"/>
</desc>
</template>
@ -3674,8 +3679,6 @@
<function name="GetUniformfvARB" template="GetUniform" gltype="GLfloat"/>
<function name="GetUniformivARB" template="GetUniform" gltype="GLint"/>
<function name="QueryMatrixx" template="QueryMatrix" gltype="GLfixed"/>
<function name="DrawTexf" template="DrawTex" gltype="GLfloat" expand_vector="true"/>
<function name="DrawTexfv" template="DrawTex" gltype="GLfloat"/>
<function name="DrawTexi" template="DrawTex" gltype="GLint" expand_vector="true"/>

View file

@ -59,8 +59,11 @@ def _ParseXML(filename, apiname):
for func in api.functions:
alias, need_conv = impl.match(func, conversions)
if not alias:
print >>sys.stderr, "Error: unable to dispatch %s" % func.name
# external functions are manually dispatched
if not func.is_external:
print >>sys.stderr, "Error: unable to dispatch %s" % func.name
alias = func
need_conv = False
__functions[func.name] = func
__aliases[func.name] = (alias, need_conv)

View file

@ -19,7 +19,7 @@
#include "GLES/glext.h"
void GL_APIENTRY _es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
void GL_APIENTRY _es_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
void GL_APIENTRY _mesa_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void GL_APIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
@ -215,9 +215,9 @@ cpal_compressed_teximage2d(GLenum target, GLint level,
void GL_APIENTRY
_es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat,
GLsizei width, GLsizei height, GLint border,
GLsizei imageSize, const GLvoid *data)
_es_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat,
GLsizei width, GLsizei height, GLint border,
GLsizei imageSize, const GLvoid *data)
{
switch (internalFormat) {
case GL_PALETTE4_RGB8_OES:

View file

@ -10,14 +10,14 @@
#include "GLES2/gl2ext.h"
extern void GL_APIENTRY _es_RenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
extern void GL_APIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
extern void GL_APIENTRY _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
void GL_APIENTRY
_es_RenderbufferStorage(GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height)
_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height)
{
switch (internalFormat) {
case GL_RGBA4:

View file

@ -272,7 +272,13 @@ for funcName in keys:
# We're allowed to override the prefix and/or the function name
# for each function record, though. The "ConversionFunction"
# utility is poorly named, BTW...
aliasprefix = apiutil.AliasPrefix(funcName)
if funcName in allSpecials:
# perform checks and pass through
funcPrefix = "_check_"
aliasprefix = "_es_"
else:
funcPrefix = "_es_"
aliasprefix = apiutil.AliasPrefix(funcName)
alias = apiutil.ConversionFunction(funcName)
if not alias:
# There may still be a Mesa alias for the function
@ -562,8 +568,9 @@ for funcName in keys:
# The Mesa functions are scattered across all the Mesa
# header files. The easiest way to manage declarations
# is to create them ourselves.
if funcName not in allSpecials:
print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
if funcName in allSpecials:
print "/* this function is special and is defined elsewhere */"
print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
# A function may be a core function (i.e. it exists in
# the core specification), a core addition (extension
@ -594,22 +601,25 @@ for funcName in keys:
if len(compoundCategory) == 1:
# This is a core function
extensionName = None
fullFuncName = "_es_" + funcName
extensionSuffix = ""
else:
# This is an extension function. We'll need to append
# the extension suffix.
extensionName = compoundCategory[1]
extensionSuffix = extensionName.split("_")[0]
fullFuncName = "_es_" + funcName + extensionSuffix
fullFuncName = funcPrefix + funcName + extensionSuffix
# Now the generated function. The text used to mark an API-level
# function, oddly, is version-specific.
if extensionName:
print "/* Extension %s */" % extensionName
if funcName in allSpecials:
print "/* this function is special and is defined elsewhere */"
print "extern %s %s(%s);" % (returnType, fullFuncName, declarationString)
if (not variables and
not switchCode and
not conversionCodeOutgoing and
not conversionCodeIncoming):
# pass through directly
print "#define %s %s" % (fullFuncName, passthroughFuncName)
print
continue
@ -661,6 +671,7 @@ print "void"
print "_mesa_init_exec_table(struct _glapi_table *exec)"
print "{"
for func in keys:
prefix = "_es_" if func not in allSpecials else "_check_"
for spec in apiutil.Categories(func):
ext = spec.split(":")
# version does not match
@ -670,5 +681,5 @@ for func in keys:
if ext:
suffix = ext[0].split("_")[0]
entry += suffix
print " SET_%s(exec, _es_%s);" % (entry, entry)
print " SET_%s(exec, %s%s);" % (entry, prefix, entry)
print "}"