fixed Order for to release graph modules.

This commit is contained in:
hyzboy 2024-11-14 23:40:26 +08:00
parent fda5b629a2
commit abad1784c2
4 changed files with 32 additions and 10 deletions

View File

@ -13,7 +13,9 @@ class GraphModuleManager
{
GPUDevice *device;
Map<AnsiIDName,GraphModule *> graph_module_map;
List<GraphModule *> module_list; ///<模块列表
Map<AnsiIDName,GraphModule *> graph_module_map; ///<模块映射表
public:
@ -86,12 +88,8 @@ public:
NO_COPY_NO_MOVE(GraphModule)
GraphModule(GraphModuleManager *gmm,const AnsiIDName &name)
{
module_manager=gmm;
module_name=name;
}
virtual ~GraphModule()=default;
GraphModule(GraphModuleManager *gmm,const AnsiIDName &name);
virtual ~GraphModule();
virtual bool Init(){return true;} ///<初始化当前模块

View File

@ -27,7 +27,6 @@ RTSwapchain::RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rc
RTSwapchain::~RTSwapchain()
{
delete present_complete_semaphore;
delete swapchain;
}
uint32_t RTSwapchain::AcquireNextImage()

View File

@ -1,7 +1,20 @@
#include<hgl/graph/module/GraphModule.h>
#include<hgl/graph/VKDevice.h>
#include<hgl/log/LogInfo.h>
VK_NAMESPACE_BEGIN
GraphModule::GraphModule(GraphModuleManager *gmm,const AnsiIDName &name)
{
module_manager=gmm;
module_name=name;
LOG_INFO("GraphModule::GraphModule: "+AnsiString(module_name.GetName()))
}
GraphModule::~GraphModule()
{
LOG_INFO("GraphModule::~GraphModule: "+AnsiString(module_name.GetName()))
}
VK_NAMESPACE_END

View File

@ -94,7 +94,10 @@ GraphModule *GraphModuleManager::GetModule(const AnsiIDName &name,bool create)
gm=CreateGraphModule(name,this);
if(gm)
{
graph_module_map.Add(name,gm);
module_list.Add(gm);
}
return gm;
}
@ -104,10 +107,19 @@ GraphModule *GraphModuleManager::GetModule(const AnsiIDName &name,bool create)
GraphModuleManager::~GraphModuleManager()
{
for(auto *gm:graph_module_map)
//按顺序加入module_list的要倒着释放
GraphModule **gm=module_list.end();
while(gm>module_list.begin())
{
delete gm->value;
--gm;
delete *gm;
}
//其实下面释不释放都无所谓了
module_list.Clear();
graph_module_map.Clear();
}
void GraphModuleManager::ReleaseModule(GraphModule *gm)