From 199cc5f6b14feb4ed661780b11082630aa0898fb Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 12 May 2021 19:03:08 +0800 Subject: [PATCH] add DescriptorSets at RenderableInstance class. and renamed RenderableInstance::GetMIDescSets instead of GetDescriptorSets. --- example/common/VulkanAppFramework.h | 2 +- inc/hgl/graph/VKRenderableInstance.h | 5 ++++- res | 2 +- src/SceneGraph/Vulkan/VKRenderableInstance.cpp | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/example/common/VulkanAppFramework.h b/example/common/VulkanAppFramework.h index 37c00bb2..cd7f52e3 100644 --- a/example/common/VulkanAppFramework.h +++ b/example/common/VulkanAppFramework.h @@ -184,7 +184,7 @@ public: cb->SetClearColor(0,clear_color.r,clear_color.g,clear_color.b); cb->BeginRenderPass(); cb->BindPipeline(ri->GetPipeline()); - cb->BindDescriptorSets(ri->GetDescriptorSets()); + cb->BindDescriptorSets(ri->GetMIDescSets()); cb->BindVAB(ri); if (ib) diff --git a/inc/hgl/graph/VKRenderableInstance.h b/inc/hgl/graph/VKRenderableInstance.h index 87845e60..71309b21 100644 --- a/inc/hgl/graph/VKRenderableInstance.h +++ b/inc/hgl/graph/VKRenderableInstance.h @@ -16,6 +16,8 @@ class RenderableInstance MaterialInstance * mat_inst; Renderable * render_obj; + DescriptorSets * descriptor_sets; ///<渲染实例专用描述符合集,一般用于存LocalToWorld等等 + uint32_t buffer_count; VkBuffer * buffer_list; VkDeviceSize * buffer_size; @@ -42,7 +44,8 @@ public: const uint32_t GetIndexBufferOffset()const{return render_obj->GetIndexBufferOffset();} const uint32_t GetDrawCount ()const{return render_obj->GetDrawCount();} - DescriptorSets * GetDescriptorSets ()const{return mat_inst->GetDescriptorSets();} + DescriptorSets * GetMIDescSets ()const{return mat_inst->GetDescriptorSets();} + DescriptorSets * GetRIDescSets ()const{return descriptor_sets;} public: diff --git a/res b/res index bab8e147..45e15237 160000 --- a/res +++ b/res @@ -1 +1 @@ -Subproject commit bab8e14717bf63dfc01a84e49d46bae9332b2ed1 +Subproject commit 45e15237277bc6b1da18c8a8007b2addcb9129bc diff --git a/src/SceneGraph/Vulkan/VKRenderableInstance.cpp b/src/SceneGraph/Vulkan/VKRenderableInstance.cpp index a0607ada..7c611677 100644 --- a/src/SceneGraph/Vulkan/VKRenderableInstance.cpp +++ b/src/SceneGraph/Vulkan/VKRenderableInstance.cpp @@ -10,6 +10,8 @@ RenderableInstance::RenderableInstance(Renderable *r,MaterialInstance *mi,Pipeli mat_inst=mi; pipeline=p; + descriptor_sets=nullptr; + buffer_count=count; buffer_list=bl; buffer_size=bs; @@ -17,6 +19,7 @@ RenderableInstance::RenderableInstance(Renderable *r,MaterialInstance *mi,Pipeli RenderableInstance::~RenderableInstance() { + SAFE_CLEAR(descriptor_sets); //需要在这里添加删除pipeline/desc_sets/render_obj引用计数的代码 delete[] buffer_list;