Mesa (main): venus: add struct vn_command_buffer_builder

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 28 23:19:33 UTC 2021


Module: Mesa
Branch: main
Commit: fb549d21d877e00095075ed5eaf7cf1739af3e96
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb549d21d877e00095075ed5eaf7cf1739af3e96

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Wed May  5 12:15:31 2021 -0700

venus: add struct vn_command_buffer_builder

We are going to remember more states.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11067>

---

 src/virtio/vulkan/vn_command_buffer.c | 14 +++++++-------
 src/virtio/vulkan/vn_command_buffer.h | 11 ++++++++---
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/virtio/vulkan/vn_command_buffer.c b/src/virtio/vulkan/vn_command_buffer.c
index 642f157ed71..e09cf8d2a94 100644
--- a/src/virtio/vulkan/vn_command_buffer.c
+++ b/src/virtio/vulkan/vn_command_buffer.c
@@ -171,8 +171,8 @@ vn_FreeCommandBuffers(VkDevice device,
       if (!cmd)
          continue;
 
-      if (cmd->image_barriers)
-         vk_free(alloc, cmd->image_barriers);
+      if (cmd->builder.image_barriers)
+         vk_free(alloc, cmd->builder.image_barriers);
 
       vn_cs_encoder_fini(&cmd->cs);
       list_del(&cmd->head);
@@ -963,17 +963,17 @@ vn_get_intercepted_barriers(struct vn_command_buffer *cmd,
 
    size_t size = sizeof(VkImageMemoryBarrier) * count;
    /* avoid shrinking in case of non efficient reallocation implementation */
-   VkImageMemoryBarrier *barriers = cmd->image_barriers;
-   if (count > cmd->image_barrier_count) {
+   VkImageMemoryBarrier *barriers = cmd->builder.image_barriers;
+   if (count > cmd->builder.image_barrier_count) {
       barriers =
-         vk_realloc(&cmd->allocator, cmd->image_barriers, size,
+         vk_realloc(&cmd->allocator, cmd->builder.image_barriers, size,
                     VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
       if (!barriers)
          return img_barriers;
 
       /* update upon successful reallocation */
-      cmd->image_barrier_count = count;
-      cmd->image_barriers = barriers;
+      cmd->builder.image_barrier_count = count;
+      cmd->builder.image_barriers = barriers;
    }
    memcpy(barriers, img_barriers, size);
    for (uint32_t i = 0; i < count; i++) {
diff --git a/src/virtio/vulkan/vn_command_buffer.h b/src/virtio/vulkan/vn_command_buffer.h
index ab74effe507..ef0652390ff 100644
--- a/src/virtio/vulkan/vn_command_buffer.h
+++ b/src/virtio/vulkan/vn_command_buffer.h
@@ -33,18 +33,23 @@ enum vn_command_buffer_state {
    VN_COMMAND_BUFFER_STATE_INVALID,
 };
 
+struct vn_command_buffer_builder {
+   /* for scrubbing VK_IMAGE_LAYOUT_PRESENT_SRC_KHR */
+   uint32_t image_barrier_count;
+   VkImageMemoryBarrier *image_barriers;
+};
+
 struct vn_command_buffer {
    struct vn_object_base base;
 
    struct vn_device *device;
 
-   /* for scrubbing VK_IMAGE_LAYOUT_PRESENT_SRC_KHR */
    VkAllocationCallbacks allocator;
-   uint32_t image_barrier_count;
-   VkImageMemoryBarrier *image_barriers;
 
    struct list_head head;
 
+   struct vn_command_buffer_builder builder;
+
    enum vn_command_buffer_state state;
    struct vn_cs_encoder cs;
 };



More information about the mesa-commit mailing list