Compare commits

..

4 Commits

Author SHA1 Message Date
Orbmu2k
6d3237bfeb unified scan to a single run for better startup time #41 2020-01-12 14:20:22 +01:00
Orbmu2k
5dbb8ef721 fixed profiles counter for 3d vision settings 2020-01-12 00:36:00 +01:00
Orbmu2k
fcd9ef5346 merge 2020-01-11 13:46:18 +01:00
Orbmu2k
67bb397b6a fixed readme 2020-01-11 13:42:52 +01:00
4 changed files with 33 additions and 89 deletions

View File

@@ -8,4 +8,4 @@ For more information how to use this tool, you can find some very good wikis her
* https://wiki.step-project.com/Guide:NVIDIA_Inspector
* https://www.pcgamingwiki.com/wiki/Nvidia_Profile_Inspector
![screenshot](/npi_screenhshot.png)
![](npi_screenshot.png)

View File

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 109 KiB

View File

@@ -63,7 +63,7 @@ namespace nspector.Common
checkedSettingsCount++;
AddScannedSettingToCache(profile, setting);
alreadyCheckedSettingIds.Add(setting.settingId);
return true;
return (setting.isCurrentPredefined != 1);
}
else if (setting.isCurrentPredefined != 1)
{
@@ -79,11 +79,10 @@ namespace nspector.Common
return (current > 0) ? (int)Math.Round((current * 100f) / max) : 0; ;
}
public async Task ScanForModifiedProfilesAsync(IProgress<int> progress, CancellationToken token = default(CancellationToken))
public async Task ScanProfileSettingsAsync(bool justModified, IProgress<int> progress, CancellationToken token = default(CancellationToken))
{
await Task.Run(() =>
{
ModifiedProfiles = new List<string>();
UserProfiles = new HashSet<string>();
var knownPredefines = new List<uint>(_commonSettingIds);
@@ -105,97 +104,28 @@ namespace nspector.Common
var profile = GetProfileInfo(hSession, hProfile);
int checkedSettingsCount = 0;
bool foundModifiedProfile = false;
var alreadyChecked = new List<uint>();
bool foundModifiedProfile = false;
if (profile.isPredefined == 0)
{
ModifiedProfiles.Add(profile.profileName);
UserProfiles.Add(profile.profileName);
continue;
foundModifiedProfile = true;
}
if ((hBaseProfile == hProfile || profile.numOfApps > 0) && profile.numOfSettings > 0)
{
var alreadyChecked = new List<uint>();
foreach (uint settingId in knownPredefines)
{
if (CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, settingId, false, ref alreadyChecked))
{
foundModifiedProfile = true;
ModifiedProfiles.Add(profile.profileName);
break;
}
}
// the detection if only applications has changed in a profile makes the scan process very slow, we leave it out!
//if (!foundModifiedProfile && profile.numOfApps > 0)
//{
// var apps = GetProfileApplications(hSession, hProfile);
// foreach (var app in apps)
// {
// if (app.isPredefined == 0)
// {
// foundModifiedProfile = true;
// ModifiedProfiles.Add(profile.profileName);
// break;
// }
// }
//}
if (foundModifiedProfile || checkedSettingsCount >= profile.numOfSettings)
continue;
var settings = GetProfileSettings(hSession, hProfile);
foreach (var setting in settings)
{
if (knownPredefines.IndexOf(setting.settingId) < 0)
knownPredefines.Add(setting.settingId);
if (setting.isCurrentPredefined != 1)
{
ModifiedProfiles.Add(profile.profileName);
break;
}
}
}
}
});
});
}
public async Task ScanForPredefinedProfileSettingsAsync(IProgress<int> progress, CancellationToken token = default(CancellationToken))
{
await Task.Run(() =>
{
var knownPredefines = new List<uint>(_commonSettingIds);
DrsSession((hSession) =>
{
var profileHandles = EnumProfileHandles(hSession);
var maxProfileCount = profileHandles.Count;
int curProfilePos = 0;
foreach (IntPtr hProfile in profileHandles)
{
if (token.IsCancellationRequested) break;
progress?.Report(CalcPercent(curProfilePos++, maxProfileCount));
var profile = GetProfileInfo(hSession, hProfile);
int checkedSettingsCount = 0;
var alreadyChecked = new List<uint>();
foreach (uint kpd in knownPredefines)
{
CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, kpd, true, ref alreadyChecked);
if (CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, kpd, !justModified, ref alreadyChecked))
{
if (!foundModifiedProfile)
{
foundModifiedProfile = true;
ModifiedProfiles.Add(profile.profileName);
}
}
}
if (checkedSettingsCount >= profile.numOfSettings)
@@ -207,8 +137,17 @@ namespace nspector.Common
if (knownPredefines.IndexOf(setting.settingId) < 0)
knownPredefines.Add(setting.settingId);
if (alreadyChecked.IndexOf(setting.settingId) < 0)
if (!justModified && alreadyChecked.IndexOf(setting.settingId) < 0)
AddScannedSettingToCache(profile, setting);
if (setting.isCurrentPredefined != 1)
{
if (!foundModifiedProfile)
{
foundModifiedProfile = true;
ModifiedProfiles.Add(profile.profileName);
}
}
}
}
});
@@ -245,6 +184,8 @@ namespace nspector.Common
else if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE)
cachedSetting.AddBinaryValue(setting.predefinedValue.binaryValue, profile.profileName);
}
else
cachedSetting.ProfileCount++;
if (!cacheEntryExists)
CachedSettings.Add(cachedSetting);

View File

@@ -699,12 +699,15 @@ namespace nspector
if (scanPredefined && !_alreadyScannedForPredefinedSettings)
{
_alreadyScannedForPredefinedSettings = true;
await _scanner.ScanForPredefinedProfileSettingsAsync(progressHandler, _scannerCancelationTokenSource.Token);
await _scanner.ScanProfileSettingsAsync(false, progressHandler, _scannerCancelationTokenSource.Token);
_meta.ResetMetaCache();
tscbShowScannedUnknownSettings.Enabled = true;
}
await _scanner.ScanForModifiedProfilesAsync(progressHandler, _scannerCancelationTokenSource.Token);
else
{
await _scanner.ScanProfileSettingsAsync(true, progressHandler, _scannerCancelationTokenSource.Token);
}
RefreshModifiesProfilesDropDown();
tsbModifiedProfiles.Enabled = true;