From 9af842801c731c50f9797d1528d6873ec3672e5c Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 11 Oct 2018 09:56:30 +0200 Subject: [PATCH] [dxgi] Implement IDXGIFactory3 --- src/dxgi/dxgi_factory.cpp | 13 ++++++++++--- src/dxgi/dxgi_factory.h | 7 +++++-- src/dxgi/dxgi_main.cpp | 29 ++++++++++------------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/dxgi/dxgi_factory.cpp b/src/dxgi/dxgi_factory.cpp index c5ab7a8d..77abbdaf 100644 --- a/src/dxgi/dxgi_factory.cpp +++ b/src/dxgi/dxgi_factory.cpp @@ -3,9 +3,10 @@ namespace dxvk { - DxgiFactory::DxgiFactory() + DxgiFactory::DxgiFactory(UINT Flags) : m_instance(new DxvkInstance()), - m_options (m_instance->config()) { + m_options (m_instance->config()), + m_flags (Flags) { for (uint32_t i = 0; m_instance->enumAdapters(i) != nullptr; i++) m_instance->enumAdapters(i)->logAdapterInfo(); } @@ -23,7 +24,8 @@ namespace dxvk { || riid == __uuidof(IDXGIObject) || riid == __uuidof(IDXGIFactory) || riid == __uuidof(IDXGIFactory1) - || riid == __uuidof(IDXGIFactory2)) { + || riid == __uuidof(IDXGIFactory2) + || riid == __uuidof(IDXGIFactory3)) { *ppvObject = ref(this); return S_OK; } @@ -266,5 +268,10 @@ namespace dxvk { DWORD dwCookie) { Logger::err("DxgiFactory::UnregisterOcclusionStatus: Not implemented"); } + + + UINT STDMETHODCALLTYPE DxgiFactory::GetCreationFlags() { + return m_flags; + } } diff --git a/src/dxgi/dxgi_factory.h b/src/dxgi/dxgi_factory.h index 2a81ebdb..95806198 100644 --- a/src/dxgi/dxgi_factory.h +++ b/src/dxgi/dxgi_factory.h @@ -9,11 +9,11 @@ namespace dxvk { - class DxgiFactory : public DxgiObject { + class DxgiFactory : public DxgiObject { public: - DxgiFactory(); + DxgiFactory(UINT Flags); ~DxgiFactory(); HRESULT STDMETHODCALLTYPE QueryInterface( @@ -101,6 +101,8 @@ namespace dxvk { void STDMETHODCALLTYPE UnregisterOcclusionStatus( DWORD dwCookie) final; + UINT STDMETHODCALLTYPE GetCreationFlags() final; + const DxgiOptions* GetOptions() const { return &m_options; } @@ -109,6 +111,7 @@ namespace dxvk { Rc m_instance; DxgiOptions m_options; + UINT m_flags; HWND m_associatedWindow = nullptr; diff --git a/src/dxgi/dxgi_main.cpp b/src/dxgi/dxgi_main.cpp index dc724737..c1256657 100644 --- a/src/dxgi/dxgi_main.cpp +++ b/src/dxgi/dxgi_main.cpp @@ -5,37 +5,28 @@ namespace dxvk { Logger Logger::s_instance("dxgi.log"); - HRESULT createDxgiFactory(REFIID riid, void **ppFactory) { - if (riid != __uuidof(IDXGIFactory) - && riid != __uuidof(IDXGIFactory1) - && riid != __uuidof(IDXGIFactory2)) { - Logger::err("CreateDXGIFactory: Requested version of IDXGIFactory not supported"); - Logger::err(str::format(riid)); - *ppFactory = nullptr; - return E_NOINTERFACE; - } - - try { - *ppFactory = ref(new DxgiFactory()); - return S_OK; - } catch (const DxvkError& err) { - Logger::err(err.message()); + HRESULT createDxgiFactory(UINT Flags, REFIID riid, void **ppFactory) { + Com factory = new DxgiFactory(Flags); + HRESULT hr = factory->QueryInterface(riid, ppFactory); + + if (FAILED(hr)) return DXGI_ERROR_UNSUPPORTED; - } + + return S_OK; } } extern "C" { DLLEXPORT HRESULT __stdcall CreateDXGIFactory2(UINT Flags, REFIID riid, void **ppFactory) { dxvk::Logger::warn("CreateDXGIFactory2: Ignoring flags"); - return dxvk::createDxgiFactory(riid, ppFactory); + return dxvk::createDxgiFactory(Flags, riid, ppFactory); } DLLEXPORT HRESULT __stdcall CreateDXGIFactory1(REFIID riid, void **ppFactory) { - return dxvk::createDxgiFactory(riid, ppFactory); + return dxvk::createDxgiFactory(0, riid, ppFactory); } DLLEXPORT HRESULT __stdcall CreateDXGIFactory(REFIID riid, void **ppFactory) { - return dxvk::createDxgiFactory(riid, ppFactory); + return dxvk::createDxgiFactory(0, riid, ppFactory); } } \ No newline at end of file