nvk: Reset pushbufs on command buffer reset
authorDave Airlie <airlied@redhat.com>
Thu, 2 Jun 2022 06:36:08 +0000 (16:36 +1000)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:53 +0000 (21:31 +0000)
Karol: also reset on VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/nvk_cmd_buffer.c
src/nouveau/vulkan/nvk_cmd_buffer.h
src/nouveau/vulkan/nvk_device.c
src/nouveau/winsys/nouveau_push.c
src/nouveau/winsys/nouveau_push.h

index ebf8f20..a57bfff 100644 (file)
@@ -47,10 +47,13 @@ nvk_create_cmd_buffer(struct nvk_device *device, struct nvk_cmd_pool *pool,
    return VK_SUCCESS;
 }
 
-static VkResult
+VkResult
 nvk_reset_cmd_buffer(struct nvk_cmd_buffer *cmd_buffer)
 {
    vk_command_buffer_reset(&cmd_buffer->vk);
+
+   nouveau_ws_push_reset(cmd_buffer->push);
+
    return VK_SUCCESS;
 }
 
@@ -207,6 +210,13 @@ nvk_ResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags
 VKAPI_ATTR VkResult VKAPI_CALL
 nvk_BeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo)
 {
+   VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
+
+   if (pBeginInfo->flags & VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)
+      cmd->reset_on_submit = true;
+   else
+      cmd->reset_on_submit = false;
+
    return VK_SUCCESS;
 }
 
index ac2d0d5..c7db064 100644 (file)
@@ -21,8 +21,11 @@ struct nvk_cmd_buffer {
    struct list_head pool_link;
 
    struct nouveau_ws_push *push;
+   bool reset_on_submit;
 };
 
+VkResult nvk_reset_cmd_buffer(struct nvk_cmd_buffer *cmd_buffer);
+
 VK_DEFINE_HANDLE_CASTS(nvk_cmd_buffer, vk.base, VkCommandBuffer,
                        VK_OBJECT_TYPE_COMMAND_BUFFER)
 VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_cmd_pool, vk.base, VkCommandPool,
index 97ca583..884a946 100644 (file)
@@ -25,6 +25,8 @@ nvk_queue_submit(struct vk_queue *queue, struct vk_queue_submit *submission)
       }
 
       nouveau_ws_push_submit(cmd->push, device->pdev->dev, device->ctx);
+      if (cmd->reset_on_submit)
+         nvk_reset_cmd_buffer(cmd);
    }
 
    for (uint32_t i = 0; i < submission->signal_count; i++) {
index 4e787a2..efc0a48 100644 (file)
@@ -130,3 +130,11 @@ nouveau_ws_push_ref(
 
    util_dynarray_append(&push->bos, struct nouveau_ws_push_bo, push_bo);
 }
+
+void nouveau_ws_push_reset(struct nouveau_ws_push *push)
+{
+   util_dynarray_clear(&push->bos);
+
+   nouveau_ws_push_ref(push, push->bo, NOUVEAU_WS_BO_RD);
+   push->map = push->orig_map;
+}
index 8b88539..1ad8ba2 100644 (file)
@@ -27,6 +27,7 @@ struct nouveau_ws_push *nouveau_ws_push_new(struct nouveau_ws_device *, uint64_t
 void nouveau_ws_push_destroy(struct nouveau_ws_push *);
 int nouveau_ws_push_submit(struct nouveau_ws_push *, struct nouveau_ws_device *, struct nouveau_ws_context *);
 void nouveau_ws_push_ref(struct nouveau_ws_push *, struct nouveau_ws_bo *, enum nouveau_ws_bo_map_flags);
+void nouveau_ws_push_reset(struct nouveau_ws_push *);
 
 #ifdef CONFIG_NOUVEAU_DEBUG_PUSH
 #define PUSH_PRINTF(p,f,a...) do {                              \