From 4d581a4bc6ad51b3c5478d46dd2f52f7c86a2974 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Mon, 27 Apr 2020 16:49:22 +0200 Subject: [PATCH] panfrost: Create additional BO for the checksum of imported BOs (Bifrost) Similar to what the blob does. My reason for doing this was mainly so traces weren't as different, which makes it more work to spot relevant differences. Signed-off-by: Tomeu Vizoso Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_mfbd.c | 6 ++++-- src/gallium/drivers/panfrost/pan_resource.c | 11 +++++++++++ src/panfrost/encoder/pan_texture.h | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index 2c011fda002..1350e17485a 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -502,7 +502,6 @@ panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws) if (batch->key.nr_cbufs == 1) { struct pipe_surface *surf = batch->key.cbufs[0]; struct panfrost_resource *rsrc = pan_resource(surf->texture); - struct panfrost_bo *bo = rsrc->bo; if (rsrc->checksummed) { unsigned level = surf->u.tex.level; @@ -511,7 +510,10 @@ panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws) fb.mfbd_flags |= MALI_MFBD_EXTRA; fbx.flags_lo |= MALI_EXTRA_PRESENT; fbx.checksum_stride = slice->checksum_stride; - fbx.checksum = bo->gpu + slice->checksum_offset; + if (slice->checksum_bo) + fbx.checksum = slice->checksum_bo->gpu; + else + fbx.checksum = rsrc->bo->gpu + slice->checksum_offset; } } diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 3505f373788..443df15d257 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -109,6 +109,14 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, rsc->slices[0].initialized = true; panfrost_resource_reset_damage(rsc); + if (dev->quirks & IS_BIFROST && + templat->bind & PIPE_BIND_RENDER_TARGET) { + unsigned size = panfrost_compute_checksum_size( + &rsc->slices[0], templat->width0, templat->height0); + rsc->slices[0].checksum_bo = pan_bo_create(dev, size, 0); + rsc->checksummed = true; + } + if (dev->ro) { rsc->scanout = renderonly_create_gpu_import_for_resource(prsc, dev->ro, NULL); @@ -550,6 +558,9 @@ panfrost_resource_destroy(struct pipe_screen *screen, if (rsrc->bo) panfrost_bo_unreference(rsrc->bo); + if (rsrc->slices[0].checksum_bo) + panfrost_bo_unreference(rsrc->slices[0].checksum_bo); + util_range_destroy(&rsrc->valid_buffer_range); ralloc_free(rsrc); } diff --git a/src/panfrost/encoder/pan_texture.h b/src/panfrost/encoder/pan_texture.h index 5bcda798ac3..591efd86c68 100644 --- a/src/panfrost/encoder/pan_texture.h +++ b/src/panfrost/encoder/pan_texture.h @@ -46,6 +46,7 @@ struct panfrost_slice { * is its offset/stride? */ unsigned checksum_offset; unsigned checksum_stride; + struct panfrost_bo *checksum_bo; /* Has anything been written to this slice? */ bool initialized; -- 2.30.2