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 <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10869>
This commit is contained in:
Alyssa Rosenzweig
2021-05-14 19:29:38 -04:00
committed by Marge Bot
parent 672079e592
commit 876de2831f

View File

@@ -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);
}
}