From 8249e2b9a23dfa45e8e235a188fb183d609eac96 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 17 Aug 2020 19:41:48 -0400 Subject: [PATCH] panfrost: Explicitly handle nr_cbufs=0 case Avoids some indirection around colour buffer count. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Tomeu Vizoso Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 27 ++++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index d3bbf40f6dc..699b48777cb 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -551,7 +551,7 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx, ctx->blend->base.alpha_to_coverage); /* Get blending setup */ - unsigned rt_count = MAX2(ctx->pipe_framebuffer.nr_cbufs, 1); + unsigned rt_count = ctx->pipe_framebuffer.nr_cbufs; struct panfrost_blend_final blend[PIPE_MAX_COLOR_BUFS]; @@ -592,7 +592,7 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx, fragmeta->blend.shader = 0; - for (signed rt = (rt_count - 1); rt >= 0; --rt) { + for (signed rt = ((signed) rt_count - 1); rt >= 0; --rt) { if (!blend[rt].is_shader) continue; @@ -634,16 +634,22 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx, /* Additional blend descriptor tacked on for jobs using MFBD */ + struct bifrost_blend_rt *brts = rts; + struct midgard_blend_rt *mrts = rts; + + /* Disable blending for depth-only on Bifrost */ + + if (rt_count == 0 && dev->quirks & IS_BIFROST) + brts[0].unk2 = 0x3; + for (unsigned i = 0; i < rt_count; ++i) { unsigned flags = 0; - if (ctx->pipe_framebuffer.nr_cbufs > i && !blend[i].no_colour) { + if (!blend[i].no_colour) { flags = 0x200; batch->draws |= (PIPE_CLEAR_COLOR0 << i); - bool is_srgb = (ctx->pipe_framebuffer.nr_cbufs > i) && - (ctx->pipe_framebuffer.cbufs[i]) && - util_format_is_srgb(ctx->pipe_framebuffer.cbufs[i]->format); + bool is_srgb = util_format_is_srgb(ctx->pipe_framebuffer.cbufs[i]->format); SET_BIT(flags, MALI_BLEND_MRT_SHADER, blend[i].is_shader); SET_BIT(flags, MALI_BLEND_LOAD_TIB, !blend[i].no_blending); @@ -652,8 +658,6 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx, } if (dev->quirks & IS_BIFROST) { - struct bifrost_blend_rt *brts = rts; - brts[i].flags = flags; if (blend[i].is_shader) { @@ -665,7 +669,7 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx, (fs->bo->gpu & (0xffffffffull << 32))); brts[i].shader = blend[i].shader.gpu; brts[i].unk2 = 0x0; - } else if (ctx->pipe_framebuffer.nr_cbufs > i) { + } else { enum pipe_format format = ctx->pipe_framebuffer.cbufs[i]->format; const struct util_format_description *format_desc; format_desc = util_format_description(format); @@ -683,14 +687,9 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx, * blending. */ brts[i].unk2 = blend[i].no_blending ? 0x19 : 0x1a; - brts[i].shader_type = fs->blend_types[i]; - } else { - /* Dummy attachment for depth-only */ - brts[i].unk2 = 0x3; brts[i].shader_type = fs->blend_types[i]; } } else { - struct midgard_blend_rt *mrts = rts; mrts[i].flags = flags; if (blend[i].is_shader) { -- 2.30.2