diff --git a/src/d3d9/d3d9_interface.cpp b/src/d3d9/d3d9_interface.cpp index e78a7e32..10113e57 100644 --- a/src/d3d9/d3d9_interface.cpp +++ b/src/d3d9/d3d9_interface.cpp @@ -4,12 +4,16 @@ #include "d3d9_caps.h" #include "d3d9_device.h" +#include "../util/util_singleton.h" + #include namespace dxvk { + Singleton g_dxvkInstance; + D3D9InterfaceEx::D3D9InterfaceEx(bool bExtended) - : m_instance ( new DxvkInstance() ) + : m_instance ( g_dxvkInstance.acquire() ) , m_extended ( bExtended ) , m_d3d9Options ( nullptr, m_instance->config() ) , m_d3d9Interop ( this ) { @@ -64,6 +68,11 @@ namespace dxvk { } + D3D9InterfaceEx::~D3D9InterfaceEx() { + g_dxvkInstance.release(); + } + + HRESULT STDMETHODCALLTYPE D3D9InterfaceEx::QueryInterface(REFIID riid, void** ppvObject) { if (ppvObject == nullptr) return E_POINTER; diff --git a/src/d3d9/d3d9_interface.h b/src/d3d9/d3d9_interface.h index 3fc9a43d..55c9be91 100644 --- a/src/d3d9/d3d9_interface.h +++ b/src/d3d9/d3d9_interface.h @@ -20,6 +20,8 @@ namespace dxvk { D3D9InterfaceEx(bool bExtended); + ~D3D9InterfaceEx(); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); HRESULT STDMETHODCALLTYPE RegisterSoftwareDevice(void* pInitializeFunction); diff --git a/src/dxgi/dxgi_factory.cpp b/src/dxgi/dxgi_factory.cpp index 63522186..80d43ddc 100644 --- a/src/dxgi/dxgi_factory.cpp +++ b/src/dxgi/dxgi_factory.cpp @@ -3,8 +3,12 @@ #include "dxgi_swapchain.h" #include "dxgi_swapchain_dispatcher.h" +#include "../util/util_singleton.h" + namespace dxvk { + Singleton g_dxvkInstance; + DxgiVkFactory::DxgiVkFactory(DxgiFactory* pFactory) : m_factory(pFactory) { @@ -44,7 +48,7 @@ namespace dxvk { DxgiFactory::DxgiFactory(UINT Flags) - : m_instance (new DxvkInstance()), + : m_instance (g_dxvkInstance.acquire()), m_interop (this), m_options (m_instance->config()), m_monitorInfo (this, m_options), @@ -55,7 +59,7 @@ namespace dxvk { DxgiFactory::~DxgiFactory() { - + g_dxvkInstance.release(); }