mirror of
https://github.com/VirtualDrivers/Virtual-Display-Driver.git
synced 2026-12-06 07:01:23 +09:00
Keep configured modes within the IddCx monitor limit
This commit is contained in:
1 parent
6dc32fc013
commit
99ff2c3b5e
1 file changed
+32
-20
@@ -40,6 +40,7 @@ Environment:
|
||||
#include <cwchar>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <numeric>
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <cstddef>
|
||||
@@ -177,19 +178,36 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
void RebuildKnownMonitorModesCache()
|
||||
void SetMonitorModes(const vector<tuple<int, int, int, int>>& candidates)
|
||||
{
|
||||
// IddCx accepts 200 entries across the two lists. We publish each mode in both.
|
||||
constexpr size_t maxModes = 100;
|
||||
set<tuple<int, int, int, int>> seen;
|
||||
monitorModes.clear();
|
||||
for (const auto& mode : candidates) {
|
||||
const auto [width, height, numerator, denominator] = mode;
|
||||
if (width <= 0 || height <= 0 || numerator <= 0 || denominator <= 0) {
|
||||
continue;
|
||||
}
|
||||
const int divisor = std::gcd(numerator, denominator);
|
||||
if (!seen.emplace(width, height, numerator / divisor, denominator / divisor).second) {
|
||||
continue;
|
||||
}
|
||||
if (monitorModes.size() == maxModes) {
|
||||
vddlog("w", "IddCx mode limit reached. Reporting the first 100 distinct modes.");
|
||||
break;
|
||||
}
|
||||
monitorModes.push_back(mode);
|
||||
}
|
||||
if (monitorModes.empty()) {
|
||||
vddlog("w", "No usable display modes configured. Reporting 1920x1080 at 60 Hz.");
|
||||
monitorModes.emplace_back(1920, 1080, 60, 1);
|
||||
}
|
||||
|
||||
s_KnownMonitorModes2.clear();
|
||||
s_KnownMonitorModes2.reserve(monitorModes.size());
|
||||
|
||||
for (const auto& mode : monitorModes)
|
||||
{
|
||||
s_KnownMonitorModes2.push_back(
|
||||
dispinfo(
|
||||
std::get<0>(mode),
|
||||
std::get<1>(mode),
|
||||
std::get<2>(mode),
|
||||
std::get<3>(mode)));
|
||||
for (const auto& [width, height, numerator, denominator] : monitorModes) {
|
||||
s_KnownMonitorModes2.push_back(dispinfo(width, height, numerator, denominator));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1447,8 +1465,7 @@ bool ApplyEdidProfile(const EdidProfileData& profile) {
|
||||
|
||||
// Validate the final mode list
|
||||
if (ValidateModeList(finalModes)) {
|
||||
monitorModes = finalModes;
|
||||
RebuildKnownMonitorModesCache();
|
||||
SetMonitorModes(finalModes);
|
||||
|
||||
stringstream ss;
|
||||
ss << "Enhanced mode management completed:\n"
|
||||
@@ -2810,8 +2827,7 @@ void loadSettings() {
|
||||
|
||||
numVirtualDisplays = monitorcount;
|
||||
gpuname = gpuFriendlyName;
|
||||
monitorModes = res;
|
||||
RebuildKnownMonitorModesCache();
|
||||
SetMonitorModes(res);
|
||||
|
||||
// === APPLY EDID INTEGRATION ===
|
||||
if (edidIntegrationEnabled && autoConfigureFromEdid) {
|
||||
@@ -2852,8 +2868,7 @@ void loadSettings() {
|
||||
}
|
||||
|
||||
vddlog("i", "Using option.txt");
|
||||
monitorModes = res;
|
||||
RebuildKnownMonitorModesCache();
|
||||
SetMonitorModes(res);
|
||||
for (const auto& mode : res) {
|
||||
int width, height, vsync_num, vsync_den;
|
||||
tie(width, height, vsync_num, vsync_den) = mode;
|
||||
@@ -2927,8 +2942,7 @@ void loadSettings() {
|
||||
vddlog("d", ss.str().c_str());
|
||||
}
|
||||
|
||||
monitorModes = res;
|
||||
RebuildKnownMonitorModesCache();
|
||||
SetMonitorModes(res);
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -4079,7 +4093,6 @@ NTSTATUS VirtualDisplayDriverParseMonitorDescription(const IDARG_IN_PARSEMONITOR
|
||||
logStream << "Parsing monitor description. Input buffer count: " << pInArgs->MonitorModeBufferInputCount;
|
||||
vddlog("d", logStream.str().c_str());
|
||||
|
||||
RebuildKnownMonitorModesCache();
|
||||
pOutArgs->MonitorModeBufferOutputCount = (UINT)monitorModes.size();
|
||||
|
||||
logStream.str("");
|
||||
@@ -4433,7 +4446,6 @@ NTSTATUS VirtualDisplayDriverEvtIddCxParseMonitorDescription2(
|
||||
}
|
||||
vddlog("d", logStream.str().c_str());
|
||||
|
||||
RebuildKnownMonitorModesCache();
|
||||
pOutArgs->MonitorModeBufferOutputCount = (UINT)monitorModes.size();
|
||||
|
||||
if (pInArgs->MonitorModeBufferInputCount < monitorModes.size())
|
||||
|
||||
Reference in new issue
Block a user