Added composite buffer render passes for deferred lighting path.

Refactoring KRCamera::renderFrame to use render passes.
Eliminate composite buffer binding GL code from KRCamera::renderFrame
This commit is contained in:
2022-07-04 22:08:05 -07:00
parent 17113b59ea
commit 68c3831fde
6 changed files with 90 additions and 90 deletions

View File

@@ -49,6 +49,8 @@ KRSurface::KRSurface(KRContext& context)
, m_frameIndex(0)
{
m_forwardOpaquePass = std::make_unique<KRRenderPass>(context);
m_deferredGBufferPass = std::make_unique<KRRenderPass>(context);
m_deferredOpaquePass = std::make_unique<KRRenderPass>(context);
m_swapChain = std::make_unique<KRSwapchain>(context);
}
@@ -96,6 +98,14 @@ void KRSurface::destroy()
m_forwardOpaquePass->destroy(*device);
}
if (m_deferredGBufferPass) {
m_deferredGBufferPass->destroy(*device);
}
if (m_deferredOpaquePass) {
m_deferredOpaquePass->destroy(*device);
}
if (device && m_renderFinishedSemaphore != VK_NULL_HANDLE) {
vkDestroySemaphore(device->m_logicalDevice, m_renderFinishedSemaphore, nullptr);
m_renderFinishedSemaphore = VK_NULL_HANDLE;
@@ -147,7 +157,19 @@ KrResult KRSurface::createSwapChain()
}
m_forwardOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat);
KRRenderPass::RenderPassInfo info{};
info.clearDepth = true;
info.keepDepth = false;
m_forwardOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);
info.clearDepth = true;
info.keepDepth = true;
m_deferredGBufferPass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);
info.clearDepth = false;
info.keepDepth = false;
m_deferredOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);
m_swapChain->create(*device, m_surface, selectedSurfaceFormat, depthImageFormat, swapExtent, imageCount, *m_forwardOpaquePass);
return KR_SUCCESS;
@@ -196,12 +218,21 @@ VkFormat KRSurface::getDepthFormat() const
return m_swapChain->m_depthFormat;
}
KRRenderPass& KRSurface::getForwardOpaquePass()
{
return *m_forwardOpaquePass;
}
KRRenderPass& KRSurface::getDeferredGBufferPass()
{
return *m_deferredGBufferPass;
}
KRRenderPass& KRSurface::getDeferredOpaquePass()
{
return *m_deferredOpaquePass;
}
void KRSurface::endFrame()
{
m_frameIndex++;;