Mesa (master): panfrost: Seperate resource setup and bo creation
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Sep 9 12:04:33 UTC 2020
Module: Mesa
Branch: master
Commit: c35645320592acfb8548b5db4bb3d43cc3608c8a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c35645320592acfb8548b5db4bb3d43cc3608c8a
Author: Icecream95 <ixn at keemail.me>
Date: Sat Sep 5 10:16:04 2020 +1200
panfrost: Seperate resource setup and bo creation
This will make it easier to convert between modifiers without
unnecessarily creating a new bo.
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6608>
---
src/gallium/drivers/panfrost/pan_resource.c | 30 ++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index aa8277f8cb5..467ea91e6e0 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -398,13 +398,15 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
/* Arrays and cubemaps have the entire miptree duplicated */
pres->cubemap_stride = ALIGN_POT(offset, 64);
- *bo_size = ALIGN_POT(pres->cubemap_stride * res->array_size, 4096);
+ if (bo_size)
+ *bo_size = ALIGN_POT(pres->cubemap_stride * res->array_size, 4096);
} else {
/* 3D strides across the 2D layers */
assert(res->array_size == 1);
pres->cubemap_stride = size_2d;
- *bo_size = ALIGN_POT(offset, 4096);
+ if (bo_size)
+ *bo_size = ALIGN_POT(offset, 4096);
}
}
@@ -524,14 +526,12 @@ panfrost_best_modifier(struct panfrost_device *dev,
}
static void
-panfrost_resource_create_bo(struct panfrost_device *dev, struct panfrost_resource *pres,
- uint64_t modifier)
+panfrost_resource_setup(struct panfrost_device *dev, struct panfrost_resource *pres,
+ size_t *bo_size, uint64_t modifier)
{
- struct pipe_resource *res = &pres->base;
-
pres->modifier = (modifier != DRM_FORMAT_MOD_INVALID) ? modifier :
panfrost_best_modifier(dev, pres);
- pres->checksummed = (res->bind & PIPE_BIND_RENDER_TARGET);
+ pres->checksummed = (pres->base.bind & PIPE_BIND_RENDER_TARGET);
/* We can only switch tiled->linear if the resource isn't already
* linear, and if we control the modifier, and if the resource can be
@@ -540,13 +540,7 @@ panfrost_resource_create_bo(struct panfrost_device *dev, struct panfrost_resourc
&& (modifier == DRM_FORMAT_MOD_INVALID)
&& panfrost_can_linear(dev, pres));
- size_t bo_size;
-
- panfrost_setup_slices(pres, &bo_size);
-
- /* We create a BO immediately but don't bother mapping, since we don't
- * care to map e.g. FBOs which the CPU probably won't touch */
- pres->bo = panfrost_bo_create(dev, bo_size, PAN_BO_DELAY_MMAP);
+ panfrost_setup_slices(pres, bo_size);
}
void
@@ -631,7 +625,13 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen,
util_range_init(&so->valid_buffer_range);
- panfrost_resource_create_bo(dev, so, modifier);
+ size_t bo_size;
+ panfrost_resource_setup(dev, so, &bo_size, modifier);
+
+ /* We create a BO immediately but don't bother mapping, since we don't
+ * care to map e.g. FBOs which the CPU probably won't touch */
+ so->bo = panfrost_bo_create(dev, bo_size, PAN_BO_DELAY_MMAP);
+
panfrost_resource_set_damage_region(NULL, &so->base, 0, NULL);
if (template->bind & PIPE_BIND_INDEX_BUFFER)
More information about the mesa-commit
mailing list