From ec704d8179104b752ad422ee3a68ac2f99ea381a Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Thu, 12 Jan 2023 06:35:59 +0000 Subject: [PATCH] Recreates Vulkan swapchain on window resize. Tested By: hyperion Differential Revision: https://code.wildfiregames.com/D4879 This was SVN commit r27422. --- source/renderer/backend/vulkan/Device.cpp | 9 ++++++--- source/renderer/backend/vulkan/SwapChain.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/renderer/backend/vulkan/Device.cpp b/source/renderer/backend/vulkan/Device.cpp index 8a74178933..b1751f1580 100644 --- a/source/renderer/backend/vulkan/Device.cpp +++ b/source/renderer/backend/vulkan/Device.cpp @@ -674,7 +674,6 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings) std::unique_ptr CDevice::CreateGraphicsPipelineState( const SGraphicsPipelineStateDesc& pipelineStateDesc) { - UNUSED2(pipelineStateDesc); return CGraphicsPipelineState::Create(this, pipelineStateDesc); } @@ -778,8 +777,12 @@ void CDevice::Present() void CDevice::OnWindowResize(const uint32_t width, const uint32_t height) { - UNUSED2(width); - UNUSED2(height); + if (!IsSwapChainValid() || + width != m_SwapChain->GetDepthTexture()->GetWidth() || + height != m_SwapChain->GetDepthTexture()->GetHeight()) + { + RecreateSwapChain(); + } } bool CDevice::IsTextureFormatSupported(const Format format) const diff --git a/source/renderer/backend/vulkan/SwapChain.h b/source/renderer/backend/vulkan/SwapChain.h index 175b9b4838..6d82ca6069 100644 --- a/source/renderer/backend/vulkan/SwapChain.h +++ b/source/renderer/backend/vulkan/SwapChain.h @@ -62,6 +62,8 @@ public: const AttachmentLoadOp depthStencilAttachmentLoadOp, const AttachmentStoreOp depthStencilAttachmentStoreOp); + CTexture* GetDepthTexture() { return m_DepthTexture.get(); } + private: friend class CDevice;