Graphics/FrameGraph: Remove SwapchainFactors attachment size and fully handle multiple viewer sizes

This commit is contained in:
Lynix 2023-11-21 23:02:07 +01:00
parent dca8555d34
commit d7d5c09428
4 changed files with 10 additions and 22 deletions

View File

@ -705,7 +705,7 @@ int main(int argc, char* argv[])
godRaysTexture = graph.AddAttachment({ godRaysTexture = graph.AddAttachment({
.name = "God rays texture", .name = "God rays texture",
.format = Nz::PixelFormat::RGBA16F, .format = Nz::PixelFormat::RGBA16F,
.size = Nz::FramePassAttachmentSize::SwapchainFactor, .size = Nz::FramePassAttachmentSize::ViewerTargetFactor,
.width = 50'000, .width = 50'000,
.height = 50'000 .height = 50'000
}); });
@ -716,7 +716,7 @@ int main(int argc, char* argv[])
bloomBrightOutput = graph.AddAttachment({ bloomBrightOutput = graph.AddAttachment({
.name = "Bloom bright output", .name = "Bloom bright output",
.format = Nz::PixelFormat::RGBA16F, .format = Nz::PixelFormat::RGBA16F,
.size = Nz::FramePassAttachmentSize::SwapchainFactor, .size = Nz::FramePassAttachmentSize::ViewerTargetFactor,
.width = bloomSize, .width = bloomSize,
.height = bloomSize .height = bloomSize
}); });
@ -726,7 +726,7 @@ int main(int argc, char* argv[])
bloomTextures[i * 2 + 0] = graph.AddAttachment({ bloomTextures[i * 2 + 0] = graph.AddAttachment({
.name = "Bloom texture #" + std::to_string(i), .name = "Bloom texture #" + std::to_string(i),
.format = Nz::PixelFormat::RGBA16F, .format = Nz::PixelFormat::RGBA16F,
.size = Nz::FramePassAttachmentSize::SwapchainFactor, .size = Nz::FramePassAttachmentSize::ViewerTargetFactor,
.width = bloomSize, .width = bloomSize,
.height = bloomSize .height = bloomSize
}); });
@ -735,7 +735,7 @@ int main(int argc, char* argv[])
bloomTextures[i * 2 + 1] = graph.AddAttachment({ bloomTextures[i * 2 + 1] = graph.AddAttachment({
.name = "Bloom texture #" + std::to_string(i), .name = "Bloom texture #" + std::to_string(i),
.format = Nz::PixelFormat::RGBA16F, .format = Nz::PixelFormat::RGBA16F,
.size = Nz::FramePassAttachmentSize::SwapchainFactor, .size = Nz::FramePassAttachmentSize::ViewerTargetFactor,
.width = bloomSize, .width = bloomSize,
.height = bloomSize .height = bloomSize
}); });
@ -746,7 +746,7 @@ int main(int argc, char* argv[])
toneMappingOutput = graph.AddAttachment({ toneMappingOutput = graph.AddAttachment({
.name = "Tone mapping", .name = "Tone mapping",
.format = Nz::PixelFormat::RGBA8, .format = Nz::PixelFormat::RGBA8,
.size = Nz::FramePassAttachmentSize::SwapchainFactor, .size = Nz::FramePassAttachmentSize::ViewerTargetFactor,
.width = 100'000, .width = 100'000,
.height = 100'000 .height = 100'000
}); });
@ -1526,7 +1526,7 @@ int main(int argc, char* argv[])
clearValues[1].depth = 1.f; clearValues[1].depth = 1.f;
clearValues[1].stencil = 0; 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()); builder.BeginDebugRegion("Main window rendering", Nz::Color::Green());
{ {

View File

@ -91,6 +91,7 @@ namespace Nz
std::shared_ptr<CommandPool> m_commandPool; std::shared_ptr<CommandPool> m_commandPool;
std::vector<PassData> m_passes; std::vector<PassData> m_passes;
std::vector<TextureData> m_textures; std::vector<TextureData> m_textures;
std::vector<Vector2ui> m_viewerSizes;
AttachmentIdToTextureId m_attachmentToTextureMapping; AttachmentIdToTextureId m_attachmentToTextureMapping;
PassIdToPhysicalPassIndex m_passIdToPhysicalPassMapping; PassIdToPhysicalPassIndex m_passIdToPhysicalPassMapping;
unsigned int m_height; unsigned int m_height;

View File

@ -18,7 +18,6 @@ namespace Nz
enum class FramePassAttachmentSize enum class FramePassAttachmentSize
{ {
Fixed, Fixed,
SwapchainFactor,
ViewerTargetFactor, ViewerTargetFactor,
}; };

View File

@ -14,9 +14,7 @@ namespace Nz
m_passes(std::move(passes)), m_passes(std::move(passes)),
m_textures(std::move(textures)), m_textures(std::move(textures)),
m_attachmentToTextureMapping(std::move(attachmentIdToTextureMapping)), m_attachmentToTextureMapping(std::move(attachmentIdToTextureMapping)),
m_passIdToPhysicalPassMapping(std::move(passIdToPhysicalPassMapping)), m_passIdToPhysicalPassMapping(std::move(passIdToPhysicalPassMapping))
m_height(0),
m_width(0)
{ {
const std::shared_ptr<RenderDevice>& renderDevice = Graphics::Instance()->GetRenderDevice(); const std::shared_ptr<RenderDevice>& renderDevice = Graphics::Instance()->GetRenderDevice();
m_commandPool = renderDevice->InstantiateCommandPool(QueueType::Graphics); m_commandPool = renderDevice->InstantiateCommandPool(QueueType::Graphics);
@ -131,8 +129,7 @@ namespace Nz
bool BakedFrameGraph::Resize(RenderFrame& renderFrame, std::span<Vector2ui> viewerTargetSizes) bool BakedFrameGraph::Resize(RenderFrame& renderFrame, std::span<Vector2ui> viewerTargetSizes)
{ {
Vector2ui swapchainSize = renderFrame.GetSize(); if (std::equal(m_viewerSizes.begin(), m_viewerSizes.end(), viewerTargetSizes.begin(), viewerTargetSizes.end()))
if (m_width == swapchainSize.x && m_height == swapchainSize.y)
return false; return false;
const std::shared_ptr<RenderDevice>& renderDevice = Graphics::Instance()->GetRenderDevice(); const std::shared_ptr<RenderDevice>& renderDevice = Graphics::Instance()->GetRenderDevice();
@ -147,13 +144,6 @@ namespace Nz
texDimensions.y = textureData.height; texDimensions.y = textureData.height;
break; break;
case FramePassAttachmentSize::SwapchainFactor:
texDimensions = swapchainSize;
texDimensions.x *= textureData.width;
texDimensions.y *= textureData.height;
texDimensions /= 100'000;
break;
case FramePassAttachmentSize::ViewerTargetFactor: case FramePassAttachmentSize::ViewerTargetFactor:
texDimensions = viewerTargetSizes[textureData.viewerIndex]; texDimensions = viewerTargetSizes[textureData.viewerIndex];
texDimensions.x *= textureData.width; texDimensions.x *= textureData.width;
@ -256,9 +246,7 @@ namespace Nz
passData.forceCommandBufferRegeneration = true; passData.forceCommandBufferRegeneration = true;
} }
m_width = swapchainSize.x; m_viewerSizes.assign(viewerTargetSizes.begin(), viewerTargetSizes.end());
m_height = swapchainSize.y;
return true; return true;
} }
} }