From 55204779bac56592fe52aed163d982537c04c80a Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 6 Jun 2025 23:39:20 +0800 Subject: [PATCH] =?UTF-8?q?RenderCmdBuffer=E4=B8=AD=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=9A=84DescriptorBinding=E6=94=B9=E4=B8=BA=E6=8C=89SetType?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E4=B8=BA=E5=A4=9A=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/graph/VKCommandBuffer.h | 8 +++++--- inc/hgl/graph/VKDescriptorBindingManage.h | 4 ++++ .../Vulkan/VKCommandBufferRender.cpp | 19 +++++++++++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/inc/hgl/graph/VKCommandBuffer.h b/inc/hgl/graph/VKCommandBuffer.h index 50085ec0..7188d549 100644 --- a/inc/hgl/graph/VKCommandBuffer.h +++ b/inc/hgl/graph/VKCommandBuffer.h @@ -50,6 +50,8 @@ public: };//class VulkanCmdBuffer class DescriptorBinding; +using DescriptorBindingPtr=DescriptorBinding *; +using DescriptorBindingArray=DescriptorBindingPtr[size_t(DescriptorSetType::RANGE_SIZE)]; class RenderCmdBuffer:public VulkanCmdBuffer { @@ -61,7 +63,7 @@ class RenderCmdBuffer:public VulkanCmdBuffer RenderPassBeginInfo rp_begin; VkPipelineLayout pipeline_layout; - DescriptorBinding *desc_binding=nullptr; + DescriptorBindingArray desc_binding{}; private: @@ -72,11 +74,11 @@ public: RenderCmdBuffer(const VulkanDevAttr *attr,VkCommandBuffer cb); ~RenderCmdBuffer(); - void SetDescriptorBinding(DescriptorBinding *db) { desc_binding=db; } + bool SetDescriptorBinding(DescriptorBinding *); bool End() override { - desc_binding=nullptr; + hgl_zero(desc_binding); return VulkanCmdBuffer::End(); } diff --git a/inc/hgl/graph/VKDescriptorBindingManage.h b/inc/hgl/graph/VKDescriptorBindingManage.h index edff0efc..07315914 100644 --- a/inc/hgl/graph/VKDescriptorBindingManage.h +++ b/inc/hgl/graph/VKDescriptorBindingManage.h @@ -24,6 +24,10 @@ class DescriptorBinding Map ssbo_map; Map texture_map; +public: + + const DescriptorSetType GetType()const{return set_type;} + public: DescriptorBinding(const DescriptorSetType &dst) diff --git a/src/SceneGraph/Vulkan/VKCommandBufferRender.cpp b/src/SceneGraph/Vulkan/VKCommandBufferRender.cpp index 06e95dd0..51b1103d 100644 --- a/src/SceneGraph/Vulkan/VKCommandBufferRender.cpp +++ b/src/SceneGraph/Vulkan/VKCommandBufferRender.cpp @@ -25,6 +25,18 @@ RenderCmdBuffer::~RenderCmdBuffer() hgl_free(clear_values); } +bool RenderCmdBuffer::SetDescriptorBinding(DescriptorBinding *db) +{ + if(!db) + return(false); + + const int index=int(db->GetType())-int(DescriptorSetType::BEGIN_RANGE); + + desc_binding[index]=db; + + return(true); +} + void RenderCmdBuffer::SetClear() { if(cv_count>0) @@ -91,8 +103,11 @@ bool RenderCmdBuffer::BindDescriptorSets(Material *mtl) { if(!mtl)return(false); - if(desc_binding) - desc_binding->Bind(mtl); + ENUM_CLASS_FOR(DescriptorSetType,int,i) + { + if(desc_binding[i]) + desc_binding[i]->Bind(mtl); + } { uint32_t count=0;