From f5dd030074937eb39afebf25c737935b0fd03063 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 26 Nov 2017 16:12:11 +0100 Subject: [PATCH] [dxgi] Implemented IDXGIFactory1 and IDXGIAdapter1 extensions --- src/dxgi/dxgi_adapter.cpp | 21 +++++++++++++++++++++ src/dxgi/dxgi_adapter.h | 3 +++ src/dxgi/dxgi_factory.cpp | 21 +++++++++++++++++++++ src/dxgi/dxgi_factory.h | 8 +++++++- src/dxgi/dxgi_interfaces.h | 2 +- 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index ba2a5c860..2b7b61c79 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -27,6 +27,7 @@ namespace dxvk { COM_QUERY_IFACE(riid, ppvObject, IUnknown); COM_QUERY_IFACE(riid, ppvObject, IDXGIObject); COM_QUERY_IFACE(riid, ppvObject, IDXGIAdapter); + COM_QUERY_IFACE(riid, ppvObject, IDXGIAdapter1); COM_QUERY_IFACE(riid, ppvObject, IDXVKAdapter); Logger::warn("DxgiAdapter::QueryInterface: Unknown interface query"); @@ -71,6 +72,25 @@ namespace dxvk { HRESULT DxgiAdapter::GetDesc(DXGI_ADAPTER_DESC* pDesc) { + DXGI_ADAPTER_DESC1 desc1; + HRESULT hr = this->GetDesc1(&desc1); + + if (SUCCEEDED(hr)) { + pDesc->VendorId = desc1.VendorId; + pDesc->DeviceId = desc1.DeviceId; + pDesc->SubSysId = desc1.SubSysId; + pDesc->Revision = desc1.Revision; + pDesc->DedicatedVideoMemory = desc1.DedicatedVideoMemory; + pDesc->DedicatedSystemMemory = desc1.DedicatedSystemMemory; + pDesc->SharedSystemMemory = desc1.SharedSystemMemory; + pDesc->AdapterLuid = desc1.AdapterLuid; + } + + return hr; + } + + + HRESULT DxgiAdapter::GetDesc1(DXGI_ADAPTER_DESC1* pDesc) { if (pDesc == nullptr) return DXGI_ERROR_INVALID_CALL; @@ -100,6 +120,7 @@ namespace dxvk { pDesc->DedicatedSystemMemory = 0; pDesc->SharedSystemMemory = sharedMemory; pDesc->AdapterLuid = LUID { 0, 0 }; // TODO implement + pDesc->Flags = 0; return S_OK; } diff --git a/src/dxgi/dxgi_adapter.h b/src/dxgi/dxgi_adapter.h index cd33ccde3..d5904daf1 100644 --- a/src/dxgi/dxgi_adapter.h +++ b/src/dxgi/dxgi_adapter.h @@ -41,6 +41,9 @@ namespace dxvk { HRESULT GetDesc( DXGI_ADAPTER_DESC *pDesc) final; + HRESULT GetDesc1( + DXGI_ADAPTER_DESC1 *pDesc) final; + Rc GetDXVKAdapter() final; private: diff --git a/src/dxgi/dxgi_factory.cpp b/src/dxgi/dxgi_factory.cpp index 102409efc..77f6fff83 100644 --- a/src/dxgi/dxgi_factory.cpp +++ b/src/dxgi/dxgi_factory.cpp @@ -21,6 +21,7 @@ namespace dxvk { COM_QUERY_IFACE(riid, ppvObject, IUnknown); COM_QUERY_IFACE(riid, ppvObject, IDXGIObject); COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory); + COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory1); Logger::warn("DxgiFactory::QueryInterface: Unknown interface query"); return E_NOINTERFACE; @@ -66,6 +67,20 @@ namespace dxvk { if (ppAdapter == nullptr) return DXGI_ERROR_INVALID_CALL; + IDXGIAdapter1* handle = nullptr; + HRESULT hr = this->EnumAdapters1(Adapter, &handle); + if (SUCCEEDED(hr)) + *ppAdapter = handle; + return hr; + } + + + HRESULT DxgiFactory::EnumAdapters1( + UINT Adapter, + IDXGIAdapter1** ppAdapter) { + if (ppAdapter == nullptr) + return DXGI_ERROR_INVALID_CALL; + if (Adapter >= m_adapters.size()) return DXGI_ERROR_NOT_FOUND; @@ -90,4 +105,10 @@ namespace dxvk { return S_OK; } + + BOOL DxgiFactory::IsCurrent() { + Logger::warn("DxgiFactory::IsCurrent: Stub"); + return TRUE; + } + } diff --git a/src/dxgi/dxgi_factory.h b/src/dxgi/dxgi_factory.h index 7744469eb..f72920a71 100644 --- a/src/dxgi/dxgi_factory.h +++ b/src/dxgi/dxgi_factory.h @@ -8,7 +8,7 @@ namespace dxvk { - class DxgiFactory : public DxgiObject { + class DxgiFactory : public DxgiObject { public: @@ -36,6 +36,10 @@ namespace dxvk { UINT Adapter, IDXGIAdapter** ppAdapter) final; + HRESULT EnumAdapters1( + UINT Adapter, + IDXGIAdapter1** ppAdapter) final; + HRESULT GetWindowAssociation( HWND *pWindowHandle) final; @@ -43,6 +47,8 @@ namespace dxvk { HWND WindowHandle, UINT Flags) final; + BOOL IsCurrent(); + private: Rc m_instance; diff --git a/src/dxgi/dxgi_interfaces.h b/src/dxgi/dxgi_interfaces.h index 3e8d9291f..cb1800c0a 100644 --- a/src/dxgi/dxgi_interfaces.h +++ b/src/dxgi/dxgi_interfaces.h @@ -16,7 +16,7 @@ namespace dxvk { * this interface. */ MIDL_INTERFACE("907bf281-ea3c-43b4-a8e4-9f231107b4ff") -IDXVKAdapter : public IDXGIAdapter { +IDXVKAdapter : public IDXGIAdapter1 { static const GUID guid; virtual dxvk::Rc GetDXVKAdapter() = 0;