From 876de2831f3b7e68ddaf2e9e0c980111ea55976c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 14 May 2021 19:29:38 -0400 Subject: [PATCH] panfrost: Pull erratum workaround into own function This _does_ need to be draw-time, but it doesn't need to be in the monster routine. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 686b2c349a7..813fe899626 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -506,6 +506,19 @@ panfrost_prepare_bifrost_fs_state(struct panfrost_context *ctx, } } +/* Get the last blend shader, for an erratum workaround */ + +static mali_ptr +panfrost_last_nonnull(mali_ptr *ptrs, unsigned count) +{ + for (signed i = ((signed) count - 1); i >= 0; --i) { + if (ptrs[i]) + return ptrs[i]; + } + + return 0; +} + static void panfrost_prepare_midgard_fs_state(struct panfrost_context *ctx, mali_ptr *blend_shaders, @@ -571,15 +584,8 @@ panfrost_prepare_midgard_fs_state(struct panfrost_context *ctx, state->sfbd_blend_equation.alpha.b = MALI_BLEND_OPERAND_B_SRC; state->sfbd_blend_equation.alpha.c = MALI_BLEND_OPERAND_C_ZERO; } else { - /* Bug where MRT-capable hw apparently reads the last blend - * shader from here instead of the usual location? */ - - for (signed rt = ((signed) rt_count - 1); rt >= 0; --rt) { - if (blend_shaders[rt]) { - state->sfbd_blend_shader = blend_shaders[rt]; - break; - } - } + /* Workaround on v5 */ + state->sfbd_blend_shader = panfrost_last_nonnull(blend_shaders, rt_count); } }