From 1de393fec5394e4423de20f8542f4a20cd1a38df Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 15 Apr 2021 10:10:16 +0200 Subject: [PATCH] panfrost: Fix ZS reloading on Bifrost v6 EARLY_ZS_ALWAYS was introduced in Bifrost v7. Use ALWAYS (or INTERSECT depending on the situation) on v6. Fixes: 8ba2f9f69858 ("panfrost: Create a blitter library to replace the existing preload helpers") Signed-off-by: Boris Brezillon Tested-by: Icecream95 Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/pan_blitter.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c index fe8279084a3..4682598e0be 100644 --- a/src/panfrost/lib/pan_blitter.c +++ b/src/panfrost/lib/pan_blitter.c @@ -987,10 +987,36 @@ pan_preload_emit_bifrost_pre_frame_dcd(struct pan_pool *desc_pool, (dcd_idx * (MALI_DRAW_LENGTH + MALI_DRAW_PADDING_LENGTH)); pan_preload_emit_dcd(desc_pool, fb, zs, coords, tsd, rsd, dcd); - fb->bifrost.pre_post.modes[dcd_idx] = - zs ? - MALI_PRE_POST_FRAME_SHADER_MODE_EARLY_ZS_ALWAYS : - MALI_PRE_POST_FRAME_SHADER_MODE_INTERSECT; + if (zs) { + enum pipe_format fmt = fb->zs.view.zs->image->layout.format; + bool always = false; + + /* If we're dealing with a combined ZS resource and only one + * component is cleared, we need to reload the whole surface + * because the zs_clean_pixel_write_enable flag is set in that + * case. + */ + if (util_format_is_depth_and_stencil(fmt) && + fb->zs.clear.z != fb->zs.clear.s) + always = true; + + /* We could use INTERSECT on Bifrost v7 too, but + * EARLY_ZS_ALWAYS has the advantage of reloading the ZS tile + * buffer one or more tiles ahead, making ZS data immediately + * available for any ZS tests taking place in other shaders. + * Thing's haven't been benchmarked to determine what's + * preferable (saving bandwidth vs having ZS preloaded + * earlier), so let's leave it like that for now. + */ + fb->bifrost.pre_post.modes[dcd_idx] = + desc_pool->dev->arch > 6 ? + MALI_PRE_POST_FRAME_SHADER_MODE_EARLY_ZS_ALWAYS : + always ? MALI_PRE_POST_FRAME_SHADER_MODE_ALWAYS : + MALI_PRE_POST_FRAME_SHADER_MODE_INTERSECT; + } else { + fb->bifrost.pre_post.modes[dcd_idx] = + MALI_PRE_POST_FRAME_SHADER_MODE_INTERSECT; + } } static void