diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index 844c7034e..ce7e3580a 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -705,7 +705,7 @@ int main(int argc, char* argv[]) godRaysTexture = graph.AddAttachment({ .name = "God rays texture", .format = Nz::PixelFormat::RGBA16F, - .size = Nz::FramePassAttachmentSize::SwapchainFactor, + .size = Nz::FramePassAttachmentSize::ViewerTargetFactor, .width = 50'000, .height = 50'000 }); @@ -716,7 +716,7 @@ int main(int argc, char* argv[]) bloomBrightOutput = graph.AddAttachment({ .name = "Bloom bright output", .format = Nz::PixelFormat::RGBA16F, - .size = Nz::FramePassAttachmentSize::SwapchainFactor, + .size = Nz::FramePassAttachmentSize::ViewerTargetFactor, .width = bloomSize, .height = bloomSize }); @@ -726,7 +726,7 @@ int main(int argc, char* argv[]) bloomTextures[i * 2 + 0] = graph.AddAttachment({ .name = "Bloom texture #" + std::to_string(i), .format = Nz::PixelFormat::RGBA16F, - .size = Nz::FramePassAttachmentSize::SwapchainFactor, + .size = Nz::FramePassAttachmentSize::ViewerTargetFactor, .width = bloomSize, .height = bloomSize }); @@ -735,7 +735,7 @@ int main(int argc, char* argv[]) bloomTextures[i * 2 + 1] = graph.AddAttachment({ .name = "Bloom texture #" + std::to_string(i), .format = Nz::PixelFormat::RGBA16F, - .size = Nz::FramePassAttachmentSize::SwapchainFactor, + .size = Nz::FramePassAttachmentSize::ViewerTargetFactor, .width = bloomSize, .height = bloomSize }); @@ -746,7 +746,7 @@ int main(int argc, char* argv[]) toneMappingOutput = graph.AddAttachment({ .name = "Tone mapping", .format = Nz::PixelFormat::RGBA8, - .size = Nz::FramePassAttachmentSize::SwapchainFactor, + .size = Nz::FramePassAttachmentSize::ViewerTargetFactor, .width = 100'000, .height = 100'000 }); @@ -1526,7 +1526,7 @@ int main(int argc, char* argv[]) clearValues[1].depth = 1.f; clearValues[1].stencil = 0; - builder.BeginRenderPass(windowRT->GetFramebuffer(frame.GetFramebufferIndex()), windowRT->GetRenderPass(), windowRenderRect, { clearValues[0], clearValues[1] }); + builder.BeginRenderPass(windowRT->GetFramebuffer(frame.GetImageIndex()), windowRT->GetRenderPass(), windowRenderRect, { clearValues[0], clearValues[1] }); { builder.BeginDebugRegion("Main window rendering", Nz::Color::Green()); { diff --git a/include/Nazara/Graphics/BakedFrameGraph.hpp b/include/Nazara/Graphics/BakedFrameGraph.hpp index 5cbf7712f..7dfc9bb95 100644 --- a/include/Nazara/Graphics/BakedFrameGraph.hpp +++ b/include/Nazara/Graphics/BakedFrameGraph.hpp @@ -91,6 +91,7 @@ namespace Nz std::shared_ptr m_commandPool; std::vector m_passes; std::vector m_textures; + std::vector m_viewerSizes; AttachmentIdToTextureId m_attachmentToTextureMapping; PassIdToPhysicalPassIndex m_passIdToPhysicalPassMapping; unsigned int m_height; diff --git a/include/Nazara/Graphics/FramePassAttachment.hpp b/include/Nazara/Graphics/FramePassAttachment.hpp index 7fdfca9b2..e5cad46f7 100644 --- a/include/Nazara/Graphics/FramePassAttachment.hpp +++ b/include/Nazara/Graphics/FramePassAttachment.hpp @@ -18,7 +18,6 @@ namespace Nz enum class FramePassAttachmentSize { Fixed, - SwapchainFactor, ViewerTargetFactor, }; diff --git a/src/Nazara/Graphics/BakedFrameGraph.cpp b/src/Nazara/Graphics/BakedFrameGraph.cpp index fa3b47ec7..7a46c3cb8 100644 --- a/src/Nazara/Graphics/BakedFrameGraph.cpp +++ b/src/Nazara/Graphics/BakedFrameGraph.cpp @@ -14,9 +14,7 @@ namespace Nz m_passes(std::move(passes)), m_textures(std::move(textures)), m_attachmentToTextureMapping(std::move(attachmentIdToTextureMapping)), - m_passIdToPhysicalPassMapping(std::move(passIdToPhysicalPassMapping)), - m_height(0), - m_width(0) + m_passIdToPhysicalPassMapping(std::move(passIdToPhysicalPassMapping)) { const std::shared_ptr& renderDevice = Graphics::Instance()->GetRenderDevice(); m_commandPool = renderDevice->InstantiateCommandPool(QueueType::Graphics); @@ -131,8 +129,7 @@ namespace Nz bool BakedFrameGraph::Resize(RenderFrame& renderFrame, std::span viewerTargetSizes) { - Vector2ui swapchainSize = renderFrame.GetSize(); - if (m_width == swapchainSize.x && m_height == swapchainSize.y) + if (std::equal(m_viewerSizes.begin(), m_viewerSizes.end(), viewerTargetSizes.begin(), viewerTargetSizes.end())) return false; const std::shared_ptr& renderDevice = Graphics::Instance()->GetRenderDevice(); @@ -147,13 +144,6 @@ namespace Nz texDimensions.y = textureData.height; break; - case FramePassAttachmentSize::SwapchainFactor: - texDimensions = swapchainSize; - texDimensions.x *= textureData.width; - texDimensions.y *= textureData.height; - texDimensions /= 100'000; - break; - case FramePassAttachmentSize::ViewerTargetFactor: texDimensions = viewerTargetSizes[textureData.viewerIndex]; texDimensions.x *= textureData.width; @@ -256,9 +246,7 @@ namespace Nz passData.forceCommandBufferRegeneration = true; } - m_width = swapchainSize.x; - m_height = swapchainSize.y; - + m_viewerSizes.assign(viewerTargetSizes.begin(), viewerTargetSizes.end()); return true; } }