Module: Mesa
Branch: main
Commit: 8c8741a17e218ea87b2637f4f14cf0705ec39e7d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c8741a17e218ea87b2637f4f14cf0705ec39e7d

Author: Lucas Stach <[email protected]>
Date:   Fri Jul 14 17:47:07 2023 +0200

etnaviv: split etna_copy_resource_box levels parameter in src/dst

Allow to copy between different level in the source and destination
resource.

Signed-off-by: Lucas Stach <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24164>

---

 src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 12 +++++++-----
 src/gallium/drivers/etnaviv/etnaviv_clear_blit.h |  2 +-
 src/gallium/drivers/etnaviv/etnaviv_transfer.c   |  5 +++--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
index 9393a1caf00..adba89af620 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
@@ -251,7 +251,7 @@ etna_copy_resource(struct pipe_context *pctx, struct 
pipe_resource *dst,
 
 void
 etna_copy_resource_box(struct pipe_context *pctx, struct pipe_resource *dst,
-                       struct pipe_resource *src, int level,
+                       struct pipe_resource *src, int dst_level, int src_level,
                        struct pipe_box *box)
 {
    struct etna_resource *src_priv = etna_resource(src);
@@ -259,7 +259,7 @@ etna_copy_resource_box(struct pipe_context *pctx, struct 
pipe_resource *dst,
 
    assert(src->format == dst->format);
    assert(src->array_size == dst->array_size);
-   assert(!etna_resource_level_needs_flush(&dst_priv->levels[level]));
+   assert(!etna_resource_level_needs_flush(&dst_priv->levels[dst_level]));
 
    struct pipe_blit_info blit = {};
    blit.mask = util_format_get_mask(dst->format);
@@ -272,7 +272,8 @@ etna_copy_resource_box(struct pipe_context *pctx, struct 
pipe_resource *dst,
    blit.dst.box = *box;
 
    blit.dst.box.depth = blit.src.box.depth = 1;
-   blit.src.level = blit.dst.level = level;
+   blit.src.level = src_level;
+   blit.dst.level = dst_level;
 
    for (int z = 0; z < box->depth; z++) {
       blit.src.box.z = blit.dst.box.z = box->z + z;
@@ -280,9 +281,10 @@ etna_copy_resource_box(struct pipe_context *pctx, struct 
pipe_resource *dst,
    }
 
    if (src == dst)
-      etna_resource_level_mark_flushed(&dst_priv->levels[level]);
+      etna_resource_level_mark_flushed(&dst_priv->levels[dst_level]);
    else
-      etna_resource_level_copy_seqno(&dst_priv->levels[level], 
&src_priv->levels[level]);
+      etna_resource_level_copy_seqno(&dst_priv->levels[dst_level],
+                                     &src_priv->levels[src_level]);
 }
 
 void
diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h 
b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h
index 2348f207abc..9a1982cd402 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h
@@ -44,7 +44,7 @@ etna_copy_resource(struct pipe_context *pctx, struct 
pipe_resource *dst,
 
 void
 etna_copy_resource_box(struct pipe_context *pctx, struct pipe_resource *dst,
-                       struct pipe_resource *src, int level,
+                       struct pipe_resource *src, int dst_level, int src_level,
                        struct pipe_box *box);
 
 void
diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
index 2a6a4f8b5e7..07159f91132 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
@@ -140,7 +140,8 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
pipe_transfer *ptrans)
          /* We have a temporary resource due to either tile status or
           * tiling format. Write back the updated buffer contents.
           */
-         etna_copy_resource_box(pctx, ptrans->resource, trans->rsc, 
ptrans->level, &ptrans->box);
+         etna_copy_resource_box(pctx, ptrans->resource, trans->rsc,
+                                ptrans->level, ptrans->level, &ptrans->box);
       } else if (trans->staging) {
          /* map buffer object */
          if (rsc->layout == ETNA_LAYOUT_TILED) {
@@ -324,7 +325,7 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
       }
 
       if ((usage & PIPE_MAP_READ) || !(usage & ETNA_PIPE_MAP_DISCARD_LEVEL))
-         etna_copy_resource_box(pctx, trans->rsc, &rsc->base, level, 
&ptrans->box);
+         etna_copy_resource_box(pctx, trans->rsc, &rsc->base, level, level, 
&ptrans->box);
 
       /* Switch to using the temporary resource instead */
       rsc = etna_resource(trans->rsc);

Reply via email to