[Mesa-dev] [PATCH 2/5] st/mesa: don't check for ARB_draw_buffers_blend in update_blend

Timothy Arceri tarceri at itsqueeze.com
Wed Feb 7 22:56:13 UTC 2018


On 01/02/18 06:55, Marek Olšák wrote> From: Marek Olšák 
<marek.olsak at amd.com>
> 
> If the GL API is missing, different blend functions can't be set
> through GL.

Looking at the commit that added this a476ca1fd1b4e7 the commit message is:

"st/mesa: Use blend equation and function of first render target for all 
render targets if ARB_draw_buffers_blend is not supported

     If EXT_draw_buffers2 is supported but ARB_draw_buffers_blend isn't
     _mesa_BlendFuncSeparateEXT only sets up the blend equation and 
function for the
     first render target. This patch makes sure that update_blend 
doesn't try to use
     the data from other rendertargets in such cases"

So it seems to me that before this patch we should probably have a patch 
the commbines the two caps PIPE_CAP_INDEP_BLEND_ENABLE and 
PIPE_CAP_INDEP_BLEND_FUNC.

If you agree that patch and this one are:

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>


> ---
>   src/mesa/state_tracker/st_atom_blend.c | 20 ++++++++------------
>   1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c
> index f7327d6..8f644ba 100644
> --- a/src/mesa/state_tracker/st_atom_blend.c
> +++ b/src/mesa/state_tracker/st_atom_blend.c
> @@ -138,72 +138,68 @@ blend_per_rt(const struct gl_context *ctx)
>      }
>      return GL_FALSE;
>   }
>   
>   void
>   st_update_blend( struct st_context *st )
>   {
>      struct pipe_blend_state *blend = &st->state.blend;
>      const struct gl_context *ctx = st->ctx;
>      unsigned num_state = 1;
> -   unsigned i, j;
> +   unsigned i;
>   
>      memset(blend, 0, sizeof(*blend));
>   
>      if (blend_per_rt(ctx) || colormask_per_rt(ctx)) {
>         num_state = ctx->Const.MaxDrawBuffers;
>         blend->independent_blend_enable = 1;
>      }
>      if (ctx->Color.ColorLogicOpEnabled) {
>         /* logicop enabled */
>         blend->logicop_enable = 1;
>         blend->logicop_func = ctx->Color._LogicOp;
>      }
>      else if (ctx->Color.BlendEnabled && !ctx->Color._AdvancedBlendMode) {
>         /* blending enabled */
> -      for (i = 0, j = 0; i < num_state; i++) {
> -
> +      for (i = 0; i < num_state; i++) {
>            blend->rt[i].blend_enable = (ctx->Color.BlendEnabled >> i) & 0x1;
>   
> -         if (ctx->Extensions.ARB_draw_buffers_blend)
> -            j = i;
> -
>            blend->rt[i].rgb_func =
> -            translate_blend(ctx->Color.Blend[j].EquationRGB);
> +            translate_blend(ctx->Color.Blend[i].EquationRGB);
>   
>            if (ctx->Color.Blend[i].EquationRGB == GL_MIN ||
>                ctx->Color.Blend[i].EquationRGB == GL_MAX) {
>               /* Min/max are special */
>               blend->rt[i].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
>               blend->rt[i].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
>            }
>            else {
>               blend->rt[i].rgb_src_factor =
> -               translate_blend(ctx->Color.Blend[j].SrcRGB);
> +               translate_blend(ctx->Color.Blend[i].SrcRGB);
>               blend->rt[i].rgb_dst_factor =
> -               translate_blend(ctx->Color.Blend[j].DstRGB);
> +               translate_blend(ctx->Color.Blend[i].DstRGB);
>            }
>   
>            blend->rt[i].alpha_func =
> -            translate_blend(ctx->Color.Blend[j].EquationA);
> +            translate_blend(ctx->Color.Blend[i].EquationA);
>   
>            if (ctx->Color.Blend[i].EquationA == GL_MIN ||
>                ctx->Color.Blend[i].EquationA == GL_MAX) {
>               /* Min/max are special */
>               blend->rt[i].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
>               blend->rt[i].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
>            }
>            else {
>               blend->rt[i].alpha_src_factor =
> -               translate_blend(ctx->Color.Blend[j].SrcA);
> +               translate_blend(ctx->Color.Blend[i].SrcA);
>               blend->rt[i].alpha_dst_factor =
> -               translate_blend(ctx->Color.Blend[j].DstA);
> +               translate_blend(ctx->Color.Blend[i].DstA);
>            }
>         }
>      }
>      else {
>         /* no blending / logicop */
>      }
>   
>      for (i = 0; i < num_state; i++)
>         blend->rt[i].colormask = GET_COLORMASK(ctx->Color.ColorMask, i);
>   
> 


More information about the mesa-dev mailing list