diff options
author | Philip Rebohle <philip.rebohle@tu-dortmund.de> | 2022-11-30 21:43:55 +0300 |
---|---|---|
committer | Philip Rebohle <philip.rebohle@tu-dortmund.de> | 2022-11-30 21:43:55 +0300 |
commit | e3f69f859d8041f7eea301db49f80e1f152b2e53 (patch) | |
tree | 66af3b4d298baa072f04506cdc0f93bba9a890ea | |
parent | 9f7066677731e9a7ef2fa16cf85e36fd32c3313a (diff) |
-rw-r--r-- | src/dxgi/dxgi_output.cpp | 14 | ||||
-rw-r--r-- | src/wsi/win32/wsi_monitor_win32.cpp | 23 | ||||
-rw-r--r-- | src/wsi/wsi_edid.cpp | 7 |
3 files changed, 42 insertions, 2 deletions
diff --git a/src/dxgi/dxgi_output.cpp b/src/dxgi/dxgi_output.cpp index 1b4db77b..9f8386b1 100644 --- a/src/dxgi/dxgi_output.cpp +++ b/src/dxgi/dxgi_output.cpp @@ -205,6 +205,8 @@ namespace dxvk { if (pDesc == nullptr) return DXGI_ERROR_INVALID_CALL; + Logger::err("GetDesc1"); + if (!wsi::getDesktopCoordinates(m_monitor, &pDesc->DesktopCoordinates)) { Logger::err("DXGI: Failed to query monitor coords"); return E_FAIL; @@ -635,11 +637,14 @@ namespace dxvk { void DxgiOutput::CacheMonitorData() { + Logger::err(str::format("CacheMonitorData: hMonitor = ", m_monitor)); + // Try and find an existing monitor info. DXGI_VK_MONITOR_DATA* pMonitorData; if (SUCCEEDED(m_monitorInfo->AcquireMonitorData(m_monitor, &pMonitorData))) { m_metadata = pMonitorData->DisplayMetadata; m_monitorInfo->ReleaseMonitorData(); + Logger::err("CacheMonitorData: returning existing data"); return; } @@ -659,16 +664,21 @@ namespace dxvk { wsi::getCurrentDisplayMode(m_monitor, &activeWsiMode); // Get the display metadata + colorimetry + Logger::err("CacheMonitorData: querying monitor EDID"); wsi::WsiEdidData edidData = wsi::getMonitorEdid(m_monitor); std::optional<wsi::WsiDisplayMetadata> metadata = std::nullopt; - if (!edidData.empty()) + + if (!edidData.empty()) { + Logger::err("CacheMonitorData: parsing monitor EDID"); metadata = wsi::parseColorimetryInfo(edidData); + } if (metadata) m_metadata = metadata.value(); else Logger::err("DXGI: Failed to parse display metadata + colorimetry info, using blank."); + Logger::err("CacheMonitorData: initializing frame statistics"); monitorData.FrameStats.SyncQPCTime.QuadPart = dxvk::high_resolution_clock::get_counter(); monitorData.GammaCurve.Scale = { 1.0f, 1.0f, 1.0f }; monitorData.GammaCurve.Offset = { 0.0f, 0.0f, 0.0f }; @@ -680,7 +690,9 @@ namespace dxvk { monitorData.GammaCurve.GammaCurve[i] = { value, value, value }; } + Logger::err("CacheMonitorData: committing data"); m_monitorInfo->InitMonitorData(m_monitor, &monitorData); + Logger::err("CacheMonitorData: done"); } } diff --git a/src/wsi/win32/wsi_monitor_win32.cpp b/src/wsi/win32/wsi_monitor_win32.cpp index 3d7913e8..93fe0988 100644 --- a/src/wsi/win32/wsi_monitor_win32.cpp +++ b/src/wsi/win32/wsi_monitor_win32.cpp @@ -137,9 +137,11 @@ namespace dxvk::wsi { } static std::wstring getMonitorDevicePath(HMONITOR hMonitor) { + Logger::err(str::format("wsi::getMonitorDevicePath: hMonitor = ", hMonitor)); // Get the device name of the monitor. MONITORINFOEXW monInfo; monInfo.cbSize = sizeof(monInfo); + if (!::GetMonitorInfoW(hMonitor, &monInfo)) { Logger::err("getMonitorDevicePath: Failed to get monitor info."); return {}; @@ -151,11 +153,13 @@ namespace dxvk::wsi { std::vector<DISPLAYCONFIG_PATH_INFO> paths; std::vector<DISPLAYCONFIG_MODE_INFO> modes; do { + Logger::err(str::format("wsi::getMonitorDevicePath: GetDisplayConfigBufferSizes")); uint32_t pathCount = 0, modeCount = 0; if ((result = ::GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathCount, &modeCount)) != ERROR_SUCCESS) { Logger::err(str::format("getMonitorDevicePath: GetDisplayConfigBufferSizes failed. ret: ", result, " LastError: ", GetLastError())); return {}; } + Logger::err(str::format("wsi::getMonitorDevicePath: QueryDisplayConfig")); paths.resize(pathCount); modes.resize(modeCount); result = ::QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, paths.data(), &modeCount, modes.data(), nullptr); @@ -168,6 +172,7 @@ namespace dxvk::wsi { // Link a source name -> target name for (const auto& path : paths) { + Logger::err(str::format("wsi::getMonitorDevicePath: DisplayConfigGetDeviceInfo 1")); DISPLAYCONFIG_SOURCE_DEVICE_NAME sourceName; sourceName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME; sourceName.header.size = sizeof(sourceName); @@ -178,6 +183,7 @@ namespace dxvk::wsi { continue; } + Logger::err(str::format("wsi::getMonitorDevicePath: DisplayConfigGetDeviceInfo 2")); DISPLAYCONFIG_TARGET_DEVICE_NAME targetName; targetName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; targetName.header.size = sizeof(targetName); @@ -190,8 +196,10 @@ namespace dxvk::wsi { // Does the source match the GDI device we are looking for? // If so, return the target back. - if (!wcscmp(sourceName.viewGdiDeviceName, monInfo.szDevice)) + if (!wcscmp(sourceName.viewGdiDeviceName, monInfo.szDevice)) { + Logger::err(str::format("wsi::getMonitorDevicePath: done")); return targetName.monitorDevicePath; + } } Logger::err("getMonitorDevicePath: Failed to find a link from source -> target."); @@ -199,18 +207,21 @@ namespace dxvk::wsi { } static WsiEdidData readMonitorEdidFromKey(HKEY deviceRegKey) { + Logger::err(str::format("wsi::readMonitorEdidFromKey: RegQueryValueExW 1")); DWORD edidSize = 0; if (::RegQueryValueExW(deviceRegKey, L"EDID", nullptr, nullptr, nullptr, &edidSize) != ERROR_SUCCESS) { Logger::err("readMonitorEdidFromKey: Failed to get EDID reg key size"); return {}; } + Logger::err(str::format("wsi::readMonitorEdidFromKey: RegQueryValueExW 2")); WsiEdidData edidData(edidSize); if (::RegQueryValueExW(deviceRegKey, L"EDID", nullptr, nullptr, edidData.data(), &edidSize) != ERROR_SUCCESS) { Logger::err("readMonitorEdidFromKey: Failed to get EDID reg key data"); return {}; } + Logger::err(str::format("wsi::readMonitorEdidFromKey: done")); return edidData; } @@ -224,6 +235,8 @@ namespace dxvk::wsi { }; WsiEdidData getMonitorEdid(HMONITOR hMonitor) { + Logger::err(str::format("wsi::getMonitorEdid: hMonitor = ", hMonitor)); + static constexpr GUID GUID_DEVINTERFACE_MONITOR = { 0xe6f07b5f, 0xee97, 0x4a90, 0xb0, 0x76, 0x33, 0xf5, 0x7b, 0xf4, 0xea, 0xa7 }; static auto pfnSetupDiGetClassDevsW = reinterpret_cast<decltype(SetupDiGetClassDevsW)*> (::GetProcAddress(::GetModuleHandleW(L"setupapi.dll"), "SetupDiGetClassDevsW")); static auto pfnSetupDiEnumDeviceInterfaces = reinterpret_cast<decltype(SetupDiEnumDeviceInterfaces)*> (::GetProcAddress(::GetModuleHandleW(L"setupapi.dll"), "SetupDiEnumDeviceInterfaces")); @@ -235,18 +248,21 @@ namespace dxvk::wsi { return {}; } + Logger::err("wsi::getMonitorEdid: getMonitorDevicePath"); std::wstring monitorDevicePath = getMonitorDevicePath(hMonitor); if (monitorDevicePath.empty()) { Logger::err("getMonitorEdid: Failed to get monitor device path."); return {}; } + Logger::err("wsi::getMonitorEdid: SetupDiGetClassDevsW"); const HDEVINFO devInfo = pfnSetupDiGetClassDevsW(&GUID_DEVINTERFACE_MONITOR, nullptr, nullptr, DIGCF_DEVICEINTERFACE); SP_DEVICE_INTERFACE_DATA interfaceData; memset(&interfaceData, 0, sizeof(interfaceData)); interfaceData.cbSize = sizeof(interfaceData); + Logger::err("wsi::getMonitorEdid: SetupDiEnumDeviceInterfaces"); for (DWORD monitorIdx = 0; pfnSetupDiEnumDeviceInterfaces(devInfo, nullptr, &GUID_DEVINTERFACE_MONITOR, monitorIdx, &interfaceData); monitorIdx++) { DxvkDeviceInterfaceDetail detailData; // Josh: I'm taking no chances here. I don't trust this API at all. @@ -257,6 +273,7 @@ namespace dxvk::wsi { memset(&devInfoData, 0, sizeof(devInfoData)); devInfoData.cbSize = sizeof(devInfoData); + Logger::err("wsi::getMonitorEdid: SetupDiGetDeviceInterfaceDetailW"); if (!pfnSetupDiGetDeviceInterfaceDetailW(devInfo, &interfaceData, &detailData.base, sizeof(detailData), nullptr, &devInfoData)) continue; @@ -267,16 +284,20 @@ namespace dxvk::wsi { if (_wcsicmp(monitorDevicePath.c_str(), detailData.base.DevicePath) != 0) continue; + Logger::err("wsi::getMonitorEdid: SetupDiOpenDevRegKey"); HKEY deviceRegKey = pfnSetupDiOpenDevRegKey(devInfo, &devInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ); if (deviceRegKey == INVALID_HANDLE_VALUE) { Logger::err("getMonitorEdid: Failed to open monitor device registry key."); return {}; } + Logger::err("wsi::getMonitorEdid: readMonitorEdidFromKey"); auto edidData = readMonitorEdidFromKey(deviceRegKey); + Logger::err("wsi::getMonitorEdid: RegCloseKey"); ::RegCloseKey(deviceRegKey); + Logger::err("wsi::getMonitorEdid: done"); return edidData; } diff --git a/src/wsi/wsi_edid.cpp b/src/wsi/wsi_edid.cpp index 792f19aa..1f812e19 100644 --- a/src/wsi/wsi_edid.cpp +++ b/src/wsi/wsi_edid.cpp @@ -13,6 +13,7 @@ namespace dxvk::wsi { std::optional<WsiDisplayMetadata> parseColorimetryInfo( const WsiEdidData& edidData) { + Logger::err("parseColorimetryInfo"); WsiDisplayMetadata metadata = {}; di_info* info = di_info_parse_edid(edidData.data(), edidData.size()); @@ -21,12 +22,15 @@ namespace dxvk::wsi { return std::nullopt; } + Logger::err("parseColorimetryInfo: di_info_get_edid"); const di_edid* edid = di_info_get_edid(info); + Logger::err("parseColorimetryInfo: di_edid_get_chromaticity_coords"); const di_edid_chromaticity_coords* chroma = di_edid_get_chromaticity_coords(edid); const di_cta_hdr_static_metadata_block* hdr_static_metadata = nullptr; const di_cta_colorimetry_block* colorimetry = nullptr; + Logger::err("parseColorimetryInfo: di_edid_get_extensions"); const di_edid_cta* cta = nullptr; const di_edid_ext* const* exts = di_edid_get_extensions(edid); for (; *exts != nullptr; exts++) { @@ -35,6 +39,7 @@ namespace dxvk::wsi { } if (cta) { + Logger::err("parseColorimetryInfo: di_edid_cta_get_data_blocks"); const di_cta_data_block* const* blocks = di_edid_cta_get_data_blocks(cta); for (; *blocks != nullptr; blocks++) { if ((hdr_static_metadata = di_cta_data_block_get_hdr_static_metadata(*blocks))) @@ -66,8 +71,10 @@ namespace dxvk::wsi { colorimetry && colorimetry->bt2020_rgb && hdr_static_metadata && hdr_static_metadata->eotfs && hdr_static_metadata->eotfs->pq; + Logger::err("parseColorimetryInfo: di_info_destroy"); di_info_destroy(info); + Logger::err("parseColorimetryInfo: done"); return metadata; } |