mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-05 09:00:08 +01:00
panvk: Collect allocated push sets at the command level
It makes the reset of command buffers a tad simpler, and it allows re-cycling push sets. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30736>
This commit is contained in:
parent
5b1cddf35f
commit
598a8d9d11
6 changed files with 70 additions and 56 deletions
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "genxml/gen_macros.h"
|
||||
|
||||
#include "panvk_cmd_pool.h"
|
||||
#include "panvk_descriptor_set.h"
|
||||
#include "panvk_macros.h"
|
||||
#include "panvk_shader.h"
|
||||
|
|
@ -28,6 +29,12 @@ struct panvk_shader_desc_state {
|
|||
mali_ptr dyn_ssbos;
|
||||
};
|
||||
|
||||
struct panvk_push_set {
|
||||
struct panvk_cmd_pool_obj base;
|
||||
struct panvk_descriptor_set set;
|
||||
struct panvk_opaque_desc descs[MAX_PUSH_DESCS];
|
||||
};
|
||||
|
||||
struct panvk_descriptor_state {
|
||||
const struct panvk_descriptor_set *sets[MAX_SETS];
|
||||
struct panvk_descriptor_set *push_sets[MAX_SETS];
|
||||
|
|
@ -35,15 +42,6 @@ struct panvk_descriptor_state {
|
|||
uint32_t dyn_buf_offsets[MAX_SETS][MAX_DYNAMIC_BUFFERS];
|
||||
};
|
||||
|
||||
void panvk_per_arch(cmd_desc_state_reset)(
|
||||
struct panvk_descriptor_state *gfx_desc_state,
|
||||
struct panvk_descriptor_state *compute_desc_state);
|
||||
|
||||
void panvk_per_arch(cmd_desc_state_cleanup)(
|
||||
struct vk_command_buffer *cmdbuf,
|
||||
struct panvk_descriptor_state *gfx_desc_state,
|
||||
struct panvk_descriptor_state *compute_desc_state);
|
||||
|
||||
void panvk_per_arch(cmd_desc_state_bind_sets)(
|
||||
struct panvk_descriptor_state *desc_state,
|
||||
const VkBindDescriptorSetsInfoKHR *info);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "genxml/gen_macros.h"
|
||||
|
||||
#include "panvk_buffer.h"
|
||||
#include "panvk_cmd_buffer.h"
|
||||
#include "panvk_cmd_desc_state.h"
|
||||
#include "panvk_entrypoints.h"
|
||||
|
||||
|
|
@ -23,29 +24,6 @@
|
|||
#include "vk_command_buffer.h"
|
||||
#include "vk_command_pool.h"
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_desc_state_reset)(
|
||||
struct panvk_descriptor_state *gfx_desc_state,
|
||||
struct panvk_descriptor_state *compute_desc_state)
|
||||
{
|
||||
memset(&gfx_desc_state->sets, 0, sizeof(gfx_desc_state->sets));
|
||||
memset(&compute_desc_state->sets, 0, sizeof(compute_desc_state->sets));
|
||||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_desc_state_cleanup)(
|
||||
struct vk_command_buffer *cmdbuf,
|
||||
struct panvk_descriptor_state *gfx_desc_state,
|
||||
struct panvk_descriptor_state *compute_desc_state)
|
||||
{
|
||||
for (unsigned i = 0; i < MAX_SETS; i++) {
|
||||
if (gfx_desc_state->push_sets[i])
|
||||
vk_free(&cmdbuf->pool->alloc, gfx_desc_state->push_sets[i]);
|
||||
if (compute_desc_state->push_sets[i])
|
||||
vk_free(&cmdbuf->pool->alloc, compute_desc_state->push_sets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_desc_state_bind_sets)(
|
||||
struct panvk_descriptor_state *desc_state,
|
||||
|
|
@ -85,25 +63,40 @@ panvk_per_arch(cmd_desc_state_bind_sets)(
|
|||
}
|
||||
|
||||
struct panvk_descriptor_set *
|
||||
panvk_per_arch(cmd_push_descriptors)(struct vk_command_buffer *cmdbuf,
|
||||
panvk_per_arch(cmd_push_descriptors)(struct vk_command_buffer *vk_cmdbuf,
|
||||
struct panvk_descriptor_state *desc_state,
|
||||
uint32_t set_idx)
|
||||
{
|
||||
struct panvk_cmd_buffer *cmdbuf =
|
||||
container_of(vk_cmdbuf, struct panvk_cmd_buffer, vk);
|
||||
struct panvk_cmd_pool *pool =
|
||||
container_of(cmdbuf->vk.pool, struct panvk_cmd_pool, vk);
|
||||
struct panvk_push_set *push_set;
|
||||
|
||||
assert(set_idx < MAX_SETS);
|
||||
|
||||
if (unlikely(desc_state->push_sets[set_idx] == NULL)) {
|
||||
VK_MULTIALLOC(ma);
|
||||
VK_MULTIALLOC_DECL(&ma, struct panvk_descriptor_set, set, 1);
|
||||
VK_MULTIALLOC_DECL(&ma, struct panvk_opaque_desc, descs, MAX_PUSH_DESCS);
|
||||
if (likely(desc_state->push_sets[set_idx])) {
|
||||
push_set = container_of(desc_state->push_sets[set_idx],
|
||||
struct panvk_push_set, set);
|
||||
} else if (!list_is_empty(&pool->push_sets)) {
|
||||
push_set =
|
||||
list_first_entry(&pool->push_sets, struct panvk_push_set, base.node);
|
||||
list_del(&push_set->base.node);
|
||||
list_addtail(&push_set->base.node, &cmdbuf->push_sets);
|
||||
} else {
|
||||
push_set = vk_zalloc(&pool->vk.alloc, sizeof(*push_set), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
list_addtail(&push_set->base.node, &cmdbuf->push_sets);
|
||||
}
|
||||
|
||||
if (unlikely(!vk_multialloc_zalloc(&ma, &cmdbuf->pool->alloc,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT))) {
|
||||
vk_command_buffer_set_error(cmdbuf, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
if (unlikely(!push_set)) {
|
||||
vk_command_buffer_set_error(&cmdbuf->vk, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
desc_state->push_sets[set_idx] = set;
|
||||
set->descs.host = descs;
|
||||
if (desc_state->push_sets[set_idx] == NULL) {
|
||||
desc_state->push_sets[set_idx] = &push_set->set;
|
||||
push_set->set.descs.host = push_set->descs;
|
||||
}
|
||||
|
||||
struct panvk_descriptor_set *set = desc_state->push_sets[set_idx];
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ struct panvk_cmd_buffer {
|
|||
struct panvk_pool varying_pool;
|
||||
struct panvk_pool tls_pool;
|
||||
struct list_head batches;
|
||||
struct list_head push_sets;
|
||||
struct panvk_batch *cur_batch;
|
||||
|
||||
struct {
|
||||
|
|
@ -191,6 +192,24 @@ struct panvk_cmd_buffer {
|
|||
VK_DEFINE_HANDLE_CASTS(panvk_cmd_buffer, vk.base, VkCommandBuffer,
|
||||
VK_OBJECT_TYPE_COMMAND_BUFFER)
|
||||
|
||||
#define panvk_cmd_buffer_obj_list_init(cmdbuf, list_name) \
|
||||
list_inithead(&(cmdbuf)->list_name)
|
||||
|
||||
#define panvk_cmd_buffer_obj_list_cleanup(cmdbuf, list_name) \
|
||||
do { \
|
||||
struct panvk_cmd_pool *__pool = \
|
||||
container_of(cmdbuf->vk.pool, struct panvk_cmd_pool, vk); \
|
||||
list_splicetail(&(cmdbuf)->list_name, &__pool->list_name); \
|
||||
} while (0)
|
||||
|
||||
#define panvk_cmd_buffer_obj_list_reset(cmdbuf, list_name) \
|
||||
do { \
|
||||
struct panvk_cmd_pool *__pool = \
|
||||
container_of(cmdbuf->vk.pool, struct panvk_cmd_pool, vk); \
|
||||
list_splicetail(&(cmdbuf)->list_name, &__pool->list_name); \
|
||||
list_inithead(&(cmdbuf)->list_name); \
|
||||
} while (0)
|
||||
|
||||
static inline struct panvk_descriptor_state *
|
||||
panvk_cmd_get_desc_state(struct panvk_cmd_buffer *cmdbuf,
|
||||
VkPipelineBindPoint bindpoint)
|
||||
|
|
|
|||
|
|
@ -333,13 +333,9 @@ panvk_reset_cmdbuf(struct vk_command_buffer *vk_cmdbuf,
|
|||
panvk_pool_reset(&cmdbuf->desc_pool);
|
||||
panvk_pool_reset(&cmdbuf->tls_pool);
|
||||
panvk_pool_reset(&cmdbuf->varying_pool);
|
||||
panvk_cmd_buffer_obj_list_reset(cmdbuf, push_sets);
|
||||
|
||||
panvk_per_arch(cmd_desc_state_reset)(&cmdbuf->state.gfx.desc_state,
|
||||
&cmdbuf->state.compute.desc_state);
|
||||
memset(&cmdbuf->state.gfx.vs.desc, 0, sizeof(cmdbuf->state.gfx.vs.desc));
|
||||
memset(&cmdbuf->state.gfx.fs.desc, 0, sizeof(cmdbuf->state.gfx.fs.desc));
|
||||
memset(&cmdbuf->state.compute.cs.desc, 0,
|
||||
sizeof(cmdbuf->state.compute.cs.desc));
|
||||
memset(&cmdbuf->state, 0, sizeof(cmdbuf->state));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -349,10 +345,6 @@ panvk_destroy_cmdbuf(struct vk_command_buffer *vk_cmdbuf)
|
|||
container_of(vk_cmdbuf, struct panvk_cmd_buffer, vk);
|
||||
struct panvk_device *dev = to_panvk_device(cmdbuf->vk.base.device);
|
||||
|
||||
panvk_per_arch(cmd_desc_state_cleanup)(&cmdbuf->vk,
|
||||
&cmdbuf->state.gfx.desc_state,
|
||||
&cmdbuf->state.compute.desc_state);
|
||||
|
||||
list_for_each_entry_safe(struct panvk_batch, batch, &cmdbuf->batches, node) {
|
||||
list_del(&batch->node);
|
||||
util_dynarray_fini(&batch->jobs);
|
||||
|
|
@ -364,6 +356,7 @@ panvk_destroy_cmdbuf(struct vk_command_buffer *vk_cmdbuf)
|
|||
panvk_pool_cleanup(&cmdbuf->desc_pool);
|
||||
panvk_pool_cleanup(&cmdbuf->tls_pool);
|
||||
panvk_pool_cleanup(&cmdbuf->varying_pool);
|
||||
panvk_cmd_buffer_obj_list_cleanup(cmdbuf, push_sets);
|
||||
vk_command_buffer_finish(&cmdbuf->vk);
|
||||
vk_free(&dev->vk.alloc, cmdbuf);
|
||||
}
|
||||
|
|
@ -390,6 +383,7 @@ panvk_create_cmdbuf(struct vk_command_pool *vk_pool, VkCommandBufferLevel level,
|
|||
return result;
|
||||
}
|
||||
|
||||
panvk_cmd_buffer_obj_list_init(cmdbuf, push_sets);
|
||||
cmdbuf->vk.dynamic_graphics_state.vi = &cmdbuf->state.gfx.dynamic.vi;
|
||||
cmdbuf->vk.dynamic_graphics_state.ms.sample_locations =
|
||||
&cmdbuf->state.gfx.dynamic.sl;
|
||||
|
|
@ -448,8 +442,6 @@ panvk_per_arch(BeginCommandBuffer)(VkCommandBuffer commandBuffer,
|
|||
|
||||
vk_command_buffer_begin(&cmdbuf->vk, pBeginInfo);
|
||||
|
||||
memset(&cmdbuf->state, 0, sizeof(cmdbuf->state));
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ panvk_CreateCommandPool(VkDevice _device,
|
|||
panvk_bo_pool_init(&pool->desc_bo_pool);
|
||||
panvk_bo_pool_init(&pool->varying_bo_pool);
|
||||
panvk_bo_pool_init(&pool->tls_bo_pool);
|
||||
list_inithead(&pool->push_sets);
|
||||
*pCmdPool = panvk_cmd_pool_to_handle(pool);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
@ -60,5 +61,11 @@ panvk_DestroyCommandPool(VkDevice _device, VkCommandPool commandPool,
|
|||
panvk_bo_pool_cleanup(&pool->varying_bo_pool);
|
||||
panvk_bo_pool_cleanup(&pool->tls_bo_pool);
|
||||
|
||||
list_for_each_entry_safe(struct panvk_cmd_pool_obj, obj, &pool->push_sets,
|
||||
node) {
|
||||
list_del(&obj->node);
|
||||
vk_free(&pool->vk.alloc, obj);
|
||||
}
|
||||
|
||||
vk_free2(&device->vk.alloc, pAllocator, pool);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,14 @@ struct panvk_cmd_pool {
|
|||
struct panvk_bo_pool desc_bo_pool;
|
||||
struct panvk_bo_pool varying_bo_pool;
|
||||
struct panvk_bo_pool tls_bo_pool;
|
||||
struct list_head push_sets;
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_cmd_pool, vk.base, VkCommandPool,
|
||||
VK_OBJECT_TYPE_COMMAND_POOL)
|
||||
|
||||
struct panvk_cmd_pool_obj {
|
||||
struct list_head node;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue