From cbf68b21fb2b6baf4578c98dd7e91855aa6dfa62 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 17 Dec 2020 10:33:50 +0100 Subject: [PATCH] panfrost: Move checksum_bo to panfrost_resource There's no reason to have the checksum_bo at the slice level since there can only be one external CRC BO per resource. Move this field to the panfrost_resource struct. Suggested-by: Icecream95 Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_job.c | 4 ++-- src/gallium/drivers/panfrost/pan_mfbd.c | 4 ++-- src/gallium/drivers/panfrost/pan_resource.c | 10 +++++----- src/gallium/drivers/panfrost/pan_resource.h | 3 +++ src/panfrost/lib/pan_texture.h | 1 - 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index c30fe15fd29..3304c469080 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -558,8 +558,8 @@ panfrost_batch_add_resource_bos(struct panfrost_batch *batch, panfrost_batch_add_bo(batch, rsrc->bo, flags); for (unsigned i = 0; i < MAX_MIP_LEVELS; i++) - if (rsrc->slices[i].checksum_bo) - panfrost_batch_add_bo(batch, rsrc->slices[i].checksum_bo, flags); + if (rsrc->checksum_bo) + panfrost_batch_add_bo(batch, rsrc->checksum_bo, flags); if (rsrc->separate_stencil) panfrost_batch_add_bo(batch, rsrc->separate_stencil->bo, flags); diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index bcf78814c02..7cc1aa8cda8 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -257,8 +257,8 @@ panfrost_mfbd_zs_crc_ext_set_bufs(struct panfrost_batch *batch, struct panfrost_slice *slice = &rsrc->slices[level]; ext->crc_row_stride = slice->checksum_stride; - if (slice->checksum_bo) - ext->crc_base = slice->checksum_bo->ptr.gpu; + if (rsrc->checksum_bo) + ext->crc_base = rsrc->checksum_bo->ptr.gpu; else ext->crc_base = rsrc->bo->ptr.gpu + slice->checksum_offset; diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 64c0d0948fb..bf8ec468cf2 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -120,7 +120,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, templat->bind & PIPE_BIND_RENDER_TARGET) { unsigned size = panfrost_compute_checksum_size( &rsc->slices[0], templat->width0, templat->height0); - rsc->slices[0].checksum_bo = panfrost_bo_create(dev, size, 0); + rsc->checksum_bo = panfrost_bo_create(dev, size, 0); rsc->checksummed = true; } @@ -709,8 +709,8 @@ 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); + if (rsrc->checksum_bo) + panfrost_bo_unreference(rsrc->checksum_bo); util_range_destroy(&rsrc->valid_buffer_range); ralloc_free(rsrc); @@ -1036,8 +1036,8 @@ panfrost_ptr_unmap(struct pipe_context *pctx, if (panfrost_should_linear_convert(prsrc, transfer)) { panfrost_bo_unreference(prsrc->bo); - if (prsrc->slices[0].checksum_bo) - panfrost_bo_unreference(prsrc->slices[0].checksum_bo); + if (prsrc->checksum_bo) + panfrost_bo_unreference(prsrc->checksum_bo); panfrost_resource_setup(dev, prsrc, NULL, DRM_FORMAT_MOD_LINEAR); diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h index 1de0051b90c..183af68b917 100644 --- a/src/gallium/drivers/panfrost/pan_resource.h +++ b/src/gallium/drivers/panfrost/pan_resource.h @@ -67,6 +67,9 @@ struct panfrost_resource { /* Is transaciton elimination enabled? */ bool checksummed; + /* The CRC BO can be allocated separately */ + struct panfrost_bo *checksum_bo; + /* Used to decide when to convert to another modifier */ uint16_t modifier_updates; diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h index 943c9d06f1b..5aebaaef454 100644 --- a/src/panfrost/lib/pan_texture.h +++ b/src/panfrost/lib/pan_texture.h @@ -52,7 +52,6 @@ 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;