mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 13:08:50 +01:00
[dxgi,d3d9] Use global singleton for DXVK instances
No reason to have multiple of these around, and instance creation is fairly expensive.
This commit is contained in:
parent
d4143429c4
commit
61d72eebc1
@ -4,12 +4,16 @@
|
||||
#include "d3d9_caps.h"
|
||||
#include "d3d9_device.h"
|
||||
|
||||
#include "../util/util_singleton.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
Singleton<DxvkInstance> 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;
|
||||
|
@ -20,6 +20,8 @@ namespace dxvk {
|
||||
|
||||
D3D9InterfaceEx(bool bExtended);
|
||||
|
||||
~D3D9InterfaceEx();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RegisterSoftwareDevice(void* pInitializeFunction);
|
||||
|
@ -3,8 +3,12 @@
|
||||
#include "dxgi_swapchain.h"
|
||||
#include "dxgi_swapchain_dispatcher.h"
|
||||
|
||||
#include "../util/util_singleton.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
Singleton<DxvkInstance> 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();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user