nvk: Add an nvk_cmd_buffer_ref_bo helper

We only need this for internal stuff that isn't tracked any other way.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:11:59 -06:00 committed by Marge Bot
parent 567148c172
commit c1b92bdf71
3 changed files with 11 additions and 13 deletions

View file

@ -124,7 +124,7 @@ nvk_cmd_buffer_resize_upload_buf(struct nvk_cmd_buffer *cmd,
uint32_t flags = NOUVEAU_WS_BO_GART | NOUVEAU_WS_BO_MAP;
bo = nouveau_ws_bo_new(device->pdev->dev, new_size, 0, flags);
nouveau_ws_push_ref(cmd->push, bo, NOUVEAU_WS_BO_RD);
nvk_cmd_buffer_ref_bo(cmd, bo);
if (cmd->upload.upload_bo) {
upload = malloc(sizeof(*upload));
@ -245,8 +245,7 @@ nvk_CmdBindPipeline(VkCommandBuffer commandBuffer,
if (!pipeline->shaders[s].bo)
continue;
nouveau_ws_push_ref(cmd->push, pipeline->shaders[s].bo,
NOUVEAU_WS_BO_RD);
nvk_cmd_buffer_ref_bo(cmd, pipeline->shaders[s].bo);
if (pipeline->shaders[s].slm_size)
nvk_device_ensure_slm(dev, pipeline->shaders[s].slm_size);
@ -289,7 +288,8 @@ nvk_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
pipeline_layout->set[set_idx].layout;
if (desc->sets[set_idx] != set) {
nvk_push_descriptor_set_ref(cmd->push, set);
if (set->bo)
nvk_cmd_buffer_ref_bo(cmd, set->bo);
desc->root.sets[set_idx] = nvk_descriptor_set_addr(set);
desc->sets[set_idx] = set;
desc->sets_dirty |= BITFIELD_BIT(set_idx);

View file

@ -123,6 +123,13 @@ nvk_cmd_buffer_push(struct nvk_cmd_buffer *cmd, uint32_t dw_count)
return P_SPACE(cmd->push, dw_count);
}
static inline void
nvk_cmd_buffer_ref_bo(struct nvk_cmd_buffer *cmd,
struct nouveau_ws_bo *bo)
{
nouveau_ws_push_ref(cmd->push, bo, NOUVEAU_WS_BO_RDWR);
}
void nvk_cmd_buffer_begin_graphics(struct nvk_cmd_buffer *cmd,
const VkCommandBufferBeginInfo *pBeginInfo);
void nvk_cmd_buffer_begin_compute(struct nvk_cmd_buffer *cmd,

View file

@ -4,7 +4,6 @@
#include "nvk_private.h"
#include "nouveau_bo.h"
#include "nouveau_push.h"
#include "vulkan/runtime/vk_object.h"
struct nvk_descriptor_set_layout;
@ -58,14 +57,6 @@ struct nvk_descriptor_set {
VK_DEFINE_HANDLE_CASTS(nvk_descriptor_set, base, VkDescriptorSet,
VK_OBJECT_TYPE_DESCRIPTOR_SET)
static inline void
nvk_push_descriptor_set_ref(struct nouveau_ws_push *push,
const struct nvk_descriptor_set *set)
{
if (set->bo)
nouveau_ws_push_ref(push, set->bo, NOUVEAU_WS_BO_RD);
}
static inline uint64_t
nvk_descriptor_set_addr(const struct nvk_descriptor_set *set)
{