panfrost: add LDST_ADDRESS property to atomic ops
[mesa.git] / src / panfrost / lib / pan_pool.c
index 5fc7cc041f649b7e8f72bf1916055d463ba85dc5..bea6eea0bc7a5769c53aea1c51017b42c11585a7 100644 (file)
@@ -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,13 +57,40 @@ 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);
 }
 
+void
+panfrost_pool_cleanup(struct pan_pool *pool)
+{
+        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;
+        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.
+                * We only keep the READ/WRITE info since this is all the BO
+                * wait logic cares about.
+                * 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;
+        }
+}
+
 struct panfrost_transfer
 panfrost_pool_alloc_aligned(struct pan_pool *pool, size_t sz, unsigned alignment)
 {