Mesa (master): panfrost: Store transient BOs in a dynamic array
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 28 20:31:23 UTC 2020
Module: Mesa
Branch: master
Commit: 9522eb7be14841f72ca2daf533f705d7546b8007
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9522eb7be14841f72ca2daf533f705d7546b8007
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Mon Aug 24 12:33:41 2020 +0200
panfrost: Store transient BOs in a dynamic array
We clearly don't need a hash here since we're never searching for BOs
that are in a pool.
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6494>
---
src/panfrost/lib/pan_pool.c | 32 ++++++++++----------------------
src/panfrost/lib/pan_pool.h | 8 +++++---
2 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/src/panfrost/lib/pan_pool.c b/src/panfrost/lib/pan_pool.c
index 11880637720..bea6eea0bc7 100644
--- a/src/panfrost/lib/pan_pool.c
+++ b/src/panfrost/lib/pan_pool.c
@@ -23,7 +23,6 @@
*
*/
-#include "util/hash_table.h"
#include "pan_bo.h"
#include "pan_pool.h"
@@ -43,13 +42,7 @@ panfrost_pool_alloc_backing(struct pan_pool *pool, size_t bo_sz)
struct panfrost_bo *bo = panfrost_bo_create(pool->dev, bo_sz,
pool->create_flags);
- uintptr_t flags = PAN_BO_ACCESS_PRIVATE |
- PAN_BO_ACCESS_RW |
- PAN_BO_ACCESS_VERTEX_TILER |
- PAN_BO_ACCESS_FRAGMENT;
-
- _mesa_hash_table_insert(pool->bos, bo, (void *) flags);
-
+ util_dynarray_append(&pool->bos, struct panfrost_bo *, bo);
pool->transient_bo = bo;
pool->transient_offset = 0;
@@ -64,33 +57,28 @@ panfrost_pool_init(struct pan_pool *pool, void *memctx,
memset(pool, 0, sizeof(*pool));
pool->dev = dev;
pool->create_flags = create_flags;
- pool->bos = _mesa_hash_table_create(memctx, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
+ util_dynarray_init(&pool->bos, memctx);
if (prealloc)
panfrost_pool_alloc_backing(pool, TRANSIENT_SLAB_SIZE);
}
-static void delete_bo_entry(struct hash_entry *entry)
-{
- panfrost_bo_unreference((struct panfrost_bo *)entry->key);
-}
-
void
panfrost_pool_cleanup(struct pan_pool *pool)
{
- _mesa_hash_table_destroy(pool->bos, delete_bo_entry);
+ util_dynarray_foreach(&pool->bos, struct panfrost_bo *, bo)
+ panfrost_bo_unreference(*bo);
+
+ util_dynarray_fini(&pool->bos);
}
void
panfrost_pool_get_bo_handles(struct pan_pool *pool, uint32_t *handles)
{
unsigned idx = 0;
- hash_table_foreach(pool->bos, entry) {
- struct panfrost_bo *bo = (struct panfrost_bo *)entry->key;
-
- assert(bo->gem_handle > 0);
- handles[idx++] = bo->gem_handle;
+ util_dynarray_foreach(&pool->bos, struct panfrost_bo *, bo) {
+ assert((*bo)->gem_handle > 0);
+ handles[idx++] = (*bo)->gem_handle;
/* Update the BO access flags so that panfrost_bo_wait() knows
* about all pending accesses.
@@ -99,7 +87,7 @@ panfrost_pool_get_bo_handles(struct pan_pool *pool, uint32_t *handles)
* We also preserve existing flags as this batch might not
* be the first one to access the BO.
*/
- bo->gpu_access |= PAN_BO_ACCESS_RW;
+ (*bo)->gpu_access |= PAN_BO_ACCESS_RW;
}
}
diff --git a/src/panfrost/lib/pan_pool.h b/src/panfrost/lib/pan_pool.h
index c3fa2abd049..1793badf35d 100644
--- a/src/panfrost/lib/pan_pool.h
+++ b/src/panfrost/lib/pan_pool.h
@@ -28,6 +28,8 @@
#include <stddef.h>
#include <midgard_pack.h>
+#include "util/u_dynarray.h"
+
/* Represents a pool of memory that can only grow, used to allocate objects
* with the same lifetime as the pool itself. In OpenGL, a pool is owned by the
* batch for transient structures. In Vulkan, it may be owned by e.g. the
@@ -37,8 +39,8 @@ struct pan_pool {
/* Parent device for allocation */
struct panfrost_device *dev;
- /* panfrost_bo -> access_flags owned by the pool */
- struct hash_table *bos;
+ /* BOs allocated by this pool */
+ struct util_dynarray bos;
/* Current transient BO */
struct panfrost_bo *transient_bo;
@@ -61,7 +63,7 @@ panfrost_pool_cleanup(struct pan_pool *pool);
static inline unsigned
panfrost_pool_num_bos(struct pan_pool *pool)
{
- return pool->bos->entries;
+ return util_dynarray_num_elements(&pool->bos, struct panfrost_bo *);
}
void
More information about the mesa-commit
mailing list