From cfdac13ea5cb13abe08c35d6c20ca22ec4cb1796 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 14 Mar 2019 15:20:40 +0100 Subject: [PATCH] [dxgi] Add new COM interface for per-monitor data --- src/dxgi/dxgi_interfaces.h | 60 ++++++++++++++++++++++++++++++++++++++ src/dxgi/dxgi_monitor.h | 12 +------- src/util/com/com_guid.cpp | 1 + 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/dxgi/dxgi_interfaces.h b/src/dxgi/dxgi_interfaces.h index eacc69702..7974bce3d 100644 --- a/src/dxgi/dxgi_interfaces.h +++ b/src/dxgi/dxgi_interfaces.h @@ -7,6 +7,7 @@ namespace dxvk { class DxgiAdapter; + class DxgiSwapChain; class DxvkAdapter; class DxvkBuffer; class DxvkDevice; @@ -16,6 +17,17 @@ namespace dxvk { struct IDXGIVkInteropDevice; + +/** + * \brief Per-monitor data + */ +struct DXGI_VK_MONITOR_DATA { + dxvk::DxgiSwapChain* pSwapChain; + DXGI_FRAME_STATISTICS FrameStats; + DXGI_GAMMA_CONTROL GammaCurve; +}; + + /** * \brief Private DXGI presenter * @@ -78,6 +90,52 @@ IDXGIVkAdapter : public IDXGIAdapter3 { }; +/** + * \brief Private DXGI monitor info interface + * + * Can be queried from the DXGI factory to store monitor + * info globally, with a lifetime that exceeds that of + * the \c IDXGIOutput or \c IDXGIAdapter objects. + */ +MIDL_INTERFACE("c06a236f-5be3-448a-8943-89c611c0c2c1") +IDXGIVkMonitorInfo : public IUnknown { + static const GUID guid; + + /** + * \brief Initializes monitor data + * + * Fails if data for the given monitor already exists. + * \param [in] hMonitor The monitor handle + * \param [in] pData Initial data + */ + virtual HRESULT STDMETHODCALLTYPE InitMonitorData( + HMONITOR hMonitor, + const DXGI_VK_MONITOR_DATA* pData) = 0; + + /** + * \brief Retrieves and locks monitor data + * + * Fails if no data for the given monitor exists. + * \param [in] hMonitor The monitor handle + * \param [out] Pointer to monitor data + * \returns S_OK on success + */ + virtual HRESULT STDMETHODCALLTYPE AcquireMonitorData( + HMONITOR hMonitor, + DXGI_VK_MONITOR_DATA** ppData) = 0; + + /** + * \brief Unlocks monitor data + * + * Must be called after each successful + * call to \ref AcquireMonitorData. + * \param [in] hMonitor The monitor handle + */ + virtual void STDMETHODCALLTYPE ReleaseMonitorData() = 0; + +}; + + /** * \brief DXGI surface interface for Vulkan interop * @@ -241,12 +299,14 @@ IWineDXGISwapChainFactory : public IUnknown { #ifdef _MSC_VER struct __declspec(uuid("907bf281-ea3c-43b4-a8e4-9f231107b4ff")) IDXGIVkAdapter; +struct __declspec(uuid("c06a236f-5be3-448a-8943-89c611c0c2c1")) IDXGIVkMonitorInfo; struct __declspec(uuid("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")) IDXGIVkInteropDevice; struct __declspec(uuid("5546cf8c-77e7-4341-b05d-8d4d5000e77d")) IDXGIVkInteropSurface; struct __declspec(uuid("104001a6-7f36-4957-b932-86ade9567d91")) IDXGIVkSwapChain; struct __declspec(uuid("53cb4ff0-c25a-4164-a891-0e83db0a7aac")) IWineDXGISwapChainFactory; #else DXVK_DEFINE_GUID(IDXGIVkAdapter); +DXVK_DEFINE_GUID(IDXGIVkMonitorInfo); DXVK_DEFINE_GUID(IDXGIVkInteropDevice); DXVK_DEFINE_GUID(IDXGIVkInteropSurface); DXVK_DEFINE_GUID(IDXGIVkSwapChain); diff --git a/src/dxgi/dxgi_monitor.h b/src/dxgi/dxgi_monitor.h index 9e03155a9..083dc35e8 100644 --- a/src/dxgi/dxgi_monitor.h +++ b/src/dxgi/dxgi_monitor.h @@ -3,22 +3,12 @@ #include #include -#include "dxgi_include.h" +#include "dxgi_interfaces.h" namespace dxvk { class DxgiSwapChain; - /** - * \brief Per-monitor data - */ - struct DXGI_VK_MONITOR_DATA { - DxgiSwapChain* pSwapChain; - DXGI_FRAME_STATISTICS FrameStats; - DXGI_GAMMA_CONTROL GammaCurve; - }; - - /** * \brief Queries bits per pixel for a format * diff --git a/src/util/com/com_guid.cpp b/src/util/com/com_guid.cpp index 85f6164d5..cd407ee84 100644 --- a/src/util/com/com_guid.cpp +++ b/src/util/com/com_guid.cpp @@ -5,6 +5,7 @@ #include "../../dxgi/dxgi_interfaces.h" const GUID IDXGIVkAdapter::guid = {0x907bf281,0xea3c,0x43b4,{0xa8,0xe4,0x9f,0x23,0x11,0x07,0xb4,0xff}}; +const GUID IDXGIVkMonitorInfo::guid = {0xc06a236f,0x5be3,0x448a,{0x89,0x43,0x89,0xc6,0x11,0xc0,0xc2,0xc1}}; const GUID IDXGIVkInteropDevice::guid = {0xe2ef5fa5,0xdc21,0x4af7,{0x90,0xc4,0xf6,0x7e,0xf6,0xa0,0x93,0x23}}; const GUID IDXGIVkInteropSurface::guid = {0x5546cf8c,0x77e7,0x4341,{0xb0,0x5d,0x8d,0x4d,0x50,0x00,0xe7,0x7d}}; const GUID IDXGIVkSwapChain::guid = {0x104001a6,0x7f36,0x4957,{0xb9,0x32,0x86,0xad,0xe9,0x56,0x7d,0x91}};