mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 15:11:31 +00:00
[idd] config: retain four-decimal refresh rates
This commit is contained in:
@@ -33,14 +33,14 @@ CSettings::CSettings()
|
||||
|
||||
CSettings::DisplayModes CSettings::LoadModes()
|
||||
{
|
||||
const unsigned defaultRefreshMilliHz = GetDefaultRefreshMilliHz();
|
||||
const unsigned defaultRefresh100uHz = GetDefaultRefresh100uHz();
|
||||
DisplayModes displayModes;
|
||||
|
||||
bool hasPreferred = false;
|
||||
DisplayMode m;
|
||||
if (GetExtraMode(m))
|
||||
{
|
||||
const std::wstring refresh = LGFormatRefreshRate(m.refreshMilliHz);
|
||||
const std::wstring refresh = LGFormatRefreshRate(m.refresh100uHz);
|
||||
DEBUG_INFO("ExtraMode: %ux%u@%ls%s", m.width, m.height,
|
||||
refresh.c_str(), m.preferred ? "*" : "");
|
||||
displayModes.push_back(m);
|
||||
@@ -57,7 +57,7 @@ CSettings::DisplayModes CSettings::LoadModes()
|
||||
{
|
||||
m.width = DefaultDisplayModes[i][0];
|
||||
m.height = DefaultDisplayModes[i][1];
|
||||
m.refreshMilliHz = defaultRefreshMilliHz;
|
||||
m.refresh100uHz = defaultRefresh100uHz;
|
||||
m.preferred = !hasPreferred &&
|
||||
(i == DefaultPreferredDisplayMode);
|
||||
m.extraMode = false;
|
||||
@@ -96,7 +96,7 @@ TransportInstances CSettings::LoadTransportInstances() const
|
||||
bool CSettings::SetExtraMode(const DisplayMode& mode)
|
||||
{
|
||||
WCHAR buf[64];
|
||||
const std::wstring refresh = LGFormatRefreshRate(mode.refreshMilliHz);
|
||||
const std::wstring refresh = LGFormatRefreshRate(mode.refresh100uHz);
|
||||
_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%ux%u@%ls%s",
|
||||
mode.width, mode.height, refresh.c_str(),
|
||||
mode.preferred ? L"*" : L"");
|
||||
@@ -199,13 +199,13 @@ bool CSettings::GetExtraMode(DisplayMode& mode)
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned CSettings::GetDefaultRefreshMilliHz() const
|
||||
unsigned CSettings::GetDefaultRefresh100uHz() const
|
||||
{
|
||||
HKEY hKey = nullptr;
|
||||
LONG status = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE, RegistryKey(), 0, KEY_QUERY_VALUE, &hKey);
|
||||
if (status != ERROR_SUCCESS)
|
||||
return 60000;
|
||||
return 60 * LG_REFRESH_RATE_SCALE;
|
||||
|
||||
DWORD type = 0;
|
||||
DWORD size = 0;
|
||||
@@ -214,17 +214,17 @@ unsigned CSettings::GetDefaultRefreshMilliHz() const
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return 60000;
|
||||
return 60 * LG_REFRESH_RATE_SCALE;
|
||||
}
|
||||
|
||||
unsigned refreshMilliHz = 0;
|
||||
unsigned refresh100uHz = 0;
|
||||
if (type == REG_DWORD && size == sizeof(DWORD))
|
||||
{
|
||||
DWORD refresh = 0;
|
||||
status = RegQueryValueExW(hKey, L"DefaultRefresh", nullptr, &type,
|
||||
(LPBYTE)&refresh, &size);
|
||||
if (status == ERROR_SUCCESS && refresh >= 24 && refresh <= 1000)
|
||||
refreshMilliHz = refresh * 1000;
|
||||
refresh100uHz = refresh * LG_REFRESH_RATE_SCALE;
|
||||
}
|
||||
else if ((type == REG_SZ || type == REG_EXPAND_SZ) && size &&
|
||||
size % sizeof(wchar_t) == 0)
|
||||
@@ -233,11 +233,11 @@ unsigned CSettings::GetDefaultRefreshMilliHz() const
|
||||
status = RegQueryValueExW(hKey, L"DefaultRefresh", nullptr, &type,
|
||||
(LPBYTE)value.data(), &size);
|
||||
if (status == ERROR_SUCCESS)
|
||||
LGParseRefreshRate(value.data(), refreshMilliHz);
|
||||
LGParseRefreshRate(value.data(), refresh100uHz);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return refreshMilliHz ? refreshMilliHz : 60000;
|
||||
return refresh100uHz ? refresh100uHz : 60 * LG_REFRESH_RATE_SCALE;
|
||||
}
|
||||
|
||||
bool CSettings::ReadMultiStringValue(const wchar_t * name,
|
||||
@@ -331,7 +331,7 @@ bool CSettings::ParseModeString(const std::wstring& in, DisplayMode& out)
|
||||
|
||||
if (!toUnsigned(s.substr(0, xPos), out.width) ||
|
||||
!toUnsigned(s.substr(xPos + 1, atPos - (xPos + 1)), out.height) ||
|
||||
!LGParseRefreshRate(s.substr(atPos + 1), out.refreshMilliHz))
|
||||
!LGParseRefreshRate(s.substr(atPos + 1), out.refresh100uHz))
|
||||
return false;
|
||||
|
||||
// sanity check
|
||||
|
||||
@@ -32,7 +32,7 @@ class CSettings
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned refreshMilliHz;
|
||||
unsigned refresh100uHz;
|
||||
bool preferred;
|
||||
bool extraMode;
|
||||
};
|
||||
@@ -44,7 +44,7 @@ class CSettings
|
||||
TransportInstances LoadTransportInstances() const;
|
||||
bool SetExtraMode(const DisplayMode & mode);
|
||||
bool GetExtraMode(DisplayMode & mode);
|
||||
unsigned GetDefaultRefreshMilliHz() const;
|
||||
unsigned GetDefaultRefresh100uHz() const;
|
||||
|
||||
std::wstring ReadStringValue(const wchar_t* name, const wchar_t* defaultValue = nullptr);
|
||||
static bool ReadBoolValue(
|
||||
|
||||
@@ -440,7 +440,7 @@ void CDeviceContext::OnSwapChainReady()
|
||||
m_monitorManager.QueueReplug();
|
||||
else if (action.setMode)
|
||||
g_pipe.SetDisplayMode(
|
||||
action.mode.width, action.mode.height, action.mode.refreshMilliHz);
|
||||
action.mode.width, action.mode.height, action.mode.refresh100uHz);
|
||||
}
|
||||
|
||||
// Display configuration
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "CDebug.h"
|
||||
#include "CSRWLock.h"
|
||||
#include "RefreshRate.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
@@ -66,24 +67,26 @@ bool CDisplayConfiguration::LoadModes(const FrameCaps& caps)
|
||||
{
|
||||
configuredMode.width,
|
||||
configuredMode.height,
|
||||
configuredMode.refreshMilliHz,
|
||||
configuredMode.refresh100uHz,
|
||||
};
|
||||
if (!frameMode.width || !frameMode.height ||
|
||||
!frameMode.refreshMilliHz)
|
||||
!frameMode.refresh100uHz)
|
||||
{
|
||||
DEBUG_WARN("Filtering invalid %s mode %ux%u@%.3f",
|
||||
DEBUG_WARN("Filtering invalid %s mode %ux%u@%.4f",
|
||||
configuredMode.extraMode ? "extra" : "configured",
|
||||
configuredMode.width, configuredMode.height,
|
||||
configuredMode.refreshMilliHz / 1000.0);
|
||||
configuredMode.refresh100uHz /
|
||||
static_cast<double>(LG_REFRESH_RATE_SCALE));
|
||||
continue;
|
||||
}
|
||||
if (!caps.CanUseMode(frameMode))
|
||||
{
|
||||
DEBUG_WARN(
|
||||
"Filtering unsupported %s mode %ux%u@%.3f",
|
||||
"Filtering unsupported %s mode %ux%u@%.4f",
|
||||
configuredMode.extraMode ? "extra" : "configured",
|
||||
configuredMode.width, configuredMode.height,
|
||||
configuredMode.refreshMilliHz / 1000.0);
|
||||
configuredMode.refresh100uHz /
|
||||
static_cast<double>(LG_REFRESH_RATE_SCALE));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -128,11 +131,11 @@ bool CDisplayConfiguration::ReloadSettings(
|
||||
CSettings::DisplayMode extraMode = {};
|
||||
if (m_settings.GetExtraMode(extraMode))
|
||||
{
|
||||
const unsigned refreshMilliHz =
|
||||
m_settings.GetDefaultRefreshMilliHz();
|
||||
if (extraMode.refreshMilliHz != refreshMilliHz)
|
||||
const unsigned refresh100uHz =
|
||||
m_settings.GetDefaultRefresh100uHz();
|
||||
if (extraMode.refresh100uHz != refresh100uHz)
|
||||
{
|
||||
extraMode.refreshMilliHz = refreshMilliHz;
|
||||
extraMode.refresh100uHz = refresh100uHz;
|
||||
settingsUpdated = m_settings.SetExtraMode(extraMode);
|
||||
}
|
||||
}
|
||||
@@ -155,10 +158,10 @@ CDisplayConfiguration::SetResolution(
|
||||
CSettings::DisplayMode mode = {};
|
||||
mode.width = width;
|
||||
mode.height = height;
|
||||
mode.refreshMilliHz = m_settings.GetDefaultRefreshMilliHz();
|
||||
mode.refresh100uHz = m_settings.GetDefaultRefresh100uHz();
|
||||
mode.preferred = true;
|
||||
|
||||
if (!mode.width || !mode.height || !mode.refreshMilliHz)
|
||||
if (!mode.width || !mode.height || !mode.refresh100uHz)
|
||||
{
|
||||
DEBUG_WARN("Ignoring invalid resolution request: %ux%u", width, height);
|
||||
return result;
|
||||
@@ -168,7 +171,7 @@ CDisplayConfiguration::SetResolution(
|
||||
{
|
||||
mode.width,
|
||||
mode.height,
|
||||
mode.refreshMilliHz,
|
||||
mode.refresh100uHz,
|
||||
};
|
||||
if (!caps.CanUseMode(frameMode, &result.requiredMiB))
|
||||
{
|
||||
@@ -289,9 +292,11 @@ static inline void FillSignalInfo(DISPLAYCONFIG_VIDEO_SIGNAL_INFO& signal,
|
||||
signal.AdditionalSignalInfo.vSyncFreqDivider = monitorMode ? 0 : 1;
|
||||
signal.AdditionalSignalInfo.videoStandard = 255;
|
||||
|
||||
SetSignalRate(signal.vSyncFreq, mode.refreshMilliHz, 1000);
|
||||
SetSignalRate(signal.vSyncFreq, mode.refresh100uHz,
|
||||
LG_REFRESH_RATE_SCALE);
|
||||
SetSignalRate(signal.hSyncFreq,
|
||||
(UINT64)mode.refreshMilliHz * signal.totalSize.cy, 1000);
|
||||
(UINT64)mode.refresh100uHz * signal.totalSize.cy,
|
||||
LG_REFRESH_RATE_SCALE);
|
||||
|
||||
signal.scanLineOrdering = DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE;
|
||||
signal.pixelRate = timing.pixelClock;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "display/CEdid.h"
|
||||
|
||||
#include "RefreshRate.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
|
||||
@@ -367,7 +369,7 @@ bool CEdid::GetTiming(Timing& timing, const CSettings::DisplayMode& mode)
|
||||
timing.vActive = mode.height;
|
||||
|
||||
if (timing.hActive == 0 || timing.vActive == 0 ||
|
||||
mode.refreshMilliHz == 0)
|
||||
mode.refresh100uHz == 0)
|
||||
return false;
|
||||
|
||||
timing.hBlank = std::max<DWORD>(160,
|
||||
@@ -391,11 +393,12 @@ bool CEdid::GetTiming(Timing& timing, const CSettings::DisplayMode& mode)
|
||||
if (timing.vFront + timing.vSync >= timing.vBlank)
|
||||
return false;
|
||||
|
||||
const UINT64 pixelClockMilliHz =
|
||||
const UINT64 pixelClock100uHz =
|
||||
(UINT64)(timing.hActive + timing.hBlank) *
|
||||
(UINT64)(timing.vActive + timing.vBlank) *
|
||||
(UINT64)mode.refreshMilliHz;
|
||||
timing.pixelClock = (pixelClockMilliHz + 500) / 1000;
|
||||
(UINT64)mode.refresh100uHz;
|
||||
timing.pixelClock = (pixelClock100uHz + LG_REFRESH_RATE_SCALE / 2) /
|
||||
LG_REFRESH_RATE_SCALE;
|
||||
return timing.pixelClock != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -564,14 +564,14 @@ bool CPipeServer::SetCursorPos(int32_t x, int32_t y)
|
||||
}
|
||||
|
||||
void CPipeServer::SetDisplayMode(
|
||||
uint32_t width, uint32_t height, uint32_t refreshMilliHz)
|
||||
uint32_t width, uint32_t height, uint32_t refresh100uHz)
|
||||
{
|
||||
LGPipeMsg msg = {};
|
||||
msg.size = sizeof(msg);
|
||||
msg.type = LGPipeMsg::SETDISPLAYMODE;
|
||||
msg.displayMode.width = width;
|
||||
msg.displayMode.height = height;
|
||||
msg.displayMode.refreshMilliHz = refreshMilliHz;
|
||||
msg.displayMode.refresh100uHz = refresh100uHz;
|
||||
WriteMsg(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class CPipeServer : private IPipeEndpointHandler,
|
||||
|
||||
bool SetCursorPos(int32_t x, int32_t y);
|
||||
void SetDisplayMode(
|
||||
uint32_t width, uint32_t height, uint32_t refreshMilliHz);
|
||||
uint32_t width, uint32_t height, uint32_t refresh100uHz);
|
||||
void SetGPUStatus(bool software);
|
||||
void ResolutionRejected(uint32_t width, uint32_t height,
|
||||
uint32_t requiredSizeMiB);
|
||||
|
||||
@@ -26,7 +26,7 @@ struct FrameMode
|
||||
{
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
uint32_t refreshMilliHz = 0;
|
||||
uint32_t refresh100uHz = 0;
|
||||
};
|
||||
|
||||
class FrameCaps
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace
|
||||
const FrameMode& mode, uint64_t& frameSize)
|
||||
{
|
||||
frameSize = 0;
|
||||
if (!mode.width || !mode.height || !mode.refreshMilliHz)
|
||||
if (!mode.width || !mode.height || !mode.refresh100uHz)
|
||||
return false;
|
||||
|
||||
uint64_t pitch;
|
||||
|
||||
Reference in New Issue
Block a user