From 49eb8f42f0636a55b1e1aedc36d560845c6b039a Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 6 Mar 2024 22:40:51 +0800 Subject: [PATCH] updated DescriptorBinding::BindUBO, to support dynamic param. --- inc/hgl/graph/VKDescriptorBindingManage.h | 2 +- .../Vulkan/VKDescriptorBindingManage.cpp | 27 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/inc/hgl/graph/VKDescriptorBindingManage.h b/inc/hgl/graph/VKDescriptorBindingManage.h index 07c4cc3b..75790ffb 100644 --- a/inc/hgl/graph/VKDescriptorBindingManage.h +++ b/inc/hgl/graph/VKDescriptorBindingManage.h @@ -101,7 +101,7 @@ namespace hgl private: - void BindUBO(MaterialParameters *,const BindingMap &); + void BindUBO(MaterialParameters *,const BindingMap &,bool dynamic); public: diff --git a/src/SceneGraph/Vulkan/VKDescriptorBindingManage.cpp b/src/SceneGraph/Vulkan/VKDescriptorBindingManage.cpp index 6be023c5..a22e6c35 100644 --- a/src/SceneGraph/Vulkan/VKDescriptorBindingManage.cpp +++ b/src/SceneGraph/Vulkan/VKDescriptorBindingManage.cpp @@ -3,24 +3,23 @@ #include VK_NAMESPACE_BEGIN -void DescriptorBinding::BindUBO(MaterialParameters *mp,const BindingMap &binding_map) +void DescriptorBinding::BindUBO(MaterialParameters *mp,const BindingMap &binding_map,bool dynamic) { + if (binding_map.GetCount() <= 0)return; + DeviceBuffer* buf = nullptr; - if (binding_map.GetCount() > 0) + const auto *dp =binding_map.GetDataList(); + const uint count =binding_map.GetCount(); + + for(uint i=0;ikey); - for (uint i = 0; i < count; i++) - { - buf = GetUBO((*dp)->key); + if(buf) + mp->BindUBO((*dp)->value,buf,dynamic); - if (buf) - mp->BindUBO((*dp)->value, buf, false); - - ++dp; - } + ++dp; } } @@ -41,8 +40,8 @@ bool DescriptorBinding::Bind(Material *mtl) // const BindingMap &texture_bm=bma[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER]; - BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER]); - BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC]); + BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER],false); + BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC],true); mp->Update(); return(true);