mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 02:20:11 +01:00
nvk: add cond render upload buffer.
conditional render has some issues with vram, so we have to use a gart buffer to put the value into. This is similiar to what nvidia seem to do. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24520>
This commit is contained in:
parent
fbe171638e
commit
07c70c77de
2 changed files with 45 additions and 0 deletions
|
|
@ -250,6 +250,45 @@ nvk_cmd_buffer_upload_data(struct nvk_cmd_buffer *cmd,
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult
|
||||
nvk_cmd_buffer_cond_render_alloc(struct nvk_cmd_buffer *cmd,
|
||||
uint64_t *addr)
|
||||
{
|
||||
uint32_t offset = cmd->cond_render_gart_offset;
|
||||
uint32_t size = 64;
|
||||
|
||||
assert(offset <= NVK_CMD_BO_SIZE);
|
||||
if (cmd->cond_render_gart_bo != NULL && size <= NVK_CMD_BO_SIZE - offset) {
|
||||
*addr = cmd->cond_render_gart_bo->bo->offset + offset;
|
||||
|
||||
cmd->cond_render_gart_offset = offset + size;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
struct nvk_cmd_bo *bo;
|
||||
VkResult result = nvk_cmd_buffer_alloc_bo(cmd, true, &bo);
|
||||
if (unlikely(result != VK_SUCCESS))
|
||||
return result;
|
||||
|
||||
nvk_cmd_buffer_ref_bo(cmd, bo->bo);
|
||||
|
||||
*addr = bo->bo->offset;
|
||||
|
||||
/* Pick whichever of the current upload BO and the new BO will have more
|
||||
* room left to be the BO for the next upload. If our upload size is
|
||||
* bigger than the old offset, we're better off burning the whole new
|
||||
* upload BO on this one allocation and continuing on the current upload
|
||||
* BO.
|
||||
*/
|
||||
if (cmd->cond_render_gart_bo == NULL || size < cmd->cond_render_gart_offset) {
|
||||
cmd->cond_render_gart_bo = bo;
|
||||
cmd->cond_render_gart_offset = size;
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
nvk_BeginCommandBuffer(VkCommandBuffer commandBuffer,
|
||||
const VkCommandBufferBeginInfo *pBeginInfo)
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ struct nvk_cmd_buffer {
|
|||
struct nvk_cmd_bo *upload_bo;
|
||||
uint32_t upload_offset;
|
||||
|
||||
struct nvk_cmd_bo *cond_render_gart_bo;
|
||||
uint32_t cond_render_gart_offset;
|
||||
|
||||
struct nvk_cmd_bo *push_bo;
|
||||
uint32_t *push_bo_limit;
|
||||
struct nv_push push;
|
||||
|
|
@ -242,6 +245,9 @@ VkResult nvk_cmd_buffer_upload_data(struct nvk_cmd_buffer *cmd,
|
|||
const void *data, uint32_t size,
|
||||
uint32_t alignment, uint64_t *addr);
|
||||
|
||||
VkResult nvk_cmd_buffer_cond_render_alloc(struct nvk_cmd_buffer *cmd,
|
||||
uint64_t *addr);
|
||||
|
||||
void
|
||||
nvk_cmd_buffer_flush_push_descriptors(struct nvk_cmd_buffer *cmd,
|
||||
struct nvk_descriptor_state *desc);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue