From 8abe9c3d9ddc03560b7d91a51c1957f88cd64c29 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 17 Jul 2019 12:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=87=8D=E5=A4=8DUBO?= =?UTF-8?q?=E8=A2=AB=E9=87=8D=E5=A4=8D=E7=BB=91=E5=AE=9A=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Vulkan/VKDescriptorSetLayoutCreater.cpp | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp index bfdf190a..9d7af084 100644 --- a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp +++ b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp @@ -14,6 +14,12 @@ DescriptorSetLayoutCreater::~DescriptorSetLayoutCreater() void DescriptorSetLayoutCreater::Bind(const uint32_t binding,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags) { + if(index_by_binding.KeyExist(binding)) + { + //重复的绑定点,有可能存在的,比如WorldMatrix在vs/fs中同时存在 + return; + } + VkDescriptorSetLayoutBinding layout_binding; layout_binding.binding = binding; @@ -33,23 +39,32 @@ void DescriptorSetLayoutCreater::Bind(const uint32_t *binding,const uint32_t cou const uint old_count=layout_binding_list.GetCount(); - layout_binding_list.SetCount(old_count+count); + layout_binding_list.PreMalloc(old_count+count); VkDescriptorSetLayoutBinding *p=layout_binding_list.GetData()+old_count; + uint fin_count=0; + for(uint i=old_count;ibinding = *binding; - p->descriptorType = desc_type; - p->descriptorCount = 1; - p->stageFlags = stageFlags; - p->pImmutableSamplers = nullptr; + if(!index_by_binding.KeyExist(*binding)) + { + p->binding = *binding; + p->descriptorType = desc_type; + p->descriptorCount = 1; + p->stageFlags = stageFlags; + p->pImmutableSamplers = nullptr; - index_by_binding.Add(*binding,i); + index_by_binding.Add(*binding,i); + + ++p; + ++fin_count; + } ++binding; - ++p; } + + layout_binding_list.SetCount(old_count+fin_count); } bool DescriptorSetLayoutCreater::CreatePipelineLayout()