conversionString = Converters[fromType][toType]
return conversionString % value
-def GetLoopSizeExpression(funcName, paramName, paramMaxVecSize):
- # The VariantArrays() list will have all the information (for all
- # parameters) on how to calculate variant array sizes.
- variantArrays = apiutil.VariantArrays(funcName)
- defaultSize = paramMaxVecSize
- loopSizeExpression = ''
-
- # There can be many different entries in the variantArrays for the
- # same parameter. We have to look at all of them and pick out the
- # ones of interest.
- for (variantName, variantSize, controllingParam, controllingValues) in variantArrays:
- if paramName == variantName:
- # This variant specification applies to us. It may be of
- # the form "param size default", meaning that the value should
- # replace the default size, or it may be
- # "param size controlParam value...", in which case the size should
- # be used if the controlParam has any one of the given values.
- if len(controllingValues) == 0:
- defaultSize = variantSize
- else:
- # Create a compound conditional that expresses
- # all the possible values in the list
- conditional = ''
- for value in controllingValues:
- if len(conditional) > 0:
- conditional = conditional + " || "
- conditional = conditional + "%s == %s" % (controllingParam, value)
-
- # Add the possibly compound conditional and
- # the associated vector size to the
- # loop control expression
- loopSizeExpression = loopSizeExpression + "(%s) ? %s : " % (conditional, variantSize)
-
- # end if the name matches
- # end for the list of all variant array declarations
-
- # Return the expression that returns the actual size of the
- # array. Note that 'loopSizeExpression' will already have a
- # trailing ": " if it is nonempty.
- if len(loopSizeExpression) > 0:
- return "(%s%s)" % (loopSizeExpression, defaultSize)
- else:
- return "%s" % defaultSize
-
FormatStrings = {
'GLenum' : '0x%x',
'GLfloat' : '%f',
#include "main/compiler.h"
#include "main/api_exec.h"
-#include "glapi/dispatch.h"
+#include "main/dispatch.h"
typedef void (*_glapi_proc)(void); /* generic function pointer */
"""
-# All variant-length arrays in the GLES API are controlled by some
-# selector parameter. Almost all of those are constant length based
-# on the selector parameter (e.g., in glFogfv(), if the "pname"
-# parameter is GL_FOG_COLOR, the "params" array is considered to be
-# 4 floats long; for any other value of "pname", the "params' array
-# is considered to be 1 float long.
-#
-# There are a very few instances where the selector parameter chooses
-# a runtime-determined value:
-# glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS)
-# glGetIntegerv(GL_SHADER_BINARY_FORMATS)
-# plus the glGetBooleanv, glGetFloatv, glGetFixedv counterparts.
-#
-# The number of formats in both cases is not a constant, but is a
-# runtime-determined value (based on the return value of
-# glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS) or
-# glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS).
-#
-# Rather than hard-code some value (and risk memory errors when we
-# overshoot arrays), in these cases we'll use a constant expresssion
-# (e.g. _get_size(GL_NUM_COMPRESSED_TEXTURE_FORMATS)) to get the
-# value of the variant array. Note, though, that in these cases the
-# "vector" parameter should be set to some size large enough to hold
-# all values (and must be set for GLfixed-based conversions, which
-# need it to define an auxiliary array size).
-#
-# Here's the function itself. Although we only need a couple of values,
-# we'll make it general.
-print """
-extern void GLAPIENTRY _mesa_GetIntegerv(GLenum, GLint *);
-static INLINE unsigned int _get_size(GLenum pname)
-{
- /* In case of error, make sure the value returned is 0. */
- GLint value = 0;
- _mesa_GetIntegerv(pname, &value);
- return (unsigned int) value;
-}
-"""
-
# Finally we get to the all-important functions
print """/*************************************************************
* Generated functions begin here
# 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
# 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
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
# end for each function
-print "void"
-print "_mesa_init_exec_table(struct _glapi_table *exec)"
+print "struct _glapi_table *"
+print "_mesa_create_exec_table(void)"
print "{"
+print " struct _glapi_table *exec;"
+print " exec = _mesa_alloc_dispatch_table(sizeof *exec);"
+print " if (exec == NULL)"
+print " return NULL;"
+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
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 ""
+print " return exec;"
print "}"