[virglrenderer-devel] [PATCH 2/3] fix rewriting of non-alpha formats

Dave Airlie airlied at gmail.com
Tue Jul 10 07:07:31 UTC 2018


This seemed like a bug in master anyways, I've rebased this and pushed it,
didn't see any piglit regressions.

Dave.


On 3 July 2018 at 16:04, Erik Faye-Lund <erik.faye-lund at collabora.com> wrote:
> When we use independent blending, we need to check every rendertarget
> indevidually, not just once for all, otherwise we end up using the
> wrong blend-mode for some render-targets.
>
> Fixes these test-cases:
> dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.0
> dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.6
> dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.14
>
> Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
> ---
>  src/vrend_renderer.c | 52 ++++++++++++++++----------------------------
>  1 file changed, 19 insertions(+), 33 deletions(-)
>
> diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> index 3b3982b..c19ab45 100644
> --- a/src/vrend_renderer.c
> +++ b/src/vrend_renderer.c
> @@ -3631,46 +3631,32 @@ static void vrend_patch_blend_state(struct vrend_context *ctx)
>  {
>     struct pipe_blend_state new_state = ctx->sub->blend_state;
>     struct pipe_blend_state *state = &ctx->sub->blend_state;
> -   bool dest_alpha_only = false, dest_has_no_alpha = false;
>     int i;
>
>     if (ctx->sub->nr_cbufs == 0)
>        return;
>
> -   for (i = 0; i < ctx->sub->nr_cbufs; i++) {
> -      if (!ctx->sub->surf[i])
> -         continue;
> -
> -      if (vrend_format_is_emulated_alpha(ctx->sub->surf[i]->format)) {
> -         dest_alpha_only = true;
> -      }
> -
> -      if (!util_format_has_alpha(ctx->sub->surf[i]->format)) {
> -         dest_has_no_alpha = true;
> -      }
> -   }
> -
> -   if (dest_alpha_only) {
> -      for (i = 0; i < (state->independent_blend_enable ? PIPE_MAX_COLOR_BUFS : 1); i++) {
> -         if (state->rt[i].blend_enable) {
> -            new_state.rt[i].rgb_src_factor = conv_a8_blend(state->rt[i].alpha_src_factor);
> -            new_state.rt[i].rgb_dst_factor = conv_a8_blend(state->rt[i].alpha_dst_factor);
> -            new_state.rt[i].alpha_src_factor = PIPE_BLENDFACTOR_ZERO;
> -            new_state.rt[i].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
> +   for (i = 0; i < (state->independent_blend_enable ? PIPE_MAX_COLOR_BUFS : 1); i++) {
> +      if (i < ctx->sub->nr_cbufs && ctx->sub->surf[i]) {
> +         if (vrend_format_is_emulated_alpha(ctx->sub->surf[i]->format)) {
> +            if (state->rt[i].blend_enable) {
> +               new_state.rt[i].rgb_src_factor = conv_a8_blend(state->rt[i].alpha_src_factor);
> +               new_state.rt[i].rgb_dst_factor = conv_a8_blend(state->rt[i].alpha_dst_factor);
> +               new_state.rt[i].alpha_src_factor = PIPE_BLENDFACTOR_ZERO;
> +               new_state.rt[i].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
> +            }
> +         } else if (!util_format_has_alpha(ctx->sub->surf[i]->format)) {
> +            if (!(is_dst_blend(state->rt[i].rgb_src_factor) ||
> +                  is_dst_blend(state->rt[i].rgb_dst_factor) ||
> +                  is_dst_blend(state->rt[i].alpha_src_factor) ||
> +                  is_dst_blend(state->rt[i].alpha_dst_factor)))
> +               continue;
> +            new_state.rt[i].rgb_src_factor = conv_dst_blend(state->rt[i].rgb_src_factor);
> +            new_state.rt[i].rgb_dst_factor = conv_dst_blend(state->rt[i].rgb_dst_factor);
> +            new_state.rt[i].alpha_src_factor = conv_dst_blend(state->rt[i].alpha_src_factor);
> +            new_state.rt[i].alpha_dst_factor = conv_dst_blend(state->rt[i].alpha_dst_factor);
>           }
>        }
> -   } else if (dest_has_no_alpha) {
> -      for (i = 0; i < (state->independent_blend_enable ? PIPE_MAX_COLOR_BUFS : 1); i++) {
> -         if (!(is_dst_blend(state->rt[i].rgb_src_factor) ||
> -               is_dst_blend(state->rt[i].rgb_dst_factor) ||
> -               is_dst_blend(state->rt[i].alpha_src_factor) ||
> -               is_dst_blend(state->rt[i].alpha_dst_factor)))
> -            continue;
> -         new_state.rt[i].rgb_src_factor = conv_dst_blend(state->rt[i].rgb_src_factor);
> -         new_state.rt[i].rgb_dst_factor = conv_dst_blend(state->rt[i].rgb_dst_factor);
> -         new_state.rt[i].alpha_src_factor = conv_dst_blend(state->rt[i].alpha_src_factor);
> -         new_state.rt[i].alpha_dst_factor = conv_dst_blend(state->rt[i].alpha_dst_factor);
> -      }
>     }
>
>     vrend_hw_emit_blend(ctx, &new_state);
> --
> 2.18.0.rc2
>
> _______________________________________________
> virglrenderer-devel mailing list
> virglrenderer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel


More information about the virglrenderer-devel mailing list