Mesa (main): venus: add vn_descriptor_set_layout_init

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 26 18:03:34 UTC 2021


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

Author: Yiwei Zhang <zzyiwei at chromium.org>
Date:   Sat Aug 21 00:27:04 2021 +0000

venus: add vn_descriptor_set_layout_init

Just a refactoring without functional changes.

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

---

 src/virtio/vulkan/vn_descriptor_set.c | 53 +++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/src/virtio/vulkan/vn_descriptor_set.c b/src/virtio/vulkan/vn_descriptor_set.c
index 93ac44fc01f..86bbd228635 100644
--- a/src/virtio/vulkan/vn_descriptor_set.c
+++ b/src/virtio/vulkan/vn_descriptor_set.c
@@ -32,6 +32,36 @@ vn_GetDescriptorSetLayoutSupport(
                                            pSupport);
 }
 
+static void
+vn_descriptor_set_layout_init(
+   struct vn_device *dev,
+   const VkDescriptorSetLayoutCreateInfo *create_info,
+   struct vn_descriptor_set_layout *layout)
+{
+   VkDevice dev_handle = vn_device_to_handle(dev);
+   VkDescriptorSetLayout layout_handle =
+      vn_descriptor_set_layout_to_handle(layout);
+
+   for (uint32_t i = 0; i < create_info->bindingCount; i++) {
+      const VkDescriptorSetLayoutBinding *binding_info =
+         &create_info->pBindings[i];
+      struct vn_descriptor_set_layout_binding *binding =
+         &layout->bindings[binding_info->binding];
+
+      switch (binding_info->descriptorType) {
+      case VK_DESCRIPTOR_TYPE_SAMPLER:
+      case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
+         binding->has_immutable_samplers = binding_info->pImmutableSamplers;
+         break;
+      default:
+         break;
+      }
+   }
+
+   vn_async_vkCreateDescriptorSetLayout(dev->instance, dev_handle,
+                                        create_info, NULL, &layout_handle);
+}
+
 VkResult
 vn_CreateDescriptorSetLayout(
    VkDevice device,
@@ -92,30 +122,11 @@ vn_CreateDescriptorSetLayout(
    vn_object_base_init(&layout->base, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT,
                        &dev->base);
 
-   for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
-      const VkDescriptorSetLayoutBinding *binding =
-         &pCreateInfo->pBindings[i];
-      struct vn_descriptor_set_layout_binding *dst =
-         &layout->bindings[binding->binding];
-
-      switch (binding->descriptorType) {
-      case VK_DESCRIPTOR_TYPE_SAMPLER:
-      case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
-         dst->has_immutable_samplers = binding->pImmutableSamplers;
-         break;
-      default:
-         break;
-      }
-   }
-
-   VkDescriptorSetLayout layout_handle =
-      vn_descriptor_set_layout_to_handle(layout);
-   vn_async_vkCreateDescriptorSetLayout(dev->instance, device, pCreateInfo,
-                                        NULL, &layout_handle);
+   vn_descriptor_set_layout_init(dev, pCreateInfo, layout);
 
    vk_free(alloc, local_bindings);
 
-   *pSetLayout = layout_handle;
+   *pSetLayout = vn_descriptor_set_layout_to_handle(layout);
 
    return VK_SUCCESS;
 }



More information about the mesa-commit mailing list