From 50347e12569367d53939431b1854cce214f900a0 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 14 Mar 2019 15:35:35 +0100 Subject: [PATCH] [dxgi] Use IDXGIVkMonitorInfo in DxgiOutput --- src/dxgi/dxgi_adapter.cpp | 2 +- src/dxgi/dxgi_factory.h | 4 ++++ src/dxgi/dxgi_output.cpp | 19 +++++++++++-------- src/dxgi/dxgi_output.h | 15 +++------------ 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index 5b90f65e0..e7e574603 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -89,7 +89,7 @@ namespace dxvk { // TODO support multiple monitors HMONITOR monitor = ::MonitorFromPoint({ 0, 0 }, MONITOR_DEFAULTTOPRIMARY); - *ppOutput = ref(new DxgiOutput(this, monitor)); + *ppOutput = ref(new DxgiOutput(m_factory, this, monitor)); return S_OK; } diff --git a/src/dxgi/dxgi_factory.h b/src/dxgi/dxgi_factory.h index 2044e6a3b..8083b6fde 100644 --- a/src/dxgi/dxgi_factory.h +++ b/src/dxgi/dxgi_factory.h @@ -116,6 +116,10 @@ namespace dxvk { const DxgiOptions* GetOptions() const { return &m_options; } + + DxgiMonitorInfo* GetMonitorInfo() { + return &m_monitorInfo; + } private: diff --git a/src/dxgi/dxgi_output.cpp b/src/dxgi/dxgi_output.cpp index 3bcf4bd08..e050acf75 100644 --- a/src/dxgi/dxgi_output.cpp +++ b/src/dxgi/dxgi_output.cpp @@ -7,6 +7,7 @@ #include #include "dxgi_adapter.h" +#include "dxgi_factory.h" #include "dxgi_output.h" #include "dxgi_swapchain.h" @@ -15,9 +16,11 @@ namespace dxvk { DxgiOutput::DxgiOutput( + const Com& factory, const Com& adapter, HMONITOR monitor) - : m_adapter(adapter), + : m_monitorInfo(factory->GetMonitorInfo()), + m_adapter(adapter), m_monitor(monitor) { // Init monitor info if necessary DXGI_VK_MONITOR_DATA monitorData; @@ -31,7 +34,7 @@ namespace dxvk { monitorData.GammaCurve.GammaCurve[i] = { value, value, value }; } - InitMonitorData(monitor, &monitorData); + m_monitorInfo->InitMonitorData(monitor, &monitorData); } @@ -333,26 +336,26 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE DxgiOutput::GetFrameStatistics(DXGI_FRAME_STATISTICS* pStats) { DXGI_VK_MONITOR_DATA* monitorInfo = nullptr; - HRESULT hr = AcquireMonitorData(m_monitor, &monitorInfo); + HRESULT hr = m_monitorInfo->AcquireMonitorData(m_monitor, &monitorInfo); if (FAILED(hr)) return hr; *pStats = monitorInfo->FrameStats; - ReleaseMonitorData(); + m_monitorInfo->ReleaseMonitorData(); return S_OK; } HRESULT STDMETHODCALLTYPE DxgiOutput::GetGammaControl(DXGI_GAMMA_CONTROL* pArray) { DXGI_VK_MONITOR_DATA* monitorInfo = nullptr; - HRESULT hr = AcquireMonitorData(m_monitor, &monitorInfo); + HRESULT hr = m_monitorInfo->AcquireMonitorData(m_monitor, &monitorInfo); if (FAILED(hr)) return hr; *pArray = monitorInfo->GammaCurve; - ReleaseMonitorData(); + m_monitorInfo->ReleaseMonitorData(); return S_OK; } @@ -388,7 +391,7 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE DxgiOutput::SetGammaControl(const DXGI_GAMMA_CONTROL* pArray) { DXGI_VK_MONITOR_DATA* monitorInfo = nullptr; - HRESULT hr = AcquireMonitorData(m_monitor, &monitorInfo); + HRESULT hr = m_monitorInfo->AcquireMonitorData(m_monitor, &monitorInfo); if (FAILED(hr)) return hr; @@ -400,7 +403,7 @@ namespace dxvk { DXGI_VK_GAMMA_CP_COUNT, pArray->GammaCurve); } - ReleaseMonitorData(); + m_monitorInfo->ReleaseMonitorData(); return hr; } diff --git a/src/dxgi/dxgi_output.h b/src/dxgi/dxgi_output.h index 372282141..8476fcdce 100644 --- a/src/dxgi/dxgi_output.h +++ b/src/dxgi/dxgi_output.h @@ -6,6 +6,7 @@ namespace dxvk { class DxgiAdapter; + class DxgiFactory; /** * \brief Number of gamma control points @@ -22,24 +23,13 @@ namespace dxvk { return float(CpIndex) / float(DXGI_VK_GAMMA_CP_COUNT - 1); } - /** - * \brief Per-output data - * - * Persistent data for a single output, which - * is addressed using the \c HMONITOR handle. - */ - struct DXGI_VK_OUTPUT_DATA { - DXGI_FRAME_STATISTICS FrameStats; - DXGI_GAMMA_CONTROL GammaCurve; - BOOL GammaDirty; - }; - class DxgiOutput : public DxgiObject { public: DxgiOutput( + const Com& factory, const Com& adapter, HMONITOR monitor); @@ -126,6 +116,7 @@ namespace dxvk { private: + DxgiMonitorInfo* m_monitorInfo = nullptr; Com m_adapter = nullptr; HMONITOR m_monitor = nullptr;