From f8af4b597e7c0c882a71c744766fb3933700976c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 5 Aug 2024 21:41:25 +0300 Subject: [PATCH] vulkan/runtime: store flags on descriptor set layouts Signed-off-by: Lionel Landwerlin Reviewed-by: Faith Ekstrand Part-of: --- src/amd/vulkan/radv_descriptor_set.c | 2 +- src/asahi/vulkan/hk_descriptor_set_layout.c | 2 +- src/freedreno/vulkan/tu_descriptor_set.cc | 2 +- .../frontends/lavapipe/lvp_descriptor_set.c | 2 +- src/microsoft/vulkan/dzn_descriptor_set.c | 2 +- src/nouveau/vulkan/nvk_descriptor_set_layout.c | 2 +- .../vulkan/panvk_vX_descriptor_set_layout.c | 2 +- src/vulkan/runtime/vk_descriptor_set_layout.c | 14 +++++++++----- src/vulkan/runtime/vk_descriptor_set_layout.h | 8 ++++++-- 9 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c index d734ad75660..2e3cfd13764 100644 --- a/src/amd/vulkan/radv_descriptor_set.c +++ b/src/amd/vulkan/radv_descriptor_set.c @@ -168,7 +168,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea * they are reference counted and may not be destroyed when vkDestroyDescriptorSetLayout is * called. */ - set_layout = vk_descriptor_set_layout_zalloc(&device->vk, size); + set_layout = vk_descriptor_set_layout_zalloc(&device->vk, size, pCreateInfo); if (!set_layout) return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); diff --git a/src/asahi/vulkan/hk_descriptor_set_layout.c b/src/asahi/vulkan/hk_descriptor_set_layout.c index f2251361763..dc7400bacf7 100644 --- a/src/asahi/vulkan/hk_descriptor_set_layout.c +++ b/src/asahi/vulkan/hk_descriptor_set_layout.c @@ -143,7 +143,7 @@ hk_CreateDescriptorSetLayout(VkDevice device, VK_MULTIALLOC_DECL(&ma, struct hk_sampler *, samplers, immutable_sampler_count); - if (!vk_descriptor_set_layout_multizalloc(&dev->vk, &ma)) + if (!vk_descriptor_set_layout_multizalloc(&dev->vk, &ma, pCreateInfo)) return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY); layout->binding_count = num_bindings; diff --git a/src/freedreno/vulkan/tu_descriptor_set.cc b/src/freedreno/vulkan/tu_descriptor_set.cc index e90a44e2662..8f7f2660563 100644 --- a/src/freedreno/vulkan/tu_descriptor_set.cc +++ b/src/freedreno/vulkan/tu_descriptor_set.cc @@ -155,7 +155,7 @@ tu_CreateDescriptorSetLayout( set_layout = (struct tu_descriptor_set_layout *) vk_descriptor_set_layout_zalloc( - &device->vk, size); + &device->vk, size, pCreateInfo); if (!set_layout) return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); diff --git a/src/gallium/frontends/lavapipe/lvp_descriptor_set.c b/src/gallium/frontends/lavapipe/lvp_descriptor_set.c index d276643dd54..98b7d8700ea 100644 --- a/src/gallium/frontends/lavapipe/lvp_descriptor_set.c +++ b/src/gallium/frontends/lavapipe/lvp_descriptor_set.c @@ -88,7 +88,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDescriptorSetLayout( num_bindings * sizeof(set_layout->binding[0]) + immutable_sampler_count * sizeof(struct lvp_sampler *); - set_layout = vk_descriptor_set_layout_zalloc(&device->vk, size); + set_layout = vk_descriptor_set_layout_zalloc(&device->vk, size, pCreateInfo); if (!set_layout) return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); diff --git a/src/microsoft/vulkan/dzn_descriptor_set.c b/src/microsoft/vulkan/dzn_descriptor_set.c index 3a6c8bc5a97..ec162956dd3 100644 --- a/src/microsoft/vulkan/dzn_descriptor_set.c +++ b/src/microsoft/vulkan/dzn_descriptor_set.c @@ -239,7 +239,7 @@ dzn_descriptor_set_layout_create(struct dzn_device *device, VK_MULTIALLOC_DECL(&ma, struct dzn_descriptor_set_layout_binding, binfos, binding_count); - if (!vk_descriptor_set_layout_multizalloc(&device->vk, &ma)) + if (!vk_descriptor_set_layout_multizalloc(&device->vk, &ma, pCreateInfo)) return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); set_layout->static_samplers = static_samplers; diff --git a/src/nouveau/vulkan/nvk_descriptor_set_layout.c b/src/nouveau/vulkan/nvk_descriptor_set_layout.c index a5fb148d2c9..dd777bd3a33 100644 --- a/src/nouveau/vulkan/nvk_descriptor_set_layout.c +++ b/src/nouveau/vulkan/nvk_descriptor_set_layout.c @@ -164,7 +164,7 @@ nvk_CreateDescriptorSetLayout(VkDevice device, VK_MULTIALLOC_DECL(&ma, struct nvk_sampler *, samplers, immutable_sampler_count); - if (!vk_descriptor_set_layout_multizalloc(&dev->vk, &ma)) + if (!vk_descriptor_set_layout_multizalloc(&dev->vk, &ma, pCreateInfo)) return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY); layout->vk.destroy = nvk_descriptor_set_layout_destroy; diff --git a/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c b/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c index 6b366460aeb..9d2783917bc 100644 --- a/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c +++ b/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c @@ -126,7 +126,7 @@ panvk_per_arch(CreateDescriptorSetLayout)( VK_MULTIALLOC_DECL(&ma, struct panvk_sampler *, samplers, immutable_sampler_count); - if (!vk_descriptor_set_layout_multizalloc(&device->vk, &ma)) { + if (!vk_descriptor_set_layout_multizalloc(&device->vk, &ma, pCreateInfo)) { free(bindings); return panvk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); } diff --git a/src/vulkan/runtime/vk_descriptor_set_layout.c b/src/vulkan/runtime/vk_descriptor_set_layout.c index 9e657bec4c5..209a8c3a548 100644 --- a/src/vulkan/runtime/vk_descriptor_set_layout.c +++ b/src/vulkan/runtime/vk_descriptor_set_layout.c @@ -29,17 +29,20 @@ static void vk_descriptor_set_layout_init(struct vk_device *device, - struct vk_descriptor_set_layout *layout) + struct vk_descriptor_set_layout *layout, + const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { vk_object_base_init(device, &layout->base, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT); layout->ref_cnt = 1; + layout->flags = pCreateInfo->flags; layout->destroy = vk_descriptor_set_layout_destroy; } void * -vk_descriptor_set_layout_zalloc(struct vk_device *device, size_t size) +vk_descriptor_set_layout_zalloc(struct vk_device *device, size_t size, + const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { /* Because we're reference counting and lifetimes may not be what the * client expects, these have to be allocated off the device and not as @@ -50,14 +53,15 @@ vk_descriptor_set_layout_zalloc(struct vk_device *device, size_t size) if (!layout) return NULL; - vk_descriptor_set_layout_init(device, layout); + vk_descriptor_set_layout_init(device, layout, pCreateInfo); return layout; } void * vk_descriptor_set_layout_multizalloc(struct vk_device *device, - struct vk_multialloc *ma) + struct vk_multialloc *ma, + const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { /* Because we're reference counting and lifetimes may not be what the * client expects, these have to be allocated off the device and not as @@ -69,7 +73,7 @@ vk_descriptor_set_layout_multizalloc(struct vk_device *device, if (!layout) return NULL; - vk_descriptor_set_layout_init(device, layout); + vk_descriptor_set_layout_init(device, layout, pCreateInfo); return layout; } diff --git a/src/vulkan/runtime/vk_descriptor_set_layout.h b/src/vulkan/runtime/vk_descriptor_set_layout.h index b01f30157e4..9349ac863db 100644 --- a/src/vulkan/runtime/vk_descriptor_set_layout.h +++ b/src/vulkan/runtime/vk_descriptor_set_layout.h @@ -35,6 +35,8 @@ extern "C" { struct vk_descriptor_set_layout { struct vk_object_base base; + VkDescriptorSetLayoutCreateFlags flags; + /* BLAKE3 hash of the descriptor set layout. This is used by the common * pipeline code to properly cache shaders, including handling pipeline * layouts. It must be populated by the driver or you risk pipeline cache @@ -66,10 +68,12 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(vk_descriptor_set_layout, base, VkDescriptorSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT); -void *vk_descriptor_set_layout_zalloc(struct vk_device *device, size_t size); +void *vk_descriptor_set_layout_zalloc(struct vk_device *device, size_t size, + const VkDescriptorSetLayoutCreateInfo *pCreateInfo); void *vk_descriptor_set_layout_multizalloc(struct vk_device *device, - struct vk_multialloc *ma); + struct vk_multialloc *ma, + const VkDescriptorSetLayoutCreateInfo *pCreateInfo); void vk_descriptor_set_layout_destroy(struct vk_device *device, struct vk_descriptor_set_layout *layout);