mesa: add dlist support for indexed colormask and indexed enables/disables
[mesa.git] / src / mesa / main / get_gen.py
index 930c3362faee20333cd70d8f52c128a2100da51c..18708be26037d96cdfc35ed8fdcca97e3c21d57b 100644 (file)
@@ -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,
@@ -942,9 +942,9 @@ StateVars = [
 
        # GL_OES_read_format
        ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint,
-         ["ctx->Const.ColorReadType"], "", ["OES_read_format"] ),
+         ["_mesa_get_color_read_type(ctx)"], "", ["OES_read_format"] ),
        ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint,
-         ["ctx->Const.ColorReadFormat"], "", ["OES_read_format"] ),
+         ["_mesa_get_color_read_format(ctx)"], "", ["OES_read_format"] ),
 
        # GL_ATI_fragment_shader
        ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], "", ["ATI_fragment_shader"] ),
@@ -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
@@ -1033,6 +1033,21 @@ StateVars = [
 ]
 
 
+# These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v()
+IndexedStateVars = [
+       ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"],
+         "ctx->Const.MaxDrawBuffers", None ),
+       ( "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", None ),
+       # 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 +1074,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 +1083,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,14 +1122,26 @@ 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 indexMax:
+                       print ('         if (index >= %s) {' % indexMax)
+                       print ('            _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function)
+                       print ('         }')
+
                if extensions:
                        if len(extensions) == 1:
                                print ('         CHECK_EXT1(%s, "%s");' %
@@ -1159,6 +1199,7 @@ def EmitHeader():
 #include "mtypes.h"
 #include "state.h"
 #include "texcompress.h"
+#include "framebuffer.h"
 
 
 #define FLOAT_TO_BOOLEAN(X)   ( (X) ? GL_TRUE : GL_FALSE )
@@ -1248,9 +1289,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)
+