Skip to content

Commit 377cb88

Browse files
Bugfix for MultiDeviceSwapChain which did not properly recreate images (o3de#17648)
Signed-off-by: Martin Winter <[email protected]> Co-authored-by: Martin Winter <[email protected]>
1 parent 534e953 commit 377cb88

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

Gems/Atom/RHI/Code/Include/Atom/RHI/SwapChain.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ namespace AZ::RHI
7575

7676
//! Recreate the swapchain if it becomes invalid during presenting. This should happen at the end of the frame
7777
//! due to images being used as attachments in the frame graph.
78-
virtual void ProcessRecreation() {};
78+
virtual bool ProcessRecreation(){ return false; };
79+
7980
protected:
8081
SwapChain();
8182

Gems/Atom/RHI/Code/Source/RHI/MultiDeviceSwapChain.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,18 @@ namespace AZ::RHI
238238

239239
void MultiDeviceSwapChain::ProcessRecreation()
240240
{
241-
IterateObjects<SwapChain>([]([[maybe_unused]] auto deviceIndex, auto deviceSwapChain)
241+
auto recreated{ false };
242+
IterateObjects<SwapChain>(
243+
[&recreated]([[maybe_unused]] auto deviceIndex, auto deviceSwapChain)
244+
{
245+
recreated = deviceSwapChain->ProcessRecreation();
246+
});
247+
248+
if (recreated)
242249
{
243-
deviceSwapChain->ProcessRecreation();
244-
});
250+
ShutdownImages();
251+
InitImages();
252+
}
245253
}
246254

247255
uint32_t MultiDeviceSwapChain::GetImageCount() const

Gems/Atom/RHI/Vulkan/Code/Source/RHI/SwapChain.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace AZ
7070
m_swapChainBarrier.m_isValid = true;
7171
}
7272

73-
void SwapChain::ProcessRecreation()
73+
bool SwapChain::ProcessRecreation()
7474
{
7575
if (m_pendingRecreation)
7676
{
@@ -82,7 +82,9 @@ namespace AZ
8282
InitImages();
8383

8484
m_pendingRecreation = false;
85+
return true;
8586
}
87+
return false;
8688
}
8789

8890
void SwapChain::SetVerticalSyncIntervalInternal(uint32_t previousVsyncInterval)

Gems/Atom/RHI/Vulkan/Code/Source/RHI/SwapChain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace AZ
5151

5252
void QueueBarrier(const VkPipelineStageFlags src, const VkPipelineStageFlags dst, const VkImageMemoryBarrier& imageBarrier);
5353

54-
void ProcessRecreation() override;
54+
bool ProcessRecreation() override;
5555
private:
5656
SwapChain() = default;
5757

0 commit comments

Comments
 (0)