panfrost: Make pan_pool.h panfrost_{device,bo} agnostic
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Constantine Shablya <constantine.shablya@collabora.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26698>
This commit is contained in:

committed by
Marge Bot

parent
1b1f1a6d76
commit
7b4d1bb9be
@@ -2292,7 +2292,7 @@ panfrost_emit_varying_descs(struct panfrost_pool *pool,
|
||||
struct panfrost_compiled_shader *consumer,
|
||||
uint16_t point_coord_mask, struct pan_linkage *out)
|
||||
{
|
||||
struct panfrost_device *dev = pool->base.dev;
|
||||
struct panfrost_device *dev = pool->dev;
|
||||
unsigned producer_count = producer->info.varyings.output_count;
|
||||
unsigned consumer_count = consumer->info.varyings.input_count;
|
||||
|
||||
|
@@ -52,8 +52,8 @@ panfrost_pool_alloc_backing(struct panfrost_pool *pool, size_t bo_sz)
|
||||
* flags to this function and keep the read/write,
|
||||
* fragment/vertex+tiler pools separate.
|
||||
*/
|
||||
struct panfrost_bo *bo = panfrost_bo_create(
|
||||
pool->base.dev, bo_sz, pool->base.create_flags, pool->base.label);
|
||||
struct panfrost_bo *bo =
|
||||
panfrost_bo_create(pool->dev, bo_sz, pool->create_flags, pool->label);
|
||||
|
||||
if (pool->owned)
|
||||
util_dynarray_append(&pool->bos, struct panfrost_bo *, bo);
|
||||
@@ -73,7 +73,10 @@ panfrost_pool_init(struct panfrost_pool *pool, void *memctx,
|
||||
bool owned)
|
||||
{
|
||||
memset(pool, 0, sizeof(*pool));
|
||||
pan_pool_init(&pool->base, dev, create_flags, slab_size, label);
|
||||
pan_pool_init(&pool->base, slab_size);
|
||||
pool->dev = dev;
|
||||
pool->create_flags = create_flags;
|
||||
pool->label = label;
|
||||
pool->owned = owned;
|
||||
|
||||
if (owned)
|
||||
@@ -131,8 +134,8 @@ panfrost_pool_alloc_aligned(struct panfrost_pool *pool, size_t sz,
|
||||
unsigned offset = ALIGN_POT(pool->transient_offset, alignment);
|
||||
|
||||
#ifdef PAN_DBG_OVERFLOW
|
||||
if (unlikely(pool->base.dev->debug & PAN_DBG_OVERFLOW) &&
|
||||
!(pool->base.create_flags & PAN_BO_INVISIBLE)) {
|
||||
if (unlikely(pool->dev->debug & PAN_DBG_OVERFLOW) &&
|
||||
!(pool->create_flags & PAN_BO_INVISIBLE)) {
|
||||
unsigned aligned = ALIGN_POT(sz, sysconf(_SC_PAGESIZE));
|
||||
unsigned bo_size = aligned + PAN_GUARD_SIZE;
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#ifndef __PAN_MEMPOOL_H__
|
||||
#define __PAN_MEMPOOL_H__
|
||||
|
||||
#include "pan_bo.h"
|
||||
#include "pan_pool.h"
|
||||
|
||||
/* Represents grow-only memory. It may be owned by the batch (OpenGL), or may
|
||||
@@ -34,6 +35,15 @@ struct panfrost_pool {
|
||||
/* Inherit from pan_pool */
|
||||
struct pan_pool base;
|
||||
|
||||
/* Parent device for allocation */
|
||||
struct panfrost_device *dev;
|
||||
|
||||
/* Label for created BOs */
|
||||
const char *label;
|
||||
|
||||
/* BO flags to use in the pool */
|
||||
unsigned create_flags;
|
||||
|
||||
/* BOs allocated by this pool */
|
||||
struct util_dynarray bos;
|
||||
|
||||
|
@@ -30,6 +30,8 @@
|
||||
#include "util/list.h"
|
||||
#include "panfrost-job.h"
|
||||
|
||||
#include "pan_pool.h"
|
||||
|
||||
#include "kmod/pan_kmod.h"
|
||||
|
||||
/* Flags for allocated memory */
|
||||
@@ -78,14 +80,6 @@ typedef uint8_t pan_bo_access;
|
||||
|
||||
struct panfrost_device;
|
||||
|
||||
struct panfrost_ptr {
|
||||
/* CPU address */
|
||||
void *cpu;
|
||||
|
||||
/* GPU address */
|
||||
mali_ptr gpu;
|
||||
};
|
||||
|
||||
struct panfrost_bo {
|
||||
/* Must be first for casting */
|
||||
struct list_head bucket_link;
|
||||
|
@@ -27,34 +27,28 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <genxml/gen_macros.h>
|
||||
#include "pan_bo.h"
|
||||
|
||||
#include "util/u_dynarray.h"
|
||||
|
||||
struct panfrost_ptr {
|
||||
/* CPU address */
|
||||
void *cpu;
|
||||
|
||||
/* GPU address */
|
||||
mali_ptr gpu;
|
||||
};
|
||||
|
||||
/* Represents grow-only memory. */
|
||||
|
||||
struct pan_pool {
|
||||
/* Parent device for allocation */
|
||||
struct panfrost_device *dev;
|
||||
|
||||
/* Label for created BOs */
|
||||
const char *label;
|
||||
|
||||
/* BO flags to use in the pool */
|
||||
unsigned create_flags;
|
||||
|
||||
/* Minimum size for allocated BOs. */
|
||||
size_t slab_size;
|
||||
};
|
||||
|
||||
static inline void
|
||||
pan_pool_init(struct pan_pool *pool, struct panfrost_device *dev,
|
||||
unsigned create_flags, size_t slab_size, const char *label)
|
||||
pan_pool_init(struct pan_pool *pool, size_t slab_size)
|
||||
{
|
||||
pool->dev = dev;
|
||||
pool->create_flags = create_flags;
|
||||
pool->slab_size = slab_size;
|
||||
pool->label = label;
|
||||
}
|
||||
|
||||
/* Represents a fat pointer for GPU-mapped memory, returned from the transient
|
||||
|
@@ -57,8 +57,8 @@ panvk_pool_alloc_backing(struct panvk_pool *pool, size_t bo_sz)
|
||||
* flags to this function and keep the read/write,
|
||||
* fragment/vertex+tiler pools separate.
|
||||
*/
|
||||
bo = panfrost_bo_create(pool->base.dev, bo_sz, pool->base.create_flags,
|
||||
pool->base.label);
|
||||
bo =
|
||||
panfrost_bo_create(pool->dev, bo_sz, pool->create_flags, pool->label);
|
||||
}
|
||||
|
||||
if (panfrost_bo_size(bo) == pool->base.slab_size)
|
||||
@@ -104,7 +104,10 @@ panvk_pool_init(struct panvk_pool *pool, struct panfrost_device *dev,
|
||||
size_t slab_size, const char *label, bool prealloc)
|
||||
{
|
||||
memset(pool, 0, sizeof(*pool));
|
||||
pan_pool_init(&pool->base, dev, create_flags, slab_size, label);
|
||||
pan_pool_init(&pool->base, slab_size);
|
||||
pool->dev = dev;
|
||||
pool->create_flags = create_flags;
|
||||
pool->label = label;
|
||||
pool->bo_pool = bo_pool;
|
||||
|
||||
util_dynarray_init(&pool->bos, NULL);
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#define __PANVK_POOL_H__
|
||||
|
||||
#include "pan_pool.h"
|
||||
#include "pan_bo.h"
|
||||
|
||||
struct panvk_bo_pool {
|
||||
struct util_dynarray free_bos;
|
||||
@@ -52,6 +53,15 @@ struct panvk_pool {
|
||||
/* Inherit from pan_pool */
|
||||
struct pan_pool base;
|
||||
|
||||
/* Parent device for allocation */
|
||||
struct panfrost_device *dev;
|
||||
|
||||
/* Label for created BOs */
|
||||
const char *label;
|
||||
|
||||
/* BO flags to use in the pool */
|
||||
unsigned create_flags;
|
||||
|
||||
/* Before allocating a new BO, check if the BO pool has free BOs.
|
||||
* When returning BOs, if bo_pool != NULL, return them to this bo_pool.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user