From d844ddfdfa41872e77516746cb1e8cd2dfacb669 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 24 May 2018 12:31:21 +0200 Subject: [PATCH] [dxgi] Add option for deferred surface creation Deferred surface creation is required for Frostpunk due to conflicts with the D3D9 swap chain created by the game before it presents the first frame to the DXGI swap chain, but breaks NieR:Automata due to threading issues. --- src/dxgi/dxgi_presenter.cpp | 7 +++++++ src/dxgi/dxgi_presenter.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dxgi/dxgi_presenter.cpp b/src/dxgi/dxgi_presenter.cpp index 431cca37..f041ab6a 100644 --- a/src/dxgi/dxgi_presenter.cpp +++ b/src/dxgi/dxgi_presenter.cpp @@ -14,6 +14,13 @@ namespace dxvk { m_device (device), m_context (device->createContext()) { + // Some games don't work with deferred surface creation, + // so we should default to initializing it immediately. + DxgiOptions dxgiOptions = getDxgiAppOptions(env::getExeName()); + + if (!dxgiOptions.test(DxgiOption::DeferSurfaceCreation)) + m_surface = CreateSurface(); + // Reset options for the swap chain itself. We will // create a swap chain object before presentation. m_options.preferredSurfaceFormat = { VK_FORMAT_UNDEFINED, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR }; diff --git a/src/dxgi/dxgi_presenter.h b/src/dxgi/dxgi_presenter.h index 8709849c..a497ab34 100644 --- a/src/dxgi/dxgi_presenter.h +++ b/src/dxgi/dxgi_presenter.h @@ -8,7 +8,7 @@ #include "../spirv/spirv_module.h" -#include "dxgi_include.h" +#include "dxgi_options.h" namespace dxvk {