etnaviv: optimize resource copies by skipping clean levels
authorLucas Stach <l.stach@pengutronix.de>
Fri, 18 Nov 2022 10:04:24 +0000 (11:04 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 14 Jul 2023 14:21:35 +0000 (14:21 +0000)
If we sync/flush a full resource we can skip any level where the
target is of the same age as the source.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19964>

src/gallium/drivers/etnaviv/etnaviv_clear_blit.c

index 4422571..0b077ad 100644 (file)
@@ -217,6 +217,15 @@ etna_copy_resource(struct pipe_context *pctx, struct pipe_resource *dst,
 
    /* Copy each level and each layer */
    for (int level = first_level; level <= last_level; level++) {
+      /* skip levels that don't need to be flushed or are of the same age */
+      if (src == dst) {
+         if (!etna_resource_level_needs_flush(&src_priv->levels[level]))
+            continue;
+      } else {
+         if (!etna_resource_level_older(&dst_priv->levels[level], &src_priv->levels[level]))
+            continue;
+      }
+
       blit.src.level = blit.dst.level = level;
       blit.src.box.width = blit.dst.box.width =
          MIN2(src_priv->levels[level].padded_width, dst_priv->levels[level].padded_width);