From a7de35564602520c45383c8080f7cbcf98895e41 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 23 Oct 2020 12:15:19 +0200 Subject: [PATCH] [dxgi] Implement IDXGIFactory6 --- src/dxgi/dxgi_factory.cpp | 27 +++++++++++++++++++++++++++ src/dxgi/dxgi_factory.h | 8 +++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/dxgi/dxgi_factory.cpp b/src/dxgi/dxgi_factory.cpp index 7d61f34ff..d7425e78c 100644 --- a/src/dxgi/dxgi_factory.cpp +++ b/src/dxgi/dxgi_factory.cpp @@ -223,6 +223,33 @@ namespace dxvk { } + HRESULT STDMETHODCALLTYPE DxgiFactory::EnumAdapterByGpuPreference( + UINT Adapter, + DXGI_GPU_PREFERENCE GpuPreference, + REFIID riid, + void** ppvAdapter) { + InitReturnPtr(ppvAdapter); + uint32_t adapterCount = m_instance->adapterCount(); + + if (Adapter >= adapterCount) + return DXGI_ERROR_NOT_FOUND; + + // We know that the backend lists dedicated GPUs before + // any integrated ones, so just list adapters in reverse + // order. We have no other way to estimate performance. + if (GpuPreference == DXGI_GPU_PREFERENCE_MINIMUM_POWER) + Adapter = adapterCount - Adapter - 1; + + Com adapter; + HRESULT hr = this->EnumAdapters(Adapter, &adapter); + + if (FAILED(hr)) + return hr; + + return adapter->QueryInterface(riid, ppvAdapter); + } + + HRESULT STDMETHODCALLTYPE DxgiFactory::EnumWarpAdapter( REFIID riid, void** ppvAdapter) { diff --git a/src/dxgi/dxgi_factory.h b/src/dxgi/dxgi_factory.h index d74c47471..32575d266 100644 --- a/src/dxgi/dxgi_factory.h +++ b/src/dxgi/dxgi_factory.h @@ -10,7 +10,7 @@ namespace dxvk { - class DxgiFactory : public DxgiObject { + class DxgiFactory : public DxgiObject { public: @@ -70,6 +70,12 @@ namespace dxvk { REFIID riid, void** ppvAdapter) final; + HRESULT STDMETHODCALLTYPE EnumAdapterByGpuPreference( + UINT Adapter, + DXGI_GPU_PREFERENCE GpuPreference, + REFIID riid, + void** ppvAdapter); + HRESULT STDMETHODCALLTYPE EnumWarpAdapter( REFIID riid, void** ppvAdapter) final;