[dxgi] Support multiple outputs per adapter

This commit is contained in:
Philip Rebohle 2018-07-16 17:00:23 +02:00
parent 4ab5682260
commit 1c86ed8c93
2 changed files with 37 additions and 7 deletions

View File

@ -81,14 +81,18 @@ namespace dxvk {
if (ppOutput == nullptr)
return DXGI_ERROR_INVALID_CALL;
if (Output > 0) {
*ppOutput = nullptr;
return DXGI_ERROR_NOT_FOUND;
}
MonitorEnumInfo info;
info.iMonitorId = Output;
info.oMonitor = nullptr;
// TODO support multiple monitors
HMONITOR monitor = ::MonitorFromPoint({ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
*ppOutput = ref(new DxgiOutput(this, monitor));
::EnumDisplayMonitors(
nullptr, nullptr, &MonitorEnumProc,
reinterpret_cast<LPARAM>(&info));
if (info.oMonitor == nullptr)
return DXGI_ERROR_NOT_FOUND;
*ppOutput = ref(new DxgiOutput(this, info.oMonitor));
return S_OK;
}
@ -284,4 +288,19 @@ namespace dxvk {
return S_OK;
}
BOOL DxgiAdapter::MonitorEnumProc(
HMONITOR hmon,
HDC hdc,
LPRECT rect,
LPARAM lp) {
auto data = reinterpret_cast<MonitorEnumInfo*>(lp);
if (data->iMonitorId--)
return TRUE; /* continue */
data->oMonitor = hmon;
return FALSE; /* stop */
}
}

View File

@ -85,6 +85,17 @@ namespace dxvk {
std::mutex m_outputMutex;
OutputMap m_outputData;
struct MonitorEnumInfo {
UINT iMonitorId;
HMONITOR oMonitor;
};
static BOOL MonitorEnumProc(
HMONITOR hmon,
HDC hdc,
LPRECT rect,
LPARAM lp);
};
}