Skip to content

Commit c38992c

Browse files
committed
Settings: show DLSS override version in dropdown/description, and
remove unused mark from DLSS-RR preset E. Tries to parse nvngx_config.txt and find the latest override version, displays it in dropdown. Needs testing with systems that have modified nvngx_config (eg. through updating DLSS override with tools), may release test version for it soon.
1 parent 53ead6e commit c38992c

File tree

5 files changed

+144
-8
lines changed

5 files changed

+144
-8
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.IO;
7+
8+
namespace nspector.Common.Helper
9+
{
10+
public class IniParser
11+
{
12+
public Dictionary<string, Dictionary<string, string>> Data { get; } = new();
13+
14+
public void Load(string filePath)
15+
{
16+
using var reader = new StreamReader(filePath);
17+
string? line;
18+
string? currentSection = null;
19+
20+
while ((line = reader.ReadLine()) != null)
21+
{
22+
line = line.Trim();
23+
24+
// Skip empty lines and comments
25+
if (string.IsNullOrEmpty(line) || line.StartsWith(";") || line.StartsWith("#"))
26+
continue;
27+
28+
// Section
29+
if (line.StartsWith("[") && line.EndsWith("]"))
30+
{
31+
currentSection = line.Substring(1, line.Length - 2).Trim();
32+
if (!Data.ContainsKey(currentSection))
33+
Data[currentSection] = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
34+
}
35+
// Key=Value
36+
else if (currentSection != null && line.Contains('='))
37+
{
38+
int idx = line.IndexOf('=');
39+
var key = line.Substring(0, idx).Trim();
40+
var value = line.Substring(idx + 1).Trim();
41+
Data[currentSection][key] = value;
42+
}
43+
}
44+
}
45+
46+
public string? GetValue(string section, string key)
47+
{
48+
if (Data.TryGetValue(section, out var sectionDict) &&
49+
sectionDict.TryGetValue(key, out var value))
50+
{
51+
return value;
52+
}
53+
54+
return null;
55+
}
56+
57+
public List<string> GetSections()
58+
{
59+
return Data.Keys.ToList();
60+
}
61+
}
62+
63+
public static class DlssHelper
64+
{
65+
private static Dictionary<string, Version> _ngxVersions = FetchVersions();
66+
67+
// Fetches latest versions installed in C:\ProgramData\NVIDIA\NGX\models\ folder
68+
private static Dictionary<string, Version> FetchVersions()
69+
{
70+
Dictionary<string, Version> versions = new Dictionary<string, Version>();
71+
72+
try
73+
{
74+
string ngxDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"NVIDIA\NGX\models\");
75+
string ngxConfigPath = Path.Combine(ngxDataPath, "nvngx_config.txt");
76+
if (!File.Exists(ngxConfigPath))
77+
return versions;
78+
79+
var ini = new IniParser();
80+
ini.Load(ngxConfigPath);
81+
82+
foreach (string section in ini.GetSections())
83+
{
84+
string versionStr = ini.GetValue(section, "app_E658700");
85+
if (string.IsNullOrEmpty(versionStr))
86+
continue;
87+
88+
Version ver = new Version(versionStr.Trim());
89+
90+
versions[section] = ver;
91+
}
92+
}
93+
catch
94+
{
95+
versions.Clear();
96+
}
97+
98+
return versions;
99+
}
100+
101+
public static string GetSnippetLatestVersion(string snippet)
102+
{
103+
if (!_ngxVersions.ContainsKey(snippet))
104+
return "unknown";
105+
return "v" + _ngxVersions[snippet].ToString();
106+
}
107+
108+
public static string ReplaceDlssVersions(string str)
109+
{
110+
if (string.IsNullOrEmpty(str))
111+
return str;
112+
113+
if (str.Contains("${DlssVersion}"))
114+
str = str.Replace("${DlssVersion}", DlssHelper.GetSnippetLatestVersion("dlss").ToString());
115+
116+
if (str.Contains("${DlssgVersion}"))
117+
str = str.Replace("${DlssgVersion}", DlssHelper.GetSnippetLatestVersion("dlssg").ToString());
118+
119+
if (str.Contains("${DlssdVersion}"))
120+
str = str.Replace("${DlssdVersion}", DlssHelper.GetSnippetLatestVersion("dlssd").ToString());
121+
122+
return str;
123+
}
124+
}
125+
}

nspector/Common/Meta/CustomSettingMetaService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Linq;
6+
using nspector.Common.Helper;
67

78
namespace nspector.Common.Meta
89
{
@@ -42,13 +43,19 @@ public CustomSettingMetaService(CustomSettingNames customSettings, SettingMetaSo
4243
}
4344
}
4445

46+
private string ProcessNameReplacements(string friendlyName)
47+
{
48+
// Apply string version replacements here before settings are fully loaded, so that string-to-value mappings can be preserved
49+
return DlssHelper.ReplaceDlssVersions(friendlyName);
50+
}
51+
4552
public string GetSettingName(uint settingId)
4653
{
4754
var setting = customSettings.Settings
4855
.FirstOrDefault(x => x.SettingId.Equals(settingId));
4956

5057
if (setting != null)
51-
return setting.UserfriendlyName;
58+
return ProcessNameReplacements(setting.UserfriendlyName);
5259

5360
return null;
5461
}
@@ -86,7 +93,7 @@ public List<SettingValue<uint>> GetDwordValues(uint settingId)
8693
{
8794
ValuePos = i++,
8895
Value = x.SettingValue,
89-
ValueName = _source == SettingMetaSource.CustomSettings ? x.UserfriendlyName : DrsUtil.GetDwordString(x.SettingValue) + " " + x.UserfriendlyName,
96+
ValueName = _source == SettingMetaSource.CustomSettings ? ProcessNameReplacements(x.UserfriendlyName) : DrsUtil.GetDwordString(x.SettingValue) + " " + ProcessNameReplacements(x.UserfriendlyName),
9097
}).ToList();
9198
}
9299

nspector/CustomSettingNames.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
<HexSettingID>0x10E41E01</HexSettingID>
77
<GroupName>5 - Common</GroupName>
88
<MinRequiredDriverVersion>0</MinRequiredDriverVersion>
9+
<Description>If enabled, overrides DLSS with the latest global version installed (${DlssVersion}).\r\nNVIDIA periodically push OTA updates for the global version, though it often lags behind the actual latest available online.\r\nOnly DLSS2+ games support the global override, certain games may also disallow using it.</Description>
910
<SettingValues>
1011
<CustomSettingValue>
1112
<UserfriendlyName>Off</UserfriendlyName>
1213
<HexValue>0x00000000</HexValue>
1314
</CustomSettingValue>
1415
<CustomSettingValue>
15-
<UserfriendlyName>On - DLSS overridden by latest available</UserfriendlyName>
16+
<UserfriendlyName>On - DLSS overridden by latest installed (${DlssVersion})</UserfriendlyName>
1617
<HexValue>0x00000001</HexValue>
1718
</CustomSettingValue>
1819
</SettingValues>
@@ -23,13 +24,14 @@
2324
<HexSettingID>0x10E41E02</HexSettingID>
2425
<GroupName>5 - Common</GroupName>
2526
<MinRequiredDriverVersion>0</MinRequiredDriverVersion>
27+
<Description>If enabled, overrides DLSS-RR with the latest global version installed (${DlssdVersion}).\r\nNVIDIA periodically push OTA updates for the global version, though it often lags behind the actual latest available online.\r\nOnly DLSS2+ games support the global override, certain games may also disallow using it.</Description>
2628
<SettingValues>
2729
<CustomSettingValue>
2830
<UserfriendlyName>Off</UserfriendlyName>
2931
<HexValue>0x00000000</HexValue>
3032
</CustomSettingValue>
3133
<CustomSettingValue>
32-
<UserfriendlyName>On - DLSS-RR overridden by latest available</UserfriendlyName>
34+
<UserfriendlyName>On - DLSS-RR overridden by latest installed (${DlssdVersion})</UserfriendlyName>
3335
<HexValue>0x00000001</HexValue>
3436
</CustomSettingValue>
3537
</SettingValues>
@@ -40,13 +42,14 @@
4042
<HexSettingID>0x10E41E03</HexSettingID>
4143
<GroupName>5 - Common</GroupName>
4244
<MinRequiredDriverVersion>0</MinRequiredDriverVersion>
45+
<Description>If enabled, overrides DLSS-FG with the latest global version installed (${DlssgVersion}).\r\nNVIDIA periodically push OTA updates for the global version, though it often lags behind the actual latest available online.\r\nOnly DLSS2+ games support the global override, certain games may also disallow using it.</Description>
4346
<SettingValues>
4447
<CustomSettingValue>
4548
<UserfriendlyName>Off</UserfriendlyName>
4649
<HexValue>0x00000000</HexValue>
4750
</CustomSettingValue>
4851
<CustomSettingValue>
49-
<UserfriendlyName>On - DLSS-FG overridden by latest available</UserfriendlyName>
52+
<UserfriendlyName>On - DLSS-FG overridden by latest installed (${DlssgVersion})</UserfriendlyName>
5053
<HexValue>0x00000001</HexValue>
5154
</CustomSettingValue>
5255
</SettingValues>
@@ -156,7 +159,7 @@
156159
<HexValue>0x00000004</HexValue>
157160
</CustomSettingValue>
158161
<CustomSettingValue>
159-
<UserfriendlyName>Preset E (unused)</UserfriendlyName>
162+
<UserfriendlyName>Preset E</UserfriendlyName>
160163
<HexValue>0x00000005</HexValue>
161164
</CustomSettingValue>
162165
<CustomSettingValue>

nspector/frmDrvSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ private void MoveComboToItemAndFill()
301301

302302
var referenceSettings = DrsServiceLocator.ReferenceSettings?.Settings.FirstOrDefault(s => s.SettingId == settingid);
303303

304-
var description = settingMeta.Description;
304+
var description = DlssHelper.ReplaceDlssVersions(settingMeta.Description);
305305
if (!string.IsNullOrEmpty(settingMeta.AlternateNames))
306306
description = $"Alternate names: {settingMeta.AlternateNames}\r\n{description}";
307307

@@ -313,7 +313,7 @@ private void MoveComboToItemAndFill()
313313
}
314314
else
315315
{
316-
tbSettingDescription.Text = description;
316+
tbSettingDescription.Text = description.Replace("\\r\\n", "\r\n");
317317
tbSettingDescription.Visible = true;
318318
tbSettingDescription.BackColor = (referenceSettings?.HasConstraints ?? false) ? Color.LightCoral : SystemColors.Control;
319319
}

nspector/nvidiaProfileInspector.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
<Compile Include="Common\DrsSessionScope.cs" />
137137
<Compile Include="Common\DrsSettingsMetaService.cs" />
138138
<Compile Include="Common\DrsUtil.cs" />
139+
<Compile Include="Common\Helper\DlssHelper.cs" />
139140
<Compile Include="Common\Helper\DropDownMenuScrollWheelHandler.cs" />
140141
<Compile Include="Common\Helper\GithubVersionHelper.cs" />
141142
<Compile Include="Common\Helper\ListViewGroupSorter.cs" />

0 commit comments

Comments
 (0)