mesa: Keep a computed value for dual source blend func with each buffer.
The i965 driver needed this as well for hardware setup, so instead of duplicating the logic, just save it off. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -166,6 +166,24 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
|
|||||||
_mesa_BlendFuncSeparateEXT(sfactor, dfactor, sfactor, 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.
|
* 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].DstRGB = dfactorRGB;
|
||||||
ctx->Color.Blend[buf].SrcA = sfactorA;
|
ctx->Color.Blend[buf].SrcA = sfactorA;
|
||||||
ctx->Color.Blend[buf].DstA = dfactorA;
|
ctx->Color.Blend[buf].DstA = dfactorA;
|
||||||
|
update_uses_dual_src(ctx, buf);
|
||||||
}
|
}
|
||||||
ctx->Color._BlendFuncPerBuffer = GL_FALSE;
|
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].DstRGB = dfactorRGB;
|
||||||
ctx->Color.Blend[buf].SrcA = sfactorA;
|
ctx->Color.Blend[buf].SrcA = sfactorA;
|
||||||
ctx->Color.Blend[buf].DstA = dfactorA;
|
ctx->Color.Blend[buf].DstA = dfactorA;
|
||||||
|
update_uses_dual_src(ctx, buf);
|
||||||
ctx->Color._BlendFuncPerBuffer = GL_TRUE;
|
ctx->Color._BlendFuncPerBuffer = GL_TRUE;
|
||||||
|
|
||||||
if (ctx->Driver.BlendFuncSeparatei) {
|
if (ctx->Driver.BlendFuncSeparatei) {
|
||||||
|
@@ -1703,13 +1703,6 @@ _mesa_set_mvp_with_dp4( struct gl_context *ctx,
|
|||||||
ctx->mvp_with_dp4 = flag;
|
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
|
* ARB_blend_func_extended - ERRORS section
|
||||||
* "The error INVALID_OPERATION is generated by Begin or any procedure that
|
* "The error INVALID_OPERATION is generated by Begin or any procedure that
|
||||||
@@ -1722,18 +1715,15 @@ static GLboolean
|
|||||||
_mesa_check_blend_func_error(struct gl_context *ctx)
|
_mesa_check_blend_func_error(struct gl_context *ctx)
|
||||||
{
|
{
|
||||||
GLuint i;
|
GLuint i;
|
||||||
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
|
for (i = ctx->Const.MaxDualSourceDrawBuffers;
|
||||||
if (blend_factor_is_dual_src(ctx->Color.Blend[i].SrcRGB) ||
|
i < ctx->DrawBuffer->_NumColorDrawBuffers;
|
||||||
blend_factor_is_dual_src(ctx->Color.Blend[i].DstRGB) ||
|
i++) {
|
||||||
blend_factor_is_dual_src(ctx->Color.Blend[i].SrcA) ||
|
if (ctx->Color.Blend[i]._UsesDualSrc) {
|
||||||
blend_factor_is_dual_src(ctx->Color.Blend[i].DstA)) {
|
|
||||||
if (i >= ctx->Const.MaxDualSourceDrawBuffers) {
|
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
"dual source blend on illegal attachment");
|
"dual source blend on illegal attachment");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -755,6 +755,11 @@ struct gl_colorbuffer_attrib
|
|||||||
GLenum DstA; /**< Alpha blend dest term */
|
GLenum DstA; /**< Alpha blend dest term */
|
||||||
GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
|
GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
|
||||||
GLenum EquationA; /**< 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];
|
} Blend[MAX_DRAW_BUFFERS];
|
||||||
/** Are the blend func terms currently different for each buffer/target? */
|
/** Are the blend func terms currently different for each buffer/target? */
|
||||||
GLboolean _BlendFuncPerBuffer;
|
GLboolean _BlendFuncPerBuffer;
|
||||||
|
Reference in New Issue
Block a user