From ccbd1254684fde0efed0a87a1e19ba48c3c20d64 Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Sat, 22 Jul 2023 18:35:42 +0900 Subject: [PATCH] asahi: Always use resource size, not BO size BOs can be oversized, as they can come from the BO cache. Make sure to always use the resource layout size, not the BO size, when we need this for some reason. This fixes BO shadowing creating overlarge BOs, and also the attachment size for submissions (probably doesn't matter, but it's more correct now). Signed-off-by: Asahi Lina Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 5a0fa7f..dce48fb 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -658,6 +658,7 @@ agx_shadow(struct agx_context *ctx, struct agx_resource *rsrc, bool needs_copy) { struct agx_device *dev = agx_device(ctx->base.screen); struct agx_bo *old = rsrc->bo; + size_t size = rsrc->layout.size_B; unsigned flags = old->flags; if (dev->debug & AGX_DBG_NOSHADOW) @@ -678,17 +679,17 @@ agx_shadow(struct agx_context *ctx, struct agx_resource *rsrc, bool needs_copy) if (needs_copy) flags |= AGX_BO_WRITEBACK; - struct agx_bo *new_ = agx_bo_create(dev, old->size, flags, old->label); + struct agx_bo *new_ = agx_bo_create(dev, size, flags, old->label); /* If allocation failed, we can fallback on a flush gracefully*/ if (new_ == NULL) return false; if (needs_copy) { - perf_debug_ctx(ctx, "Shadowing %zu bytes on the CPU (%s)", old->size, + perf_debug_ctx(ctx, "Shadowing %zu bytes on the CPU (%s)", size, (old->flags & AGX_BO_WRITEBACK) ? "cached" : "uncached"); - memcpy(new_->ptr.cpu, old->ptr.cpu, old->size); + memcpy(new_->ptr.cpu, old->ptr.cpu, size); } /* Swap the pointers, dropping a reference */ -- 2.7.4