From 53e79ff3eda0c86ccabb334bcfff4356016199f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Wed, 28 Jan 2026 08:43:33 +0100 Subject: [PATCH] some changes to try --- WickedEngine/shaders/globals.hlsli | 4 ++-- WickedEngine/wiGraphicsDevice_Vulkan.cpp | 10 +++++----- WickedEngine/wiGraphicsDevice_Vulkan.h | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/WickedEngine/shaders/globals.hlsli b/WickedEngine/shaders/globals.hlsli index ce6e77a35..b125b9828 100644 --- a/WickedEngine/shaders/globals.hlsli +++ b/WickedEngine/shaders/globals.hlsli @@ -404,8 +404,8 @@ static const BindlessResource bindless_accelera // But vk::binding works correctly in this case. // HLSL register space declaration is working well with Vulkan when spaces are not overlapping. // This layout with two descriptor sets can be implemented onn Vulkan side with mutable descriptors. -static const uint DESCRIPTOR_SET_BINDLESS_RESOURCE = 1; -static const uint DESCRIPTOR_SET_BINDLESS_SAMPLER = 2; +static const uint DESCRIPTOR_SET_BINDLESS_SAMPLER = 1; +static const uint DESCRIPTOR_SET_BINDLESS_RESOURCE = 2; [[vk::binding(0, DESCRIPTOR_SET_BINDLESS_SAMPLER)]] SamplerState bindless_samplers[]; [[vk::binding(0, DESCRIPTOR_SET_BINDLESS_RESOURCE)]] ByteAddressBuffer bindless_buffers[]; diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index 105c03580..049798136 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -3222,15 +3222,15 @@ using namespace vulkan_internal; assert(features_1_2.descriptorBindingStorageTexelBufferUpdateAfterBind == VK_TRUE); // Note: bindless uniform buffer is not used, don't need to check it + allocationhandler->bindless_samplers.init(this, VK_DESCRIPTOR_TYPE_SAMPLER, std::min(BINDLESS_SAMPLER_CAPACITY, properties_1_2.maxDescriptorSetUpdateAfterBindSampledImages)); + descriptor_set_layouts[DESCRIPTOR_SET_BINDLESS_SAMPLER] = allocationhandler->bindless_samplers.descriptorSetLayout; + uint32_t bindless_resource_capacity_real = BINDLESS_RESOURCE_CAPACITY; bindless_resource_capacity_real = std::min(bindless_resource_capacity_real, properties_1_2.maxDescriptorSetUpdateAfterBindSampledImages); bindless_resource_capacity_real = std::min(bindless_resource_capacity_real, properties_1_2.maxDescriptorSetUpdateAfterBindStorageImages); bindless_resource_capacity_real = std::min(bindless_resource_capacity_real, properties_1_2.maxDescriptorSetUpdateAfterBindStorageBuffers); allocationhandler->bindless_resources.init(this, VK_DESCRIPTOR_TYPE_MUTABLE_EXT, bindless_resource_capacity_real); descriptor_set_layouts[DESCRIPTOR_SET_BINDLESS_RESOURCE] = allocationhandler->bindless_resources.descriptorSetLayout; - - allocationhandler->bindless_samplers.init(this, VK_DESCRIPTOR_TYPE_SAMPLER, std::min(BINDLESS_SAMPLER_CAPACITY, properties_1_2.maxDescriptorSetUpdateAfterBindSampledImages)); - descriptor_set_layouts[DESCRIPTOR_SET_BINDLESS_SAMPLER] = allocationhandler->bindless_samplers.descriptorSetLayout; } // Pipeline layouts: @@ -6392,8 +6392,8 @@ using namespace vulkan_internal; vulkan_check(vkBeginCommandBuffer(commandlist.GetCommandBuffer(), &beginInfo)); const VkDescriptorSet descriptor_sets[] = { - allocationhandler->bindless_resources.descriptorSet, allocationhandler->bindless_samplers.descriptorSet, + allocationhandler->bindless_resources.descriptorSet, }; if (queue == QUEUE_GRAPHICS) @@ -8483,8 +8483,8 @@ using namespace vulkan_internal; // Note: bind descriptor set for RT here instead of BeginCommandList to not set it needlessly const VkDescriptorSet descriptor_sets[] = { - allocationhandler->bindless_resources.descriptorSet, allocationhandler->bindless_samplers.descriptorSet, + allocationhandler->bindless_resources.descriptorSet, }; vkCmdBindDescriptorSets( commandlist.GetCommandBuffer(), diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.h b/WickedEngine/wiGraphicsDevice_Vulkan.h index 5f0b4b4c5..2b5b70165 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.h +++ b/WickedEngine/wiGraphicsDevice_Vulkan.h @@ -114,8 +114,8 @@ namespace wi::graphics enum DESCRIPTOR_SET { DESCRIPTOR_SET_BINDINGS, - DESCRIPTOR_SET_BINDLESS_RESOURCE, DESCRIPTOR_SET_BINDLESS_SAMPLER, + DESCRIPTOR_SET_BINDLESS_RESOURCE, DESCRIPTOR_SET_COUNT, }; VkDescriptorSetLayout descriptor_set_layouts[DESCRIPTOR_SET_COUNT] = {}; @@ -619,7 +619,8 @@ namespace wi::graphics const VkDescriptorBindingFlags bindingFlags = VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT | VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | - VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT; + VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT | + VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT; VkDescriptorSetLayoutBindingFlagsCreateInfo bindingFlagsInfo = {}; bindingFlagsInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO; bindingFlagsInfo.bindingCount = 1;