summaryrefslogtreecommitdiff
path: root/src/mesa/main/get_gen.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/get_gen.py')
-rw-r--r--src/mesa/main/get_gen.py101
1 files changed, 75 insertions, 26 deletions
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index 697c4cfd92..b0beb59207 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -82,7 +82,7 @@ StateVars = [
( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ),
( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"],
"", None ),
- ( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ),
+ ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", None ),
( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
@@ -126,10 +126,10 @@ StateVars = [
( "GL_COLOR_MATERIAL_PARAMETER", GLenum,
["ctx->Light.ColorMaterialMode"], "", None ),
( "GL_COLOR_WRITEMASK", GLint,
- [ "ctx->Color.ColorMask[RCOMP] ? 1 : 0",
- "ctx->Color.ColorMask[GCOMP] ? 1 : 0",
- "ctx->Color.ColorMask[BCOMP] ? 1 : 0",
- "ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ),
+ [ "ctx->Color.ColorMask[0][RCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[0][GCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[0][BCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", None ),
( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ),
( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ),
( "GL_CURRENT_COLOR", GLfloatN,
@@ -1006,7 +1006,7 @@ StateVars = [
( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint,
["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ),
( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint,
- ["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "", ["ARB_vertex_shader"] ),
+ ["ctx->Const.MaxCombinedTextureImageUnits"], "", ["ARB_vertex_shader"] ),
# GL_ARB_shader_objects
# Actually, this token isn't part of GL_ARB_shader_objects, but is
@@ -1030,9 +1030,29 @@ StateVars = [
# GL_ARB_sync
( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "",
["ARB_sync"] ),
+
+ # GL3
+ ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ),
+ ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", None ),
+ ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", None )
+]
+
+
+# These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v()
+IndexedStateVars = [
+ ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"],
+ "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ),
+ ( "GL_COLOR_WRITEMASK", GLint,
+ [ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[index][GCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[index][BCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ],
+ "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ),
+ # XXX more to come...
]
+
def ConversionFunc(fromType, toType):
"""Return the name of the macro to convert between two data types."""
if fromType == toType:
@@ -1059,7 +1079,7 @@ def ConversionFunc(fromType, toType):
return fromStr + "_TO_" + toStr
-def EmitGetFunction(stateVars, returnType):
+def EmitGetFunction(stateVars, returnType, indexed):
"""Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv."""
assert (returnType == GLboolean or
returnType == GLint or
@@ -1068,22 +1088,35 @@ def EmitGetFunction(stateVars, returnType):
strType = TypeStrings[returnType]
# Capitalize first letter of return type
- if returnType == GLint:
- function = "GetIntegerv"
- elif returnType == GLboolean:
- function = "GetBooleanv"
- elif returnType == GLfloat:
- function = "GetFloatv"
- elif returnType == GLint64:
- function = "GetInteger64v"
+ if indexed:
+ if returnType == GLint:
+ function = "GetIntegerIndexedv"
+ elif returnType == GLboolean:
+ function = "GetBooleanIndexedv"
+ elif returnType == GLint64:
+ function = "GetInteger64Indexedv"
+ else:
+ function = "Foo"
else:
- abort()
+ if returnType == GLint:
+ function = "GetIntegerv"
+ elif returnType == GLboolean:
+ function = "GetBooleanv"
+ elif returnType == GLfloat:
+ function = "GetFloatv"
+ elif returnType == GLint64:
+ function = "GetInteger64v"
+ else:
+ abort()
if returnType == GLint64:
print "#if FEATURE_ARB_sync"
print "void GLAPIENTRY"
- print "_mesa_%s( GLenum pname, %s *params )" % (function, strType)
+ if indexed:
+ print "_mesa_%s( GLenum pname, GLuint index, %s *params )" % (function, strType)
+ else:
+ print "_mesa_%s( GLenum pname, %s *params )" % (function, strType)
print "{"
print " GET_CURRENT_CONTEXT(ctx);"
print " ASSERT_OUTSIDE_BEGIN_END(ctx);"
@@ -1094,13 +1127,20 @@ def EmitGetFunction(stateVars, returnType):
print " if (ctx->NewState)"
print " _mesa_update_state(ctx);"
print ""
- print " if (ctx->Driver.%s &&" % function
- print " ctx->Driver.%s(ctx, pname, params))" % function
- print " return;"
- print ""
+ if indexed == 0:
+ print " if (ctx->Driver.%s &&" % function
+ print " ctx->Driver.%s(ctx, pname, params))" % function
+ print " return;"
+ print ""
print " switch (pname) {"
- for (name, varType, state, optionalCode, extensions) in stateVars:
+ for state in stateVars:
+ if indexed:
+ (name, varType, state, indexMax, extensions) = state
+ optionalCode = 0
+ else:
+ (name, varType, state, optionalCode, extensions) = state
+ indexMax = 0
print " case " + name + ":"
if extensions:
if len(extensions) == 1:
@@ -1116,6 +1156,11 @@ def EmitGetFunction(stateVars, returnType):
assert len(extensions) == 4
print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' %
(extensions[0], extensions[1], extensions[2], extensions[3], function))
+ if indexMax:
+ print (' if (index >= %s) {' % indexMax)
+ print (' _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function)
+ print (' }')
+
conversion = ConversionFunc(varType, returnType)
if optionalCode:
optionalCode = string.replace(optionalCode, "CONVERSION", conversion);
@@ -1249,9 +1294,13 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
EmitHeader()
# XXX Maybe sort the StateVars list
-EmitGetFunction(StateVars, GLboolean)
-EmitGetFunction(StateVars, GLfloat)
-EmitGetFunction(StateVars, GLint)
-EmitGetFunction(StateVars, GLint64)
+EmitGetFunction(StateVars, GLboolean, 0)
+EmitGetFunction(StateVars, GLfloat, 0)
+EmitGetFunction(StateVars, GLint, 0)
+EmitGetFunction(StateVars, GLint64, 0)
EmitGetDoublev()
+EmitGetFunction(IndexedStateVars, GLboolean, 1)
+EmitGetFunction(IndexedStateVars, GLint, 1)
+EmitGetFunction(IndexedStateVars, GLint64, 1)
+