blob: 56a5a0f755f7ede678a5116978b2618b2114659c [file] [log] [blame]
From ad934eb680abc952670dfef1d52f717a1de9e5e7 Mon Sep 17 00:00:00 2001
From: Yiwei Zhang <zzyiwei@chromium.org>
Date: Sat, 21 Aug 2021 00:27:04 +0000
Subject: [PATCH 2/8] venus: add vn_descriptor_set_layout_init
Just a refactoring without functional changes.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@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;
}
--
2.33.0.259.gc128427fd7-goog