From 171251bc834a1bc26f9eeee3d0fddd97bc3a6ed8 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 11 Oct 2018 10:58:26 +0200 Subject: [PATCH] [dxgi] Implement IDXGIFactory4 Do not support WARP adapters for the moment. --- src/dxgi/dxgi_factory.cpp | 39 ++++++++++++++++++++++++++++++++++++++- src/dxgi/dxgi_factory.h | 11 ++++++++++- src/dxgi/dxgi_output.cpp | 13 ++++++++++++- src/dxgi/dxgi_output.h | 8 +++++++- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/dxgi/dxgi_factory.cpp b/src/dxgi/dxgi_factory.cpp index 77abbdaf4..d522d3f1f 100644 --- a/src/dxgi/dxgi_factory.cpp +++ b/src/dxgi/dxgi_factory.cpp @@ -25,7 +25,8 @@ namespace dxvk { || riid == __uuidof(IDXGIFactory) || riid == __uuidof(IDXGIFactory1) || riid == __uuidof(IDXGIFactory2) - || riid == __uuidof(IDXGIFactory3)) { + || riid == __uuidof(IDXGIFactory3) + || riid == __uuidof(IDXGIFactory4)) { *ppvObject = ref(this); return S_OK; } @@ -195,6 +196,42 @@ namespace dxvk { } + HRESULT STDMETHODCALLTYPE DxgiFactory::EnumAdapterByLuid( + LUID AdapterLuid, + REFIID riid, + void** ppvAdapter) { + InitReturnPtr(ppvAdapter); + uint32_t adapterId = 0; + + while (true) { + Com adapter; + HRESULT hr = EnumAdapters(adapterId++, &adapter); + + if (FAILED(hr)) + return hr; + + DXGI_ADAPTER_DESC desc; + adapter->GetDesc(&desc); + + if (!std::memcmp(&AdapterLuid, &desc.AdapterLuid, sizeof(LUID))) + return adapter->QueryInterface(riid, ppvAdapter); + } + + // This should be unreachable + return DXGI_ERROR_NOT_FOUND; + } + + + HRESULT STDMETHODCALLTYPE DxgiFactory::EnumWarpAdapter( + REFIID riid, + void** ppvAdapter) { + InitReturnPtr(ppvAdapter); + + Logger::err("DxgiFactory::EnumWarpAdapter: Not implemented"); + return E_NOTIMPL; + } + + HRESULT STDMETHODCALLTYPE DxgiFactory::GetWindowAssociation(HWND *pWindowHandle) { if (pWindowHandle == nullptr) return DXGI_ERROR_INVALID_CALL; diff --git a/src/dxgi/dxgi_factory.h b/src/dxgi/dxgi_factory.h index 958061985..bb2452301 100644 --- a/src/dxgi/dxgi_factory.h +++ b/src/dxgi/dxgi_factory.h @@ -9,7 +9,7 @@ namespace dxvk { - class DxgiFactory : public DxgiObject { + class DxgiFactory : public DxgiObject { public: @@ -64,6 +64,15 @@ namespace dxvk { UINT Adapter, IDXGIAdapter1** ppAdapter) final; + HRESULT STDMETHODCALLTYPE EnumAdapterByLuid( + LUID AdapterLuid, + REFIID riid, + void** ppvAdapter) final; + + HRESULT STDMETHODCALLTYPE EnumWarpAdapter( + REFIID riid, + void** ppvAdapter) final; + HRESULT STDMETHODCALLTYPE GetWindowAssociation( HWND* pWindowHandle) final; diff --git a/src/dxgi/dxgi_output.cpp b/src/dxgi/dxgi_output.cpp index 430616f57..f89082172 100644 --- a/src/dxgi/dxgi_output.cpp +++ b/src/dxgi/dxgi_output.cpp @@ -50,7 +50,8 @@ namespace dxvk { || riid == __uuidof(IDXGIOutput) || riid == __uuidof(IDXGIOutput1) || riid == __uuidof(IDXGIOutput2) - || riid == __uuidof(IDXGIOutput3)) { + || riid == __uuidof(IDXGIOutput3) + || riid == __uuidof(IDXGIOutput4)) { *ppvObject = ref(this); return S_OK; } @@ -444,6 +445,16 @@ namespace dxvk { } + HRESULT STDMETHODCALLTYPE DxgiOutput::CheckOverlayColorSpaceSupport( + DXGI_FORMAT Format, + DXGI_COLOR_SPACE_TYPE ColorSpace, + IUnknown* pConcernedDevice, + UINT* pFlags) { + Logger::warn("DxgiOutput: CheckOverlayColorSpaceSupport: Stub"); + return DXGI_ERROR_UNSUPPORTED; + } + + HRESULT DxgiOutput::GetDisplayMode(DXGI_MODE_DESC* pMode, DWORD ModeNum) { ::MONITORINFOEXW monInfo; monInfo.cbSize = sizeof(monInfo); diff --git a/src/dxgi/dxgi_output.h b/src/dxgi/dxgi_output.h index 7b1893398..bb9d5d977 100644 --- a/src/dxgi/dxgi_output.h +++ b/src/dxgi/dxgi_output.h @@ -34,7 +34,7 @@ namespace dxvk { }; - class DxgiOutput : public DxgiObject { + class DxgiOutput : public DxgiObject { public: @@ -117,6 +117,12 @@ namespace dxvk { IUnknown* pConcernedDevice, UINT* pFlags) final; + HRESULT STDMETHODCALLTYPE CheckOverlayColorSpaceSupport( + DXGI_FORMAT Format, + DXGI_COLOR_SPACE_TYPE ColorSpace, + IUnknown* pConcernedDevice, + UINT* pFlags) final; + HRESULT GetDisplayMode( DXGI_MODE_DESC* pMode, DWORD ModeNum);