diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/blend.c | 20 | ||||
-rw-r--r-- | src/mesa/main/context.c | 24 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 5 |
3 files changed, 32 insertions, 17 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index bc446edcabb..5bc40a028bd 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -166,6 +166,24 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) _mesa_BlendFuncSeparateEXT(sfactor, dfactor, sfactor, dfactor); } +static GLboolean +blend_factor_is_dual_src(GLenum factor) +{ + return (factor == GL_SRC1_COLOR || + factor == GL_SRC1_ALPHA || + factor == GL_ONE_MINUS_SRC1_COLOR || + factor == GL_ONE_MINUS_SRC1_ALPHA); +} + +static void +update_uses_dual_src(struct gl_context *ctx, int buf) +{ + ctx->Color.Blend[buf]._UsesDualSrc = + (blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcRGB) || + blend_factor_is_dual_src(ctx->Color.Blend[buf].DstRGB) || + blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcA) || + blend_factor_is_dual_src(ctx->Color.Blend[buf].DstA)); +} /** * Set the separate blend source/dest factors for all draw buffers. @@ -220,6 +238,7 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, ctx->Color.Blend[buf].DstRGB = dfactorRGB; ctx->Color.Blend[buf].SrcA = sfactorA; ctx->Color.Blend[buf].DstA = dfactorA; + update_uses_dual_src(ctx, buf); } ctx->Color._BlendFuncPerBuffer = GL_FALSE; @@ -282,6 +301,7 @@ _mesa_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, ctx->Color.Blend[buf].DstRGB = dfactorRGB; ctx->Color.Blend[buf].SrcA = sfactorA; ctx->Color.Blend[buf].DstA = dfactorA; + update_uses_dual_src(ctx, buf); ctx->Color._BlendFuncPerBuffer = GL_TRUE; if (ctx->Driver.BlendFuncSeparatei) { diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index df0452cd114..3bcedecd9ba 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1703,13 +1703,6 @@ _mesa_set_mvp_with_dp4( struct gl_context *ctx, ctx->mvp_with_dp4 = flag; } -static GLboolean -blend_factor_is_dual_src(GLenum factor) -{ - return factor == GL_SRC1_COLOR || factor == GL_SRC1_ALPHA || - factor == GL_ONE_MINUS_SRC1_COLOR || factor == GL_ONE_MINUS_SRC1_ALPHA; -} - /* * ARB_blend_func_extended - ERRORS section * "The error INVALID_OPERATION is generated by Begin or any procedure that @@ -1722,16 +1715,13 @@ static GLboolean _mesa_check_blend_func_error(struct gl_context *ctx) { GLuint i; - for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { - if (blend_factor_is_dual_src(ctx->Color.Blend[i].SrcRGB) || - blend_factor_is_dual_src(ctx->Color.Blend[i].DstRGB) || - blend_factor_is_dual_src(ctx->Color.Blend[i].SrcA) || - blend_factor_is_dual_src(ctx->Color.Blend[i].DstA)) { - if (i >= ctx->Const.MaxDualSourceDrawBuffers) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "dual source blend on illegal attachment"); - return GL_FALSE; - } + for (i = ctx->Const.MaxDualSourceDrawBuffers; + i < ctx->DrawBuffer->_NumColorDrawBuffers; + i++) { + if (ctx->Color.Blend[i]._UsesDualSrc) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "dual source blend on illegal attachment"); + return GL_FALSE; } } return GL_TRUE; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index eefe5e7e97d..3a8cac9c5a1 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -755,6 +755,11 @@ struct gl_colorbuffer_attrib GLenum DstA; /**< Alpha blend dest term */ GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */ GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */ + /** + * Set if any blend factor uses SRC1. Computed at the time blend factors + * get set. + */ + GLboolean _UsesDualSrc; } Blend[MAX_DRAW_BUFFERS]; /** Are the blend func terms currently different for each buffer/target? */ GLboolean _BlendFuncPerBuffer; |