mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 11:40:10 +01:00
nvk: add gart forced cmd pool side buffer.
Currently we put the upload and cmd bos into GART, however in the future this might change, but for conditional rendering we must have a GART space to read the value from. This creates a separate buffer allocations that are gart forced. This will be used to provide cond render with a gart location. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24520>
This commit is contained in:
parent
92c5460253
commit
fbe171638e
4 changed files with 43 additions and 12 deletions
|
|
@ -27,6 +27,7 @@ nvk_destroy_cmd_buffer(struct vk_command_buffer *vk_cmd_buffer)
|
|||
struct nvk_cmd_pool *pool = nvk_cmd_buffer_pool(cmd);
|
||||
|
||||
nvk_cmd_pool_free_bo_list(pool, &cmd->bos);
|
||||
nvk_cmd_pool_free_bo_list(pool, &cmd->gart_bos);
|
||||
util_dynarray_fini(&cmd->pushes);
|
||||
util_dynarray_fini(&cmd->bo_refs);
|
||||
vk_command_buffer_finish(&cmd->vk);
|
||||
|
|
@ -59,6 +60,7 @@ nvk_create_cmd_buffer(struct vk_command_pool *vk_pool,
|
|||
&cmd->state.gfx._dynamic_sl;
|
||||
|
||||
list_inithead(&cmd->bos);
|
||||
list_inithead(&cmd->gart_bos);
|
||||
util_dynarray_init(&cmd->pushes, NULL);
|
||||
util_dynarray_init(&cmd->bo_refs, NULL);
|
||||
|
||||
|
|
@ -78,6 +80,7 @@ nvk_reset_cmd_buffer(struct vk_command_buffer *vk_cmd_buffer,
|
|||
vk_command_buffer_reset(&cmd->vk);
|
||||
|
||||
nvk_cmd_pool_free_bo_list(pool, &cmd->bos);
|
||||
nvk_cmd_pool_free_gart_bo_list(pool, &cmd->gart_bos);
|
||||
cmd->upload_bo = NULL;
|
||||
cmd->push_bo = NULL;
|
||||
cmd->push_bo_limit = NULL;
|
||||
|
|
@ -99,12 +102,15 @@ const struct vk_command_buffer_ops nvk_cmd_buffer_ops = {
|
|||
static uint32_t push_runout[NVK_CMD_BUFFER_MAX_PUSH];
|
||||
|
||||
static VkResult
|
||||
nvk_cmd_buffer_alloc_bo(struct nvk_cmd_buffer *cmd, struct nvk_cmd_bo **bo_out)
|
||||
nvk_cmd_buffer_alloc_bo(struct nvk_cmd_buffer *cmd, bool force_gart, struct nvk_cmd_bo **bo_out)
|
||||
{
|
||||
VkResult result = nvk_cmd_pool_alloc_bo(nvk_cmd_buffer_pool(cmd), bo_out);
|
||||
VkResult result = nvk_cmd_pool_alloc_bo(nvk_cmd_buffer_pool(cmd), force_gart, bo_out);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
if (force_gart)
|
||||
list_addtail(&(*bo_out)->link, &cmd->gart_bos);
|
||||
else
|
||||
list_addtail(&(*bo_out)->link, &cmd->bos);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
@ -138,7 +144,7 @@ nvk_cmd_buffer_new_push(struct nvk_cmd_buffer *cmd)
|
|||
{
|
||||
nvk_cmd_buffer_flush_push(cmd);
|
||||
|
||||
VkResult result = nvk_cmd_buffer_alloc_bo(cmd, &cmd->push_bo);
|
||||
VkResult result = nvk_cmd_buffer_alloc_bo(cmd, false, &cmd->push_bo);
|
||||
if (unlikely(result != VK_SUCCESS)) {
|
||||
STATIC_ASSERT(NVK_CMD_BUFFER_MAX_PUSH <= NVK_CMD_BO_SIZE / 4);
|
||||
cmd->push_bo = NULL;
|
||||
|
|
@ -204,7 +210,7 @@ nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd,
|
|||
}
|
||||
|
||||
struct nvk_cmd_bo *bo;
|
||||
VkResult result = nvk_cmd_buffer_alloc_bo(cmd, &bo);
|
||||
VkResult result = nvk_cmd_buffer_alloc_bo(cmd, false, &bo);
|
||||
if (unlikely(result != VK_SUCCESS))
|
||||
return result;
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ struct nvk_cmd_buffer {
|
|||
* command buffer.
|
||||
*/
|
||||
struct list_head bos;
|
||||
struct list_head gart_bos;
|
||||
|
||||
struct nvk_cmd_bo *upload_bo;
|
||||
uint32_t upload_offset;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "nvk_physical_device.h"
|
||||
|
||||
static VkResult
|
||||
nvk_cmd_bo_create(struct nvk_cmd_pool *pool, struct nvk_cmd_bo **bo_out)
|
||||
nvk_cmd_bo_create(struct nvk_cmd_pool *pool, bool force_gart, struct nvk_cmd_bo **bo_out)
|
||||
{
|
||||
struct nvk_device *dev = nvk_cmd_pool_device(pool);
|
||||
struct nvk_cmd_bo *bo;
|
||||
|
|
@ -15,6 +15,8 @@ nvk_cmd_bo_create(struct nvk_cmd_pool *pool, struct nvk_cmd_bo **bo_out)
|
|||
return vk_error(pool, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
uint32_t flags = NOUVEAU_WS_BO_GART | NOUVEAU_WS_BO_MAP | NOUVEAU_WS_BO_NO_SHARE;
|
||||
if (force_gart)
|
||||
assert(flags & NOUVEAU_WS_BO_GART);
|
||||
bo->bo = nouveau_ws_bo_new_mapped(dev->ws_dev, NVK_CMD_BO_SIZE, 0,
|
||||
flags, NOUVEAU_WS_BO_WR, &bo->map);
|
||||
if (bo->bo == NULL) {
|
||||
|
|
@ -56,6 +58,7 @@ nvk_CreateCommandPool(VkDevice _device,
|
|||
}
|
||||
|
||||
list_inithead(&pool->free_bos);
|
||||
list_inithead(&pool->free_gart_bos);
|
||||
|
||||
*pCmdPool = nvk_cmd_pool_to_handle(pool);
|
||||
|
||||
|
|
@ -69,20 +72,31 @@ nvk_cmd_pool_destroy_bos(struct nvk_cmd_pool *pool)
|
|||
nvk_cmd_bo_destroy(pool, bo);
|
||||
|
||||
list_inithead(&pool->free_bos);
|
||||
|
||||
list_for_each_entry_safe(struct nvk_cmd_bo, bo, &pool->free_gart_bos, link)
|
||||
nvk_cmd_bo_destroy(pool, bo);
|
||||
|
||||
list_inithead(&pool->free_gart_bos);
|
||||
}
|
||||
|
||||
VkResult
|
||||
nvk_cmd_pool_alloc_bo(struct nvk_cmd_pool *pool, struct nvk_cmd_bo **bo_out)
|
||||
nvk_cmd_pool_alloc_bo(struct nvk_cmd_pool *pool, bool force_gart, struct nvk_cmd_bo **bo_out)
|
||||
{
|
||||
if (!list_is_empty(&pool->free_bos)) {
|
||||
struct nvk_cmd_bo *bo =
|
||||
list_first_entry(&pool->free_bos, struct nvk_cmd_bo, link);
|
||||
struct nvk_cmd_bo *bo = NULL;
|
||||
if (force_gart) {
|
||||
if (!list_is_empty(&pool->free_gart_bos))
|
||||
bo = list_first_entry(&pool->free_gart_bos, struct nvk_cmd_bo, link);
|
||||
} else {
|
||||
if (!list_is_empty(&pool->free_bos))
|
||||
bo = list_first_entry(&pool->free_bos, struct nvk_cmd_bo, link);
|
||||
}
|
||||
if (bo) {
|
||||
list_del(&bo->link);
|
||||
*bo_out = bo;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
return nvk_cmd_bo_create(pool, bo_out);
|
||||
return nvk_cmd_bo_create(pool, force_gart, bo_out);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -92,6 +106,13 @@ nvk_cmd_pool_free_bo_list(struct nvk_cmd_pool *pool, struct list_head *bos)
|
|||
list_inithead(bos);
|
||||
}
|
||||
|
||||
void
|
||||
nvk_cmd_pool_free_gart_bo_list(struct nvk_cmd_pool *pool, struct list_head *bos)
|
||||
{
|
||||
list_splicetail(bos, &pool->free_gart_bos);
|
||||
list_inithead(bos);
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
nvk_DestroyCommandPool(VkDevice _device,
|
||||
VkCommandPool commandPool,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ struct nvk_cmd_pool {
|
|||
|
||||
/** List of nvk_cmd_bo */
|
||||
struct list_head free_bos;
|
||||
struct list_head free_gart_bos;
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_cmd_pool, vk.base, VkCommandPool,
|
||||
|
|
@ -34,9 +35,11 @@ nvk_cmd_pool_device(struct nvk_cmd_pool *pool)
|
|||
}
|
||||
|
||||
VkResult nvk_cmd_pool_alloc_bo(struct nvk_cmd_pool *pool,
|
||||
bool force_gart,
|
||||
struct nvk_cmd_bo **bo_out);
|
||||
|
||||
void nvk_cmd_pool_free_bo_list(struct nvk_cmd_pool *pool,
|
||||
struct list_head *bos);
|
||||
|
||||
void nvk_cmd_pool_free_gart_bo_list(struct nvk_cmd_pool *pool,
|
||||
struct list_head *bos);
|
||||
#endif /* NVK_CMD_POOL_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue