summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2004-01-27 18:52:40 +0000
committerIan Romanick <idr@us.ibm.com>2004-01-27 18:52:40 +0000
commitc93105eb9e2499efb237fd89dba0cebd48f18375 (patch)
treee105eeceae3f57be1b583e51957d6f39038fed34 /src/mesa/main
parentdd9e6e7e37fbb8c30c8085ed784539d94110aa3e (diff)
Added support for EXT_blend_equation_separate / ATI_blend_equation_separate.
The internal driver interface was also changed to use BlendEquationSeparate instead of BlendEquation.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/attrib.c11
-rw-r--r--src/mesa/main/blend.c119
-rw-r--r--src/mesa/main/blend.h4
-rw-r--r--src/mesa/main/dd.h2
-rw-r--r--src/mesa/main/dlist.c25
-rw-r--r--src/mesa/main/enable.c4
-rw-r--r--src/mesa/main/extensions.c3
-rw-r--r--src/mesa/main/get.c28
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/state.c1
10 files changed, 158 insertions, 43 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 62d968a32f..8beb0a575b 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -838,7 +838,16 @@ _mesa_PopAttrib(void)
color->BlendDstRGB,
color->BlendSrcA,
color->BlendDstA);
- _mesa_BlendEquation(color->BlendEquation);
+ /* This special case is because glBlendEquationSeparateEXT
+ * cannot take GL_LOGIC_OP as a parameter.
+ */
+ if ( color->BlendEquationRGB == color->BlendEquationA ) {
+ _mesa_BlendEquation(color->BlendEquationRGB);
+ }
+ else {
+ _mesa_BlendEquationSeparateEXT(color->BlendEquationRGB,
+ color->BlendEquationA);
+ }
_mesa_BlendColor(color->BlendColor[0],
color->BlendColor[1],
color->BlendColor[2],
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 26d87d136c..6741238aae 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -215,52 +215,65 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
#if _HAVE_FULL_GL
-/* This is really an extension function! */
-void GLAPIENTRY
-_mesa_BlendEquation( GLenum mode )
+static GLboolean
+_mesa_validate_blend_equation( GLcontext *ctx,
+ GLenum mode, GLboolean is_separate )
{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug(ctx, "glBlendEquation %s\n",
- _mesa_lookup_enum_by_nr(mode));
-
- switch (mode) {
- case GL_FUNC_ADD_EXT:
+ switch (mode) {
+ case GL_FUNC_ADD:
break;
- case GL_MIN_EXT:
- case GL_MAX_EXT:
+ case GL_MIN:
+ case GL_MAX:
if (!ctx->Extensions.EXT_blend_minmax &&
!ctx->Extensions.ARB_imaging) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
- return;
+ return GL_FALSE;
}
break;
+ /* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter.
+ */
case GL_LOGIC_OP:
- if (!ctx->Extensions.EXT_blend_logic_op) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
- return;
+ if (!ctx->Extensions.EXT_blend_logic_op || is_separate) {
+ return GL_FALSE;
}
break;
- case GL_FUNC_SUBTRACT_EXT:
- case GL_FUNC_REVERSE_SUBTRACT_EXT:
+ case GL_FUNC_SUBTRACT:
+ case GL_FUNC_REVERSE_SUBTRACT:
if (!ctx->Extensions.EXT_blend_subtract &&
!ctx->Extensions.ARB_imaging) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
- return;
+ return GL_FALSE;
}
break;
default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glBlendEquation" );
- return;
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+/* This is really an extension function! */
+void GLAPIENTRY
+_mesa_BlendEquation( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glBlendEquation %s\n",
+ _mesa_lookup_enum_by_nr(mode));
+
+ if ( ! _mesa_validate_blend_equation( ctx, mode, GL_FALSE ) ) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
+ return;
}
- if (ctx->Color.BlendEquation == mode)
+ if ( (ctx->Color.BlendEquationRGB == mode) &&
+ (ctx->Color.BlendEquationA == mode) )
return;
FLUSH_VERTICES(ctx, _NEW_COLOR);
- ctx->Color.BlendEquation = mode;
+ ctx->Color.BlendEquationRGB = mode;
+ ctx->Color.BlendEquationA = mode;
/* This is needed to support 1.1's RGB logic ops AND
* 1.0's blending logicops.
@@ -269,10 +282,55 @@ _mesa_BlendEquation( GLenum mode )
(ctx->Color.BlendEnabled &&
mode == GL_LOGIC_OP));
- if (ctx->Driver.BlendEquation)
- (*ctx->Driver.BlendEquation)( ctx, mode );
+ if (ctx->Driver.BlendEquationSeparate)
+ (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode );
}
+void GLAPIENTRY
+_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glBlendEquationSeparateEXT %s %s\n",
+ _mesa_lookup_enum_by_nr(modeRGB),
+ _mesa_lookup_enum_by_nr(modeA));
+
+ if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBlendEquationSeparateEXT not supported by driver");
+ return;
+ }
+
+ if ( ! _mesa_validate_blend_equation( ctx, modeRGB, GL_TRUE ) ) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)");
+ return;
+ }
+
+ if ( ! _mesa_validate_blend_equation( ctx, modeA, GL_TRUE ) ) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)");
+ return;
+ }
+
+
+ if ( (ctx->Color.BlendEquationRGB == modeRGB) &&
+ (ctx->Color.BlendEquationA == modeA) )
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.BlendEquationRGB = modeRGB;
+ ctx->Color.BlendEquationA = modeA;
+
+ /* This is needed to support 1.1's RGB logic ops AND
+ * 1.0's blending logicops. This test is simplified over glBlendEquation
+ * because modeRGB cannot be GL_LOGIC_OP.
+ */
+ ctx->Color._LogicOpEnabled = (ctx->Color.ColorLogicOpEnabled);
+
+ if (ctx->Driver.BlendEquationSeparate)
+ (*ctx->Driver.BlendEquationSeparate)( ctx, modeRGB, modeA );
+}
#endif
@@ -500,7 +558,8 @@ void _mesa_init_color( GLcontext * ctx )
ctx->Color.BlendDstRGB = GL_ZERO;
ctx->Color.BlendSrcA = GL_ONE;
ctx->Color.BlendDstA = GL_ZERO;
- ctx->Color.BlendEquation = GL_FUNC_ADD_EXT;
+ ctx->Color.BlendEquationRGB = GL_FUNC_ADD;
+ ctx->Color.BlendEquationA = GL_FUNC_ADD;
ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
ctx->Color.IndexLogicOpEnabled = GL_FALSE;
ctx->Color.ColorLogicOpEnabled = GL_FALSE;
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index ae96bd46b6..d6c03d903f 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -50,6 +50,10 @@ _mesa_BlendEquation( GLenum mode );
extern void GLAPIENTRY
+_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA );
+
+
+extern void GLAPIENTRY
_mesa_BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index cb23e0bfad..f9fdd3b92b 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -591,7 +591,7 @@ struct dd_function_table {
/** Set the blend color */
void (*BlendColor)(GLcontext *ctx, const GLfloat color[4]);
/** Set the blend equation */
- void (*BlendEquation)(GLcontext *ctx, GLenum mode);
+ void (*BlendEquationSeparate)(GLcontext *ctx, GLenum modeRGB, GLenum modeA);
/** Specify pixel arithmetic */
void (*BlendFuncSeparate)(GLcontext *ctx,
GLenum sfactorRGB, GLenum dfactorRGB,
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 386744fdea..539e654184 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -170,6 +170,7 @@ typedef enum {
OPCODE_BITMAP,
OPCODE_BLEND_COLOR,
OPCODE_BLEND_EQUATION,
+ OPCODE_BLEND_EQUATION_SEPARATE,
OPCODE_BLEND_FUNC_SEPARATE,
OPCODE_CALL_LIST,
OPCODE_CALL_LIST_OFFSET,
@@ -628,6 +629,7 @@ void _mesa_init_lists( void )
InstSize[OPCODE_BITMAP] = 8;
InstSize[OPCODE_BLEND_COLOR] = 5;
InstSize[OPCODE_BLEND_EQUATION] = 2;
+ InstSize[OPCODE_BLEND_EQUATION_SEPARATE] = 3;
InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
InstSize[OPCODE_CALL_LIST] = 2;
InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
@@ -956,6 +958,23 @@ static void GLAPIENTRY save_BlendEquation( GLenum mode )
}
+static void GLAPIENTRY save_BlendEquationSeparateEXT( GLenum modeRGB,
+ GLenum modeA )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2 );
+ if (n) {
+ n[1].e = modeRGB;
+ n[2].e = modeA;
+ }
+ if (ctx->ExecuteFlag) {
+ (*ctx->Exec->BlendEquationSeparateEXT)( modeRGB, modeA );
+ }
+}
+
+
static void GLAPIENTRY save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA)
{
@@ -5266,6 +5285,9 @@ execute_list( GLcontext *ctx, GLuint list )
case OPCODE_BLEND_EQUATION:
(*ctx->Exec->BlendEquation)( n[1].e );
break;
+ case OPCODE_BLEND_EQUATION_SEPARATE:
+ (*ctx->Exec->BlendEquationSeparateEXT)( n[1].e, n[2].e );
+ break;
case OPCODE_BLEND_FUNC_SEPARATE:
(*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
break;
@@ -7465,6 +7487,9 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
table->MapBufferARB = _mesa_MapBufferARB;
table->UnmapBufferARB = _mesa_UnmapBufferARB;
#endif
+
+ /* 299. GL_EXT_blend_equation_separate */
+ table->BlendEquationSeparateEXT = save_BlendEquationSeparateEXT;
}
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 7f076867f9..64cc4d17ca 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -236,7 +236,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
*/
ctx->Color._LogicOpEnabled =
(ctx->Color.ColorLogicOpEnabled ||
- (state && ctx->Color.BlendEquation == GL_LOGIC_OP));
+ (state && ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
break;
#if FEATURE_userclip
case GL_CLIP_PLANE0:
@@ -384,7 +384,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
*/
ctx->Color._LogicOpEnabled =
(state || (ctx->Color.BlendEnabled &&
- ctx->Color.BlendEquation == GL_LOGIC_OP));
+ ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
break;
case GL_MAP1_COLOR_4:
if (ctx->Eval.Map1Color4 == state)
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 0b512c5793..ac3f633cb3 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -67,6 +67,7 @@ static const struct {
{ ON, "GL_EXT_abgr", 0 },
{ ON, "GL_EXT_bgra", 0 },
{ OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
+ { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
{ OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
{ OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
{ OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
@@ -109,6 +110,7 @@ static const struct {
{ OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
{ OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
{ ON, "GL_APPLE_packed_pixels", 0 },
+ { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
{ OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
{ OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
{ OFF, "GL_HP_occlusion_test", F(HP_occlusion_test) },
@@ -182,6 +184,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
ctx->Extensions.EXT_blend_color = GL_TRUE;
+ ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
ctx->Extensions.EXT_blend_minmax = GL_TRUE;
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 287eae75be..723c48ce3c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -235,8 +235,11 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
case GL_BLEND_DST_ALPHA_EXT:
*params = ENUM_TO_BOOL(ctx->Color.BlendDstA);
break;
- case GL_BLEND_EQUATION_EXT:
- *params = ENUM_TO_BOOL( ctx->Color.BlendEquation );
+ case GL_BLEND_EQUATION:
+ *params = ENUM_TO_BOOL( ctx->Color.BlendEquationRGB );
+ break;
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+ *params = ENUM_TO_BOOL( ctx->Color.BlendEquationA );
break;
case GL_BLEND_COLOR_EXT:
params[0] = FLOAT_TO_BOOL( ctx->Color.BlendColor[0] );
@@ -1777,8 +1780,11 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
case GL_BLEND_DST_ALPHA_EXT:
*params = ENUM_TO_DOUBLE(ctx->Color.BlendDstA);
break;
- case GL_BLEND_EQUATION_EXT:
- *params = ENUM_TO_DOUBLE(ctx->Color.BlendEquation);
+ case GL_BLEND_EQUATION:
+ *params = ENUM_TO_DOUBLE(ctx->Color.BlendEquationRGB);
+ break;
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+ *params = ENUM_TO_DOUBLE(ctx->Color.BlendEquationA);
break;
case GL_BLEND_COLOR_EXT:
params[0] = (GLdouble) ctx->Color.BlendColor[0];
@@ -3314,8 +3320,11 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
case GL_BLEND_DST_ALPHA_EXT:
*params = ENUM_TO_FLOAT(ctx->Color.BlendDstA);
break;
- case GL_BLEND_EQUATION_EXT:
- *params = ENUM_TO_FLOAT(ctx->Color.BlendEquation);
+ case GL_BLEND_EQUATION:
+ *params = ENUM_TO_FLOAT(ctx->Color.BlendEquationRGB);
+ break;
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+ *params = ENUM_TO_FLOAT(ctx->Color.BlendEquationA);
break;
case GL_BLEND_COLOR_EXT:
params[0] = ctx->Color.BlendColor[0];
@@ -4828,8 +4837,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
case GL_BLEND_DST_ALPHA_EXT:
*params = (GLint) ctx->Color.BlendDstA;
break;
- case GL_BLEND_EQUATION_EXT:
- *params = (GLint) ctx->Color.BlendEquation;
+ case GL_BLEND_EQUATION:
+ *params = (GLint) ctx->Color.BlendEquationRGB;
+ break;
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+ *params = (GLint) ctx->Color.BlendEquationA;
break;
case GL_BLEND_COLOR_EXT:
params[0] = FLOAT_TO_INT( ctx->Color.BlendColor[0] );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5e6777efec..5fb9b259ba 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -419,7 +419,8 @@ struct gl_colorbuffer_attrib {
GLenum BlendDstRGB; /**< Blending destination operator */
GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
- GLenum BlendEquation; /**< Blending equation */
+ GLenum BlendEquationRGB; /**< Blending equation */
+ GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
GLfloat BlendColor[4]; /**< Blending color */
/*@}*/
@@ -1771,6 +1772,7 @@ struct gl_extensions
GLboolean ATI_texture_mirror_once;
GLboolean ATI_texture_env_combine3;
GLboolean EXT_blend_color;
+ GLboolean EXT_blend_equation_separate;
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_logic_op;
GLboolean EXT_blend_minmax;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 3e7554f44f..b8a67d0ee3 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -368,6 +368,7 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
#if _HAVE_FULL_GL
exec->BlendColor = _mesa_BlendColor;
exec->BlendEquation = _mesa_BlendEquation;
+ exec->BlendEquationSeparateEXT = _mesa_BlendEquationSeparateEXT;
exec->ColorSubTable = _mesa_ColorSubTable;
exec->ColorTable = _mesa_ColorTable;
exec->ColorTableParameterfv = _mesa_ColorTableParameterfv;