Merge pull request #2090 from jpark37/dxgi-refresh-rate
Log display refresh rates, and monitor names on D3D11master
commit
3ccc63c14b
|
@ -823,6 +823,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<DISPLAYCONFIG_PATH_INFO> paths(numPath);
|
||||
std::vector<DISPLAYCONFIG_MODE_INFO> 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;
|
||||
|
@ -833,15 +880,41 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter)
|
|||
if (FAILED(output->GetDesc(&desc)))
|
||||
continue;
|
||||
|
||||
RECT rect = desc.DesktopCoordinates;
|
||||
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;
|
||||
if (EnumDisplaySettings(info.szDevice,
|
||||
ENUM_CURRENT_SETTINGS, &mode)) {
|
||||
refresh = mode.dmDisplayFrequency;
|
||||
}
|
||||
}
|
||||
|
||||
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",
|
||||
"attached=%s, "
|
||||
"refresh=%u, "
|
||||
"name=%ls",
|
||||
i, rect.left, rect.top, rect.right - rect.left,
|
||||
rect.bottom - rect.top,
|
||||
desc.AttachedToDesktop ? "true" : "false");
|
||||
desc.AttachedToDesktop ? "true" : "false", refresh,
|
||||
target.monitorFriendlyDeviceName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue