From 7fd831e705f084bc73435b34896383d5b3c6b776 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Sun, 29 Sep 2019 16:24:03 -0700 Subject: [PATCH 1/2] libobs-d3d11: Log display refresh rates --- libobs-d3d11/d3d11-subsystem.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 1fd20a98c..6eed74275 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -734,15 +734,30 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) if (FAILED(output->GetDesc(&desc))) continue; - RECT rect = desc.DesktopCoordinates; + unsigned refresh = 0; + + MONITORINFOEX info; + info.cbSize = sizeof(info); + if (GetMonitorInfo(desc.Monitor, &info)) { + DEVMODE mode; + mode.dmSize = sizeof(mode); + mode.dmDriverExtra = 0; + if (EnumDisplaySettings(info.szDevice, + ENUM_CURRENT_SETTINGS, &mode)) { + refresh = mode.dmDisplayFrequency; + } + } + + const RECT &rect = desc.DesktopCoordinates; blog(LOG_INFO, "\t output %u: " "pos={%d, %d}, " "size={%d, %d}, " - "attached=%s", + "attached=%s, " + "refresh=%u", i, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, - desc.AttachedToDesktop ? "true" : "false"); + desc.AttachedToDesktop ? "true" : "false", refresh); } } From 4b0826cf5d27ee2c1641e91ff0e4a11866fc326e Mon Sep 17 00:00:00 2001 From: jpark37 Date: Tue, 1 Oct 2019 20:00:43 -0700 Subject: [PATCH 2/2] libobs-d3d11: Log monitor names --- libobs-d3d11/d3d11-subsystem.cpp | 62 ++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 6eed74275..75bdbd16d 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -724,6 +724,53 @@ bool device_enum_adapters(bool (*callback)(void *param, const char *name, } } +static bool GetMonitorTarget(const MONITORINFOEX &info, + DISPLAYCONFIG_TARGET_DEVICE_NAME &target) +{ + bool found = false; + + UINT32 numPath, numMode; + if (GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &numPath, + &numMode) == ERROR_SUCCESS) { + std::vector paths(numPath); + std::vector modes(numMode); + if (QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &numPath, + paths.data(), &numMode, modes.data(), + nullptr) == ERROR_SUCCESS) { + paths.resize(numPath); + for (size_t i = 0; i < numPath; ++i) { + const DISPLAYCONFIG_PATH_INFO &path = paths[i]; + + DISPLAYCONFIG_SOURCE_DEVICE_NAME + source; + source.header.type = + DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME; + source.header.size = sizeof(source); + source.header.adapterId = + path.sourceInfo.adapterId; + source.header.id = path.sourceInfo.id; + if (DisplayConfigGetDeviceInfo( + &source.header) == ERROR_SUCCESS && + wcscmp(info.szDevice, + source.viewGdiDeviceName) == 0) { + target.header.type = + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; + target.header.size = sizeof(target); + target.header.adapterId = + path.sourceInfo.adapterId; + target.header.id = path.targetInfo.id; + found = DisplayConfigGetDeviceInfo( + &target.header) == + ERROR_SUCCESS; + break; + } + } + } + } + + return found; +} + static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) { UINT i; @@ -736,9 +783,14 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) unsigned refresh = 0; + bool target_found = false; + DISPLAYCONFIG_TARGET_DEVICE_NAME target; + MONITORINFOEX info; info.cbSize = sizeof(info); if (GetMonitorInfo(desc.Monitor, &info)) { + target_found = GetMonitorTarget(info, target); + DEVMODE mode; mode.dmSize = sizeof(mode); mode.dmDriverExtra = 0; @@ -748,16 +800,22 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter) } } + if (!target_found) { + target.monitorFriendlyDeviceName[0] = 0; + } + const RECT &rect = desc.DesktopCoordinates; blog(LOG_INFO, "\t output %u: " "pos={%d, %d}, " "size={%d, %d}, " "attached=%s, " - "refresh=%u", + "refresh=%u, " + "name=%ls", i, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, - desc.AttachedToDesktop ? "true" : "false", refresh); + desc.AttachedToDesktop ? "true" : "false", refresh, + target.monitorFriendlyDeviceName); } }