void D3D12Fullscreen::OnSizeChanged(UINT width, UINT height, bool minimized) { // Determine if the swap buffers and other resources need to be resized or not. if ((width != m_width || height != m_height) && !minimized) { // Flush all current GPU commands. WaitForGpu(); // Release the resources holding references to the swap chain (requirement of // IDXGISwapChain::ResizeBuffers) and reset the frame fence values to the // current fence value. for (UINT n = 0; n < FrameCount; n++) { m_renderTargets[n].Reset(); m_fenceValues[n] = m_fenceValues[m_frameIndex]; } // Resize the swap chain to the desired dimensions. DXGI_SWAP_CHAIN_DESC desc = {}; m_swapChain->GetDesc(&desc); ThrowIfFailed(m_swapChain->ResizeBuffers(FrameCount, width, height, desc.BufferDesc.Format, desc.Flags)); // Reset the frame index to the current back buffer index. m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); // Update the width, height, and aspect ratio member variables. UpdateForSizeChange(width, height); LoadSizeDependentResources(); } m_windowVisible = !minimized; }
void D3D12HDR::OnSizeChanged(UINT width, UINT height, bool minimized) { // Update the width, height, and aspect ratio member variables. UpdateForSizeChange(width, height); // Update the size of swapchain buffers. UpdateSwapChainBuffer(width, height, GetBackBufferFormat()); m_windowVisible = !minimized; }
void D3D12HDR::UpdateSwapChainBuffer(UINT width, UINT height, DXGI_FORMAT format) { if (!m_swapChain) { return; } // Flush all current GPU commands. WaitForGpu(); // Release the resources holding references to the swap chain (requirement of // IDXGISwapChain::ResizeBuffers) and reset the frame fence values to the // current fence value. for (UINT n = 0; n < FrameCount; n++) { m_renderTargets[n].Reset(); m_fenceValues[n] = m_fenceValues[m_frameIndex]; } if (m_enableUI) { m_uiLayer->ReleaseResources(); } // Resize the swap chain to the desired dimensions. DXGI_SWAP_CHAIN_DESC1 desc = {}; m_swapChain->GetDesc1(&desc); ThrowIfFailed(m_swapChain->ResizeBuffers(FrameCount, width, height, format, desc.Flags)); EnsureSwapChainColorSpace(m_currentSwapChainBitDepth, m_enableST2084); // Reset the frame index to the current back buffer index. m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); // Update the width, height, and aspect ratio member variables. UpdateForSizeChange(width, height); LoadSizeDependentResources(); }