diff --git a/inc/hgl/graph/RenderNode.h b/inc/hgl/graph/RenderNode.h index 41a42dcc..79e0075d 100644 --- a/inc/hgl/graph/RenderNode.h +++ b/inc/hgl/graph/RenderNode.h @@ -13,7 +13,7 @@ namespace hgl struct RenderNode { - uint index; ///<在MaterialRenderList中的索引 + uint index; ///<在MaterialRenderList中的索引 SceneNode * scene_node; diff --git a/inc/hgl/graph/VKPipeline.h b/inc/hgl/graph/VKPipeline.h index 7cc525bb..3678f335 100644 --- a/inc/hgl/graph/VKPipeline.h +++ b/inc/hgl/graph/VKPipeline.h @@ -6,6 +6,10 @@ #include #include VK_NAMESPACE_BEGIN +/** +* 管线
+* 管线管理了一批次渲染的所有基础条件,包括顶点输入、着色器、混合、深度测试等等 +*/ class Pipeline { VkDevice device; diff --git a/inc/hgl/graph/module/GraphModule.h b/inc/hgl/graph/module/GraphModule.h index 8d72a956..ce3989a2 100644 --- a/inc/hgl/graph/module/GraphModule.h +++ b/inc/hgl/graph/module/GraphModule.h @@ -65,7 +65,8 @@ public: virtual const bool IsRender(){return false;} ///<是否为渲染模块 GraphModuleManager *GetManager(){return module_manager;} ///<取得模块管理器 - GPUDevice *GetDevice(){return module_manager->GetDevice();} ///<取得GPU设备 + GPUDevice * GetDevice(){return module_manager->GetDevice();} ///<取得GPU设备 + GPUDeviceAttribute *GetDeviceAttribute(); static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用) virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale) diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index a11a86aa..1f30cd7e 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -284,6 +284,7 @@ SET(GRAPH_MODULE_HEADER ${SGM_HEADER_PATH}/GraphModule.h ${SGM_HEADER_PATH}/SwapchainModule.h) SET(GRAPH_MODULE_SOURCE module/GraphModule.cpp + module/GraphModuleManager.cpp module/GraphModuleFactory.cpp module/RenderModule.cpp module/RegistryCommonModule.cpp diff --git a/src/SceneGraph/module/GraphModule.cpp b/src/SceneGraph/module/GraphModule.cpp index 87a3e7df..b6a9f960 100644 --- a/src/SceneGraph/module/GraphModule.cpp +++ b/src/SceneGraph/module/GraphModule.cpp @@ -1,111 +1,11 @@ #include -#include +#include VK_NAMESPACE_BEGIN -namespace +GPUDeviceAttribute *GraphModule::GetDeviceAttribute() { - using GraphModuleManagerMap=Map; - - static GraphModuleManagerMap *graph_module_manager_map=nullptr; -} - -GraphModuleManager *InitGraphModuleManager(GPUDevice *dev) -{ - if(!dev) - return(nullptr); - - if(graph_module_manager_map) - { - if(graph_module_manager_map->ContainsKey(dev)) - return(nullptr); - } - else - { - graph_module_manager_map=new GraphModuleManagerMap; - } - - GraphModuleManager *gmm=new GraphModuleManager(dev); - - graph_module_manager_map->Add(dev,gmm); - - return gmm; -} - -bool ClearGraphModuleManager(GPUDevice *dev) -{ - if(!dev) - return(false); - - if(!graph_module_manager_map) - return(false); - - GraphModuleManager *gmm; - - if(!graph_module_manager_map->Get(dev,gmm)) - return(false); - - graph_module_manager_map->DeleteByKey(dev); - - delete gmm; - return(true); -} - -GraphModuleManager *GetGraphModuleManager(GPUDevice *dev) -{ - if(!dev) - return(nullptr); - - if(!graph_module_manager_map) - return(nullptr); - - GraphModuleManager *gmm; - - if(graph_module_manager_map->Get(dev,gmm)) - return gmm; - - return(nullptr); -} - -GraphModule *CreateGraphModule(const AnsiIDName &name,GraphModuleManager *gmm); - -GraphModule *GraphModuleManager::GetModule(const AnsiIDName &name,bool create) -{ - GraphModule *gm; - - if(graph_module_map.Get(name,gm)) - return gm; - - if(create) - { - gm=CreateGraphModule(name,this); - - if(gm) - graph_module_map.Add(name,gm); - - return gm; - } - - return nullptr; -} - -GraphModuleManager::~GraphModuleManager() -{ - for(auto *gm:graph_module_map) - { - delete gm->value; - } -} - -void GraphModuleManager::OnResize(const VkExtent2D &extent) -{ - if(graph_module_map.IsEmpty()) - return; - - for(auto *gm:graph_module_map) - { - gm->value->OnResize(extent); - } + return module_manager->GetDevice()->GetDeviceAttribute(); } VK_NAMESPACE_END diff --git a/src/SceneGraph/module/GraphModuleManager.cpp b/src/SceneGraph/module/GraphModuleManager.cpp new file mode 100644 index 00000000..87a3e7df --- /dev/null +++ b/src/SceneGraph/module/GraphModuleManager.cpp @@ -0,0 +1,111 @@ +#include +#include + +VK_NAMESPACE_BEGIN + +namespace +{ + using GraphModuleManagerMap=Map; + + static GraphModuleManagerMap *graph_module_manager_map=nullptr; +} + +GraphModuleManager *InitGraphModuleManager(GPUDevice *dev) +{ + if(!dev) + return(nullptr); + + if(graph_module_manager_map) + { + if(graph_module_manager_map->ContainsKey(dev)) + return(nullptr); + } + else + { + graph_module_manager_map=new GraphModuleManagerMap; + } + + GraphModuleManager *gmm=new GraphModuleManager(dev); + + graph_module_manager_map->Add(dev,gmm); + + return gmm; +} + +bool ClearGraphModuleManager(GPUDevice *dev) +{ + if(!dev) + return(false); + + if(!graph_module_manager_map) + return(false); + + GraphModuleManager *gmm; + + if(!graph_module_manager_map->Get(dev,gmm)) + return(false); + + graph_module_manager_map->DeleteByKey(dev); + + delete gmm; + return(true); +} + +GraphModuleManager *GetGraphModuleManager(GPUDevice *dev) +{ + if(!dev) + return(nullptr); + + if(!graph_module_manager_map) + return(nullptr); + + GraphModuleManager *gmm; + + if(graph_module_manager_map->Get(dev,gmm)) + return gmm; + + return(nullptr); +} + +GraphModule *CreateGraphModule(const AnsiIDName &name,GraphModuleManager *gmm); + +GraphModule *GraphModuleManager::GetModule(const AnsiIDName &name,bool create) +{ + GraphModule *gm; + + if(graph_module_map.Get(name,gm)) + return gm; + + if(create) + { + gm=CreateGraphModule(name,this); + + if(gm) + graph_module_map.Add(name,gm); + + return gm; + } + + return nullptr; +} + +GraphModuleManager::~GraphModuleManager() +{ + for(auto *gm:graph_module_map) + { + delete gm->value; + } +} + +void GraphModuleManager::OnResize(const VkExtent2D &extent) +{ + if(graph_module_map.IsEmpty()) + return; + + for(auto *gm:graph_module_map) + { + gm->value->OnResize(extent); + } +} + +VK_NAMESPACE_END