From 46882779874a4dcd3f61123349ae4623ccf1e3aa Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 10 Aug 2022 17:02:13 +1000 Subject: [PATCH] SwapChain: Reduce buffer count from 3 to 2 --- src/common/vulkan/swap_chain.cpp | 2 +- src/frontend-common/d3d11_host_display.cpp | 5 ++++- src/frontend-common/d3d12_host_display.cpp | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/vulkan/swap_chain.cpp b/src/common/vulkan/swap_chain.cpp index d9cb6620d..251211bd8 100644 --- a/src/common/vulkan/swap_chain.cpp +++ b/src/common/vulkan/swap_chain.cpp @@ -595,7 +595,7 @@ bool SwapChain::CreateSwapChain() return false; // Select number of images in swap chain, we prefer one buffer in the background to work on - u32 image_count = std::max(surface_capabilities.minImageCount + 1u, 2u); + u32 image_count = std::max(surface_capabilities.minImageCount, 2u); // maxImageCount can be zero, in which case there isn't an upper limit on the number of buffers. if (surface_capabilities.maxImageCount > 0) diff --git a/src/frontend-common/d3d11_host_display.cpp b/src/frontend-common/d3d11_host_display.cpp index e1c77757b..efee1c3ea 100644 --- a/src/frontend-common/d3d11_host_display.cpp +++ b/src/frontend-common/d3d11_host_display.cpp @@ -326,6 +326,9 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view Log_WarningPrint("Failed to get parent adapter/device/factory"); return false; } + ComPtr dxgi_device1; + if (SUCCEEDED(dxgi_device.As(&dxgi_device1))) + dxgi_device1->SetMaximumFrameLatency(1); DXGI_ADAPTER_DESC adapter_desc; if (SUCCEEDED(dxgi_adapter->GetDesc(&adapter_desc))) @@ -412,7 +415,7 @@ bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) swap_chain_desc.BufferDesc.Height = height; swap_chain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swap_chain_desc.SampleDesc.Count = 1; - swap_chain_desc.BufferCount = 3; + swap_chain_desc.BufferCount = 2; swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swap_chain_desc.OutputWindow = window_hwnd; swap_chain_desc.Windowed = TRUE; diff --git a/src/frontend-common/d3d12_host_display.cpp b/src/frontend-common/d3d12_host_display.cpp index e16a0a904..669436375 100644 --- a/src/frontend-common/d3d12_host_display.cpp +++ b/src/frontend-common/d3d12_host_display.cpp @@ -313,7 +313,7 @@ bool D3D12HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) swap_chain_desc.BufferDesc.Height = height; swap_chain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swap_chain_desc.SampleDesc.Count = 1; - swap_chain_desc.BufferCount = 3; + swap_chain_desc.BufferCount = 2; swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swap_chain_desc.OutputWindow = window_hwnd; swap_chain_desc.Windowed = TRUE;