From be16da37d7c55fce5bfc7885f89a4047a336f4e2 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 28 Jan 2020 13:38:27 +0100 Subject: [PATCH] [d3d11] Introduce COM interface to set and get API version Allows us to identify DirectX 10 applications correctly. --- src/d3d10/d3d10_main.cpp | 6 +++++- src/d3d11/d3d11_device.cpp | 41 ++++++++++++++++++++++++++++++++++++++ src/d3d11/d3d11_device.h | 31 ++++++++++++++++++++++++++++ src/dxgi/dxgi_interfaces.h | 17 ++++++++++++++++ src/util/com/com_guid.cpp | 1 + 5 files changed, 95 insertions(+), 1 deletion(-) diff --git a/src/d3d10/d3d10_main.cpp b/src/d3d10/d3d10_main.cpp index 447cc6a2..2f9c8317 100644 --- a/src/d3d10/d3d10_main.cpp +++ b/src/d3d10/d3d10_main.cpp @@ -46,7 +46,11 @@ extern "C" { Com multithread; d3d11Device->QueryInterface(__uuidof(ID3D10Multithread), reinterpret_cast(&multithread)); multithread->SetMultithreadProtected(!(Flags & D3D10_CREATE_DEVICE_SINGLETHREADED)); - + + Com dxvkDevice; + d3d11Device->QueryInterface(__uuidof(IDXGIDXVKDevice), reinterpret_cast(&dxvkDevice)); + dxvkDevice->SetAPIVersion(10); + if (FAILED(d3d11Device->QueryInterface( __uuidof(ID3D10Device), reinterpret_cast(ppDevice)))) return E_FAIL; diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 5d6974f3..6a231902 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -2449,8 +2449,43 @@ namespace dxvk { } + + DXGIDXVKDevice::DXGIDXVKDevice(D3D11DXGIDevice* pContainer) + : m_container(pContainer), m_apiVersion(11) { + + } + + ULONG STDMETHODCALLTYPE DXGIDXVKDevice::AddRef() { + return m_container->AddRef(); + } + + ULONG STDMETHODCALLTYPE DXGIDXVKDevice::Release() { + return m_container->Release(); + } + + + HRESULT STDMETHODCALLTYPE DXGIDXVKDevice::QueryInterface( + REFIID riid, + void** ppvObject) { + return m_container->QueryInterface(riid, ppvObject); + } + + + void STDMETHODCALLTYPE DXGIDXVKDevice::SetAPIVersion( + UINT Version) { + m_apiVersion = Version; + } + + + UINT STDMETHODCALLTYPE DXGIDXVKDevice::GetAPIVersion() { + return m_apiVersion; + } + + + + D3D11DXGIDevice::D3D11DXGIDevice( IDXGIAdapter* pAdapter, const Rc& pDxvkInstance, @@ -2464,6 +2499,7 @@ namespace dxvk { m_d3d11Device (this, FeatureLevel, FeatureFlags), m_d3d11DeviceExt(this, &m_d3d11Device), m_d3d11Interop (this, &m_d3d11Device), + m_metaDevice (this), m_wineFactory (this, &m_d3d11Device) { } @@ -2517,6 +2553,11 @@ namespace dxvk { return S_OK; } + if (riid == __uuidof(IDXGIDXVKDevice)) { + *ppvObject = ref(&m_metaDevice); + return S_OK; + } + if (riid == __uuidof(IWineDXGISwapChainFactory)) { *ppvObject = ref(&m_wineFactory); return S_OK; diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index 3d325291..6d69e636 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -552,6 +552,36 @@ namespace dxvk { }; + /** + * \brief D3D11 device metadata shenanigans + */ + class DXGIDXVKDevice : public IDXGIDXVKDevice { + + public: + + DXGIDXVKDevice(D3D11DXGIDevice* pContainer); + + ULONG STDMETHODCALLTYPE AddRef(); + + ULONG STDMETHODCALLTYPE Release(); + + HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void** ppvObject); + + void STDMETHODCALLTYPE SetAPIVersion( + UINT Version); + + UINT STDMETHODCALLTYPE GetAPIVersion(); + + private: + + D3D11DXGIDevice* m_container; + UINT m_apiVersion; + + }; + + /** * \brief D3D11 device container * @@ -645,6 +675,7 @@ namespace dxvk { D3D11Device m_d3d11Device; D3D11DeviceExt m_d3d11DeviceExt; D3D11VkInterop m_d3d11Interop; + DXGIDXVKDevice m_metaDevice; WineDXGISwapChainFactory m_wineFactory; diff --git a/src/dxgi/dxgi_interfaces.h b/src/dxgi/dxgi_interfaces.h index f890f921..06c96957 100644 --- a/src/dxgi/dxgi_interfaces.h +++ b/src/dxgi/dxgi_interfaces.h @@ -98,6 +98,21 @@ IDXGIDXVKAdapter : public IDXGIAdapter3 { }; +/** + * \brief Private DXGI device interface + */ +MIDL_INTERFACE("92a5d77b-b6e1-420a-b260-fdd701272827") +IDXGIDXVKDevice : public IUnknown { + static const GUID guid; + + virtual void STDMETHODCALLTYPE SetAPIVersion( + UINT Version) = 0; + + virtual UINT STDMETHODCALLTYPE GetAPIVersion() = 0; + +}; + + /** * \brief Private DXGI monitor info interface * @@ -329,6 +344,7 @@ IWineDXGISwapChainFactory : public IUnknown { #ifdef _MSC_VER struct __declspec(uuid("907bf281-ea3c-43b4-a8e4-9f231107b4ff")) IDXGIDXVKAdapter; +struct __declspec(uuid("92a5d77b-b6e1-420a-b260-fdd701272827")) IDXGIDXVKDevice; struct __declspec(uuid("c06a236f-5be3-448a-8943-89c611c0c2c1")) IDXGIVkMonitorInfo; struct __declspec(uuid("3a6d8f2c-b0e8-4ab4-b4dc-4fd24891bfa5")) IDXGIVkInteropAdapter; struct __declspec(uuid("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")) IDXGIVkInteropDevice; @@ -337,6 +353,7 @@ struct __declspec(uuid("104001a6-7f36-4957-b932-86ade9567d91")) IDXGIVkSwapChain struct __declspec(uuid("53cb4ff0-c25a-4164-a891-0e83db0a7aac")) IWineDXGISwapChainFactory; #else DXVK_DEFINE_GUID(IDXGIDXVKAdapter); +DXVK_DEFINE_GUID(IDXGIDXVKDevice); DXVK_DEFINE_GUID(IDXGIVkMonitorInfo); DXVK_DEFINE_GUID(IDXGIVkInteropAdapter); DXVK_DEFINE_GUID(IDXGIVkInteropDevice); diff --git a/src/util/com/com_guid.cpp b/src/util/com/com_guid.cpp index bc6a3765..0410c4ad 100644 --- a/src/util/com/com_guid.cpp +++ b/src/util/com/com_guid.cpp @@ -7,6 +7,7 @@ const GUID ID3D11VkExtDevice::guid = {0x8a6e3c42,0xf74c,0x45b7,{0x82,0x65,0xa2,0x31,0xb6,0x77,0xca,0x17}}; const GUID ID3D11VkExtContext::guid = {0xfd0bca13,0x5cb6,0x4c3a,{0x98,0x7e,0x47,0x50,0xde,0x2c,0xa7,0x91}}; const GUID IDXGIDXVKAdapter::guid = {0x907bf281,0xea3c,0x43b4,{0xa8,0xe4,0x9f,0x23,0x11,0x07,0xb4,0xff}}; +const GUID IDXGIDXVKDevice::guid = {0x92a5d77b,0xb6e1,0x420a,{0xb2,0x60,0xfd,0xf7,0x01,0x27,0x28,0x27}}; const GUID IDXGIVkMonitorInfo::guid = {0xc06a236f,0x5be3,0x448a,{0x89,0x43,0x89,0xc6,0x11,0xc0,0xc2,0xc1}}; const GUID IDXGIVkInteropAdapter::guid = {0x3a6d8f2c,0xb0e8,0x4ab4,{0xb4,0xdc,0x4f,0xd2,0x48,0x91,0xbf,0xa5}}; const GUID IDXGIVkInteropDevice::guid = {0xe2ef5fa5,0xdc21,0x4af7,{0x90,0xc4,0xf6,0x7e,0xf6,0xa0,0x93,0x23}};