From 1f7da328c37f54240ae0085fa5893ceef41d402c Mon Sep 17 00:00:00 2001 From: James Stanard Date: Fri, 2 Sep 2022 10:58:01 -0700 Subject: [PATCH] Fixed two samples that crashed when minimizing the window --- Samples/Desktop/D3D12HDR/src/D3D12HDR.cpp | 12 ++++++++---- .../src/D3D12SM6WaveIntrinsics.cpp | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Samples/Desktop/D3D12HDR/src/D3D12HDR.cpp b/Samples/Desktop/D3D12HDR/src/D3D12HDR.cpp index a6b344ce3..ce1643afb 100644 --- a/Samples/Desktop/D3D12HDR/src/D3D12HDR.cpp +++ b/Samples/Desktop/D3D12HDR/src/D3D12HDR.cpp @@ -750,11 +750,15 @@ void D3D12HDR::OnWindowMoved(int xPos, int yPos) void D3D12HDR::OnSizeChanged(UINT width, UINT height, bool minimized) { - // Update the width, height, and aspect ratio member variables. - UpdateForSizeChange(width, height); + // Don't tear down or resize any resources if the window is just temporarily minimized + if (!minimized) + { + // Update the width, height, and aspect ratio member variables. + UpdateForSizeChange(width, height); - // Update the size of swapchain buffers. - UpdateSwapChainBuffer(width, height, GetBackBufferFormat()); + // Update the size of swapchain buffers. + UpdateSwapChainBuffer(width, height, GetBackBufferFormat()); + } m_windowVisible = !minimized; } diff --git a/Samples/Desktop/D3D12SM6WaveIntrinsics/src/D3D12SM6WaveIntrinsics.cpp b/Samples/Desktop/D3D12SM6WaveIntrinsics/src/D3D12SM6WaveIntrinsics.cpp index a03a12a29..bb1d48d58 100644 --- a/Samples/Desktop/D3D12SM6WaveIntrinsics/src/D3D12SM6WaveIntrinsics.cpp +++ b/Samples/Desktop/D3D12SM6WaveIntrinsics/src/D3D12SM6WaveIntrinsics.cpp @@ -809,7 +809,10 @@ void D3D12SM6WaveIntrinsics::OnKeyDown(UINT8 key) void D3D12SM6WaveIntrinsics::OnSizeChanged(UINT width, UINT height, bool minimized) { - UNREFERENCED_PARAMETER(minimized); + // Don't tear down or resize any resources if the window is just temporarily minimized + if (minimized) + return; + UpdateForSizeChange(width, height); if (!m_swapChain)