From 8f6f1124634cf659dde4c75549b84e35505d892d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Dec 2009 16:30:54 -0700 Subject: [PATCH] mesa: added infrastructure for GL_EXT_draw_buffers2 --- src/mesa/main/enable.c | 13 ++++++++++--- src/mesa/main/extensions.c | 1 + src/mesa/main/get.c | 6 ++++++ src/mesa/main/get_gen.py | 14 +++++++------- src/mesa/main/mtypes.h | 1 + 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 6f9f57f5cb8..cd6e881ad2d 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1033,6 +1033,9 @@ _mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) ASSERT(state == 0 || state == 1); switch (cap) { case GL_BLEND: + if (!ctx->Extensions.EXT_draw_buffers2) { + goto bad_cap_error; + } if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", state ? "glEnableIndexed" : "glDisableIndexed", index); @@ -1047,10 +1050,14 @@ _mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) } break; default: - _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", - state ? "glEnableIndexed" : "glDisableIndexed", - _mesa_lookup_enum_by_nr(cap)); + goto bad_cap_error; } + return; + +bad_cap_error: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", + state ? "glEnablei" : "glDisablei", + _mesa_lookup_enum_by_nr(cap)); } diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 2138bfe40ef..9e96eb04036 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -103,6 +103,7 @@ static const struct { { OFF, "GL_EXT_convolution", F(EXT_convolution) }, { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) }, + { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) }, { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) }, { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) }, { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) }, diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 44396a0491c..99478f0ec43 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -7448,12 +7448,14 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) switch (pname) { case GL_BLEND: + CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); } params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1)); break; case GL_COLOR_WRITEMASK: + CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); } @@ -7481,12 +7483,14 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) switch (pname) { case GL_BLEND: + CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); } params[0] = ((ctx->Color.BlendEnabled >> index) & 1); break; case GL_COLOR_WRITEMASK: + CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); } @@ -7515,12 +7519,14 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) switch (pname) { case GL_BLEND: + CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); } params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1)); break; case GL_COLOR_WRITEMASK: + CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); } diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 18708be2603..82eacf03146 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1036,13 +1036,13 @@ StateVars = [ # These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v() IndexedStateVars = [ ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], - "ctx->Const.MaxDrawBuffers", None ), + "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", None ), + "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ), # XXX more to come... ] @@ -1137,11 +1137,6 @@ def EmitGetFunction(stateVars, returnType, indexed): (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");' % @@ -1156,6 +1151,11 @@ def EmitGetFunction(stateVars, returnType, indexed): 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); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7ef2852242f..3a48c8bf009 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2434,6 +2434,7 @@ struct gl_extensions GLboolean EXT_compiled_vertex_array; GLboolean EXT_copy_texture; GLboolean EXT_depth_bounds_test; + GLboolean EXT_draw_buffers2; GLboolean EXT_draw_range_elements; GLboolean EXT_fog_coord; GLboolean EXT_framebuffer_blit; -- 2.30.2