added to RenderCmdBuffer's Begin and End of Swapchain in RenderFramework::MainLoop
This commit is contained in:
parent
2ab78bf4e6
commit
fda5b629a2
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 2dfcdf0e4114729384b1c8490c8ab048f9c11c80
|
Subproject commit 753b78dddf234cd305b5d211c687b311eebaaf8a
|
@ -1,8 +1,30 @@
|
|||||||
#include<hgl/graph/RenderFramework.h>
|
#include<hgl/graph/RenderFramework.h>
|
||||||
|
#include<hgl/graph/module/RenderModule.h>
|
||||||
|
#include<hgl/graph/VKCommandBuffer.h>
|
||||||
|
#include<hgl/log/Logger.h>
|
||||||
|
|
||||||
using namespace hgl;
|
using namespace hgl;
|
||||||
using namespace hgl::graph;
|
using namespace hgl::graph;
|
||||||
|
|
||||||
|
class TestRenderModule:public RenderModule
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
RENDER_MODULE_CONSTRUCT(TestRenderModule)
|
||||||
|
|
||||||
|
void OnResize(const VkExtent2D &size) override
|
||||||
|
{
|
||||||
|
LOG_INFO(OS_TEXT("Resize: ")+OSString::numberOf(size.width)+OS_TEXT("x")+OSString::numberOf(size.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnExecute(const double,RenderCmdBuffer *cmd)
|
||||||
|
{
|
||||||
|
LOG_INFO(OS_TEXT("Execute"));
|
||||||
|
|
||||||
|
//cmd->Begin
|
||||||
|
}
|
||||||
|
};//class TestGraphModule:public RenderModule
|
||||||
|
|
||||||
int os_main(int,os_char **)
|
int os_main(int,os_char **)
|
||||||
{
|
{
|
||||||
RenderFramework rf;
|
RenderFramework rf;
|
||||||
@ -10,6 +32,8 @@ int os_main(int,os_char **)
|
|||||||
if(!rf.Init(1280,720,OS_TEXT("FirstApp")))
|
if(!rf.Init(1280,720,OS_TEXT("FirstApp")))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
rf.AddModule<TestRenderModule>();
|
||||||
|
|
||||||
rf.Run();
|
rf.Run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -67,6 +67,15 @@ public: //module
|
|||||||
|
|
||||||
template<typename T> T *GetModule(){return graph_module_manager->GetModule<T>(false);} ///<获取指定类型的模块
|
template<typename T> T *GetModule(){return graph_module_manager->GetModule<T>(false);} ///<获取指定类型的模块
|
||||||
|
|
||||||
|
template<typename T> T *AddModule()
|
||||||
|
{
|
||||||
|
T *tm=new T(graph_module_manager);
|
||||||
|
|
||||||
|
module_list.Add(tm);
|
||||||
|
|
||||||
|
return tm;
|
||||||
|
}
|
||||||
|
|
||||||
SwapchainModule *GetSwapchain(){return swapchain_module;} ///<取得Swapchain模块
|
SwapchainModule *GetSwapchain(){return swapchain_module;} ///<取得Swapchain模块
|
||||||
|
|
||||||
public: //manager
|
public: //manager
|
||||||
|
@ -122,4 +122,14 @@ public: //回调事件
|
|||||||
\
|
\
|
||||||
name(GraphModuleManager *gmm):GraphModule(gmm,GetModuleName()){}
|
name(GraphModuleManager *gmm):GraphModule(gmm,GetModuleName()){}
|
||||||
|
|
||||||
|
#define RENDER_MODULE_CONSTRUCT(name) public:\
|
||||||
|
NO_COPY_NO_MOVE(name) \
|
||||||
|
static const AnsiIDName &GetModuleName() \
|
||||||
|
{ \
|
||||||
|
static const AnsiIDName id_name(#name); \
|
||||||
|
return id_name; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
name(GraphModuleManager *gmm):RenderModule(gmm,GetModuleName()){}
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -24,6 +24,8 @@ public:
|
|||||||
virtual ~RenderModule()=default;
|
virtual ~RenderModule()=default;
|
||||||
|
|
||||||
virtual void OnResize(const VkExtent2D &ext)override{current_extent=ext;}
|
virtual void OnResize(const VkExtent2D &ext)override{current_extent=ext;}
|
||||||
|
|
||||||
|
virtual void OnExecute(const double,RenderCmdBuffer *){}
|
||||||
};//class RenderModule
|
};//class RenderModule
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -47,6 +47,8 @@ public:
|
|||||||
|
|
||||||
const VkExtent2D & GetSwapchainSize()const {return swapchain_rt->GetExtent();}
|
const VkExtent2D & GetSwapchainSize()const {return swapchain_rt->GetExtent();}
|
||||||
|
|
||||||
|
RenderCmdBuffer *GetRenderCmdBuffer();
|
||||||
|
|
||||||
};//class SwapchainModule:public GraphModule
|
};//class SwapchainModule:public GraphModule
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include<hgl/graph/manager/TextureManager.h>
|
#include<hgl/graph/manager/TextureManager.h>
|
||||||
#include<hgl/graph/module/SwapchainModule.h>
|
#include<hgl/graph/module/SwapchainModule.h>
|
||||||
#include<hgl/graph/VKDeviceCreater.h>
|
#include<hgl/graph/VKDeviceCreater.h>
|
||||||
|
#include<hgl/graph/VKCommandBuffer.h>
|
||||||
#include<hgl/Time.h>
|
#include<hgl/Time.h>
|
||||||
#include<hgl/log/LogInfo.h>
|
#include<hgl/log/LogInfo.h>
|
||||||
|
|
||||||
@ -76,10 +77,20 @@ void RenderFramework::MainLoop()
|
|||||||
|
|
||||||
BeginFrame();
|
BeginFrame();
|
||||||
|
|
||||||
for(auto rm:module_list)
|
RenderCmdBuffer *rcb=swapchain_module->GetRenderCmdBuffer();
|
||||||
|
|
||||||
|
if(rcb)
|
||||||
{
|
{
|
||||||
if(rm->IsEnable())
|
rcb->Begin();
|
||||||
rm->OnExecute(delta_time,nullptr);
|
rcb->BindFramebuffer(swapchain_module->GetRenderPass(),swapchain_module->GetRenderTarget()->GetFramebuffer());
|
||||||
|
|
||||||
|
for(auto rm:module_list)
|
||||||
|
{
|
||||||
|
if(rm->IsEnable())
|
||||||
|
rm->OnExecute(delta_time,rcb);
|
||||||
|
}
|
||||||
|
|
||||||
|
rcb->End();
|
||||||
}
|
}
|
||||||
|
|
||||||
EndFrame();
|
EndFrame();
|
||||||
|
@ -286,4 +286,14 @@ void SwapchainModule::EndFrame()
|
|||||||
swapchain_rt->WaitFence();
|
swapchain_rt->WaitFence();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RenderCmdBuffer *SwapchainModule::GetRenderCmdBuffer()
|
||||||
|
{
|
||||||
|
int index=swapchain_rt->GetCurrentFrameIndices();
|
||||||
|
|
||||||
|
if(index>=swapchain->image_count)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
return cmd_buf[index];
|
||||||
|
}
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user