mesa/src/panfrost/vulkan/panvk_mempool.h
Boris Brezillon 86109da54e panvk: Transition panvk_pool to panvk_priv_bo
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>
2024-01-23 16:32:09 +00:00

98 lines
3 KiB
C

/*
* © Copyright 2017-2018 Alyssa Rosenzweig
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef __PANVK_POOL_H__
#define __PANVK_POOL_H__
#include "pan_pool.h"
struct panvk_priv_bo;
struct panvk_bo_pool {
struct util_dynarray free_bos;
};
static inline void
panvk_bo_pool_init(struct panvk_bo_pool *bo_pool)
{
util_dynarray_init(&bo_pool->free_bos, NULL);
}
void panvk_bo_pool_cleanup(struct panvk_bo_pool *bo_pool);
/* Represents grow-only memory. It may be owned by the batch (OpenGL), or may
be unowned for persistent uploads. */
struct panvk_pool {
/* Inherit from pan_pool */
struct pan_pool base;
/* Parent device for allocation */
struct panvk_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.
*/
struct panvk_bo_pool *bo_pool;
/* BOs allocated by this pool */
struct util_dynarray bos;
struct util_dynarray big_bos;
/* Current transient BO */
struct panvk_priv_bo *transient_bo;
/* Within the topmost transient BO, how much has been used? */
unsigned transient_offset;
};
static inline struct panvk_pool *
to_panvk_pool(struct pan_pool *pool)
{
return container_of(pool, struct panvk_pool, base);
}
void panvk_pool_init(struct panvk_pool *pool, struct panvk_device *dev,
struct panvk_bo_pool *bo_pool, unsigned create_flags,
size_t slab_size, const char *label, bool prealloc);
void panvk_pool_reset(struct panvk_pool *pool);
void panvk_pool_cleanup(struct panvk_pool *pool);
static inline unsigned
panvk_pool_num_bos(struct panvk_pool *pool)
{
return util_dynarray_num_elements(&pool->bos, struct panvk_priv_bo *);
}
void panvk_pool_get_bo_handles(struct panvk_pool *pool, uint32_t *handles);
#endif