1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 04:24:11 +01:00

[dxgi] Implement IDXGIVkMonitorInfo for DxgiFactory

This commit is contained in:
Philip Rebohle 2019-03-14 15:28:05 +01:00
parent cfdac13ea5
commit 7d5b5f288c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 114 additions and 3 deletions

View File

@ -4,9 +4,10 @@
namespace dxvk {
DxgiFactory::DxgiFactory(UINT Flags)
: m_instance(new DxvkInstance()),
m_options (m_instance->config()),
m_flags (Flags) {
: m_instance (new DxvkInstance()),
m_monitorInfo (this),
m_options (m_instance->config()),
m_flags (Flags) {
for (uint32_t i = 0; m_instance->enumAdapters(i) != nullptr; i++)
m_instance->enumAdapters(i)->logAdapterInfo();
}
@ -33,6 +34,11 @@ namespace dxvk {
*ppvObject = ref(this);
return S_OK;
}
if (riid == __uuidof(IDXGIVkMonitorInfo)) {
*ppvObject = ref(&m_monitorInfo);
return S_OK;
}
Logger::warn("DxgiFactory::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -3,6 +3,7 @@
#include <vector>
#include "dxgi_adapter.h"
#include "dxgi_monitor.h"
#include "dxgi_options.h"
#include "../dxvk/dxvk_instance.h"
@ -119,6 +120,7 @@ namespace dxvk {
private:
Rc<DxvkInstance> m_instance;
DxgiMonitorInfo m_monitorInfo;
DxgiOptions m_options;
UINT m_flags;

View File

@ -6,6 +6,73 @@ namespace dxvk {
std::unordered_map<HMONITOR, DXGI_VK_MONITOR_DATA> g_monitorData;
DxgiMonitorInfo::DxgiMonitorInfo(IUnknown* pParent)
: m_parent(pParent) {
}
DxgiMonitorInfo::~DxgiMonitorInfo() {
}
ULONG STDMETHODCALLTYPE DxgiMonitorInfo::AddRef() {
return m_parent->AddRef();
}
ULONG STDMETHODCALLTYPE DxgiMonitorInfo::Release() {
return m_parent->Release();
}
HRESULT STDMETHODCALLTYPE DxgiMonitorInfo::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_parent->QueryInterface(riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE DxgiMonitorInfo::InitMonitorData(
HMONITOR hMonitor,
const DXGI_VK_MONITOR_DATA* pData) {
if (!hMonitor || !pData)
return E_INVALIDARG;
std::lock_guard<std::mutex> lock(m_monitorMutex);
auto result = m_monitorData.insert({ hMonitor, *pData });
return result.second ? S_OK : E_INVALIDARG;
}
HRESULT STDMETHODCALLTYPE DxgiMonitorInfo::AcquireMonitorData(
HMONITOR hMonitor,
DXGI_VK_MONITOR_DATA** ppData) {
InitReturnPtr(ppData);
if (!hMonitor || !ppData)
return E_INVALIDARG;
m_monitorMutex.lock();
auto entry = m_monitorData.find(hMonitor);
if (entry == m_monitorData.end()) {
m_monitorMutex.unlock();
return DXGI_ERROR_NOT_FOUND;
}
*ppData = &entry->second;
return S_OK;
}
void STDMETHODCALLTYPE DxgiMonitorInfo::ReleaseMonitorData() {
m_monitorMutex.unlock();
}
uint32_t GetMonitorFormatBpp(DXGI_FORMAT Format) {
switch (Format) {
case DXGI_FORMAT_R8G8B8A8_UNORM:

View File

@ -9,6 +9,42 @@ namespace dxvk {
class DxgiSwapChain;
class DxgiMonitorInfo : public IDXGIVkMonitorInfo {
public:
DxgiMonitorInfo(IUnknown* pParent);
~DxgiMonitorInfo();
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE InitMonitorData(
HMONITOR hMonitor,
const DXGI_VK_MONITOR_DATA* pData);
HRESULT STDMETHODCALLTYPE AcquireMonitorData(
HMONITOR hMonitor,
DXGI_VK_MONITOR_DATA** ppData);
void STDMETHODCALLTYPE ReleaseMonitorData();
private:
IUnknown* m_parent;
std::mutex m_monitorMutex;
std::unordered_map<HMONITOR, DXGI_VK_MONITOR_DATA> m_monitorData;
};
/**
* \brief Queries bits per pixel for a format
*