summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-12-29 15:09:16 -0700
committerBrian Paul <brianp@vmware.com>2009-12-29 15:09:16 -0700
commit126b35bd3acbf486471879531cd2e6f446b14497 (patch)
treee3997a0718682a4968525e7f0801c01d0ee0bffa
parent3728673bd1b974e54858fbab6ff62d3607b0d3f0 (diff)
mesa: implement indexed glGet functions
The functions are _mesa_GetBooleanIndexedv(), _mesa_GetIntegerIndexedv(), and _mesa_GetInteger64Indexedv(). These will be called from API functions such as glGetBooleanIndexedvEXT() and glGetBooleani_v(). Only the GL_BLEND query is supported at this time.
-rw-r--r--src/mesa/main/get.c74
-rw-r--r--src/mesa/main/get.h9
-rw-r--r--src/mesa/main/get_gen.py77
3 files changed, 140 insertions, 20 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 07507414d70..aff67466bcb 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -7434,3 +7434,77 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
params[i] = (GLdouble) values[i];
}
+void GLAPIENTRY
+_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!params)
+ return;
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ switch (pname) {
+ case GL_BLEND:
+ if (index >= MAX_DRAW_BUFFERS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+ }
+ params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1));
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname);
+ }
+}
+
+void GLAPIENTRY
+_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!params)
+ return;
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ switch (pname) {
+ case GL_BLEND:
+ if (index >= MAX_DRAW_BUFFERS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+ }
+ params[0] = ((ctx->Color.BlendEnabled >> index) & 1);
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname);
+ }
+}
+
+#if FEATURE_ARB_sync
+void GLAPIENTRY
+_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!params)
+ return;
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ switch (pname) {
+ case GL_BLEND:
+ if (index >= MAX_DRAW_BUFFERS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+ }
+ params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1));
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname);
+ }
+}
+#endif /* FEATURE_ARB_sync */
+
diff --git a/src/mesa/main/get.h b/src/mesa/main/get.h
index 77a9a7d04b4..076ab7a58bb 100644
--- a/src/mesa/main/get.h
+++ b/src/mesa/main/get.h
@@ -51,6 +51,15 @@ extern void GLAPIENTRY
_mesa_GetInteger64v( GLenum pname, GLint64 *params );
extern void GLAPIENTRY
+_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params );
+
+extern void GLAPIENTRY
+_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params );
+
+extern void GLAPIENTRY
_mesa_GetPointerv( GLenum pname, GLvoid **params );
extern const GLubyte * GLAPIENTRY
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index 5aff9d3544e..8b6500fae17 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -1033,6 +1033,14 @@ StateVars = [
]
+# These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v()
+IndexedStateVars = [
+ ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], "MAX_DRAW_BUFFERS", 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 +1067,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 +1076,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 +1115,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");' %
@@ -1249,9 +1282,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)
+