Reduce host swap chain latency

This commit is contained in:
2026-04-14 00:25:57 +08:00
parent d705cc839b
commit c3d443eb85
2 changed files with 19 additions and 1 deletions

View File

@@ -63,6 +63,8 @@ bool D3D12WindowSwapChainPresenter::CreateSwapChain(int width, int height) {
return false;
}
ConfigureFrameLatency();
if (!RecreateBackBufferViews()) {
m_lastError = "Failed to create swap chain back buffer views.";
return false;
@@ -73,6 +75,21 @@ bool D3D12WindowSwapChainPresenter::CreateSwapChain(int width, int height) {
return true;
}
void D3D12WindowSwapChainPresenter::ConfigureFrameLatency() {
D3D12SwapChain* d3d12SwapChain = GetD3D12SwapChain();
if (d3d12SwapChain == nullptr) {
return;
}
auto* nativeSwapChain =
static_cast<IDXGISwapChain3*>(d3d12SwapChain->GetNativeHandle());
if (nativeSwapChain == nullptr) {
return;
}
nativeSwapChain->SetMaximumFrameLatency(1u);
}
void D3D12WindowSwapChainPresenter::DestroySwapChain() {
ReleaseBackBufferViews();