SHViewport now takes in a RenderGraph instead of creating one

This commit is contained in:
Kah Wei 2022-09-18 14:49:15 +08:00
parent a3aa708b34
commit 7a126bf1fc
5 changed files with 32 additions and 34 deletions

View File

@ -109,13 +109,13 @@ namespace SHADE
defaultViewport = AddViewport(vk::Viewport(0.0f, 0.0f, window->GetWindowSize().first, window->GetWindowSize().second, 0.0f, 1.0f)); defaultViewport = AddViewport(vk::Viewport(0.0f, 0.0f, window->GetWindowSize().first, window->GetWindowSize().second, 0.0f, 1.0f));
// Create Debug Renderers // Create Debug Renderers
debugScreenRenderer = defaultViewport->AddRenderer(resourceManager); debugScreenRenderer = defaultViewport->AddRenderer(resourceManager,);
debugScreenRenderer->SetCamera(screenCamera); debugScreenRenderer->SetCamera(screenCamera);
debugWorldRenderer = defaultViewport->AddRenderer(resourceManager); debugWorldRenderer = defaultViewport->AddRenderer(resourceManager, );
debugWorldRenderer->SetCamera(worldCamera); debugWorldRenderer->SetCamera(worldCamera);
// Add world renderer to default viewport // Add world renderer to default viewport
worldRenderer = defaultViewport->AddRenderer(resourceManager); worldRenderer = defaultViewport->AddRenderer(resourceManager, );
worldRenderer->SetCamera(worldCamera); worldRenderer->SetCamera(worldCamera);
// Get render graph from default viewport world renderer // Get render graph from default viewport world renderer

View File

@ -21,27 +21,25 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE namespace SHADE
{ {
/*---------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Constructor/Destructors */ /* Constructor/Destructors */
/*---------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHRenderer::SHRenderer(Handle<SHViewport> viewport, ResourceManager& resourceManager) SHRenderer::SHRenderer(Handle<SHViewport> viewport, Handle<SHRenderGraph> renderGraph)
: viewport { viewport } : viewport { viewport }
, renderGraph { resourceManager.Create<SHRenderGraph> ()} , renderGraph { renderGraph }
{ {}
} /*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
/* Camera Registration */ /* Camera Registration */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void SHRenderer::SetCamera(Handle<SHCamera> _camera) void SHRenderer::SetCamera(Handle<SHCamera> _camera)
{ {
camera = _camera; camera = _camera;
} }
/*---------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Drawing Functions */ /* Drawing Functions */
/*---------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void SHRenderer::Draw(uint32_t frameIndex) noexcept void SHRenderer::Draw(uint32_t frameIndex) noexcept
{ {
renderGraph->Execute(frameIndex); renderGraph->Execute(frameIndex);

View File

@ -52,7 +52,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Constructor/Destructors */ /* Constructor/Destructors */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
SHRenderer(Handle<SHViewport> viewport, ResourceManager& resourceManager); SHRenderer(Handle<SHViewport> viewport, Handle<SHRenderGraph> renderGraph);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Camera Registration */ /* Camera Registration */

View File

@ -48,10 +48,10 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Renderer Registration Functions */ /* Renderer Registration Functions */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
Handle<SHRenderer> SHViewport::AddRenderer(ResourceManager& resourceManager) Handle<SHRenderer> SHViewport::AddRenderer(ResourceManager& resourceManager, Handle<SHRenderGraph> renderGraph)
{ {
// Create the renderer // Create the renderer
auto renderer = SHVkInstance::GetResourceManager().Create<SHRenderer>(GetHandle(), resourceManager); auto renderer = SHVkInstance::GetResourceManager().Create<SHRenderer>(GetHandle(), renderGraph);
// Store // Store
renderers.emplace_back(renderer); renderers.emplace_back(renderer);

View File

@ -55,7 +55,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Renderers Registration Functions */ /* Renderers Registration Functions */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
Handle<SHRenderer> AddRenderer(ResourceManager& resourceManager); Handle<SHRenderer> AddRenderer(ResourceManager& resourceManager, Handle<SHRenderGraph> renderGraph);
void RemoveRenderer(Handle<SHRenderer> renderer); void RemoveRenderer(Handle<SHRenderer> renderer);
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/