mirror of
https://github.com/Orbmu2k/nvidiaProfileInspector.git
synced 2025-12-31 10:58:10 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce1f79fd76 | ||
|
|
d5f993b63a | ||
|
|
6e0c64bf42 | ||
|
|
1f1841cb9f | ||
|
|
ef00e39885 |
@@ -15,12 +15,18 @@ namespace nspector.Common
|
||||
|
||||
private readonly DrsSettingsService _SettingService;
|
||||
private readonly DrsScannerService _ScannerService;
|
||||
private readonly DrsDecrypterService _DecrypterService;
|
||||
|
||||
public DrsImportService(DrsSettingsMetaService metaService, DrsSettingsService settingService, DrsScannerService scannerService)
|
||||
public DrsImportService(
|
||||
DrsSettingsMetaService metaService,
|
||||
DrsSettingsService settingService,
|
||||
DrsScannerService scannerService,
|
||||
DrsDecrypterService decrypterService)
|
||||
: base(metaService)
|
||||
{
|
||||
_SettingService = settingService;
|
||||
_ScannerService = scannerService;
|
||||
_DecrypterService = decrypterService;
|
||||
}
|
||||
|
||||
internal void ExportAllProfilesToNvidiaTextFile(string filename)
|
||||
@@ -76,22 +82,18 @@ namespace nspector.Common
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
var isPredefined = setting.isCurrentPredefined == 1;
|
||||
var isDwordSetting = setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
|
||||
var isCurrentProfile = setting.settingLocation ==
|
||||
NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION;
|
||||
|
||||
if (isDwordSetting && isCurrentProfile)
|
||||
if (isCurrentProfile && (!isPredefined || includePredefined))
|
||||
{
|
||||
if (!isPredefined || includePredefined)
|
||||
{
|
||||
var profileSetting = new ProfileSetting()
|
||||
{
|
||||
SettingNameInfo = setting.settingName,
|
||||
SettingId = setting.settingId,
|
||||
SettingValue = setting.currentValue.dwordValue,
|
||||
};
|
||||
result.Settings.Add(profileSetting);
|
||||
}
|
||||
var exportSetting = setting;
|
||||
_DecrypterService.DecryptSettingIfNeeded(profileName, ref exportSetting);
|
||||
|
||||
var profileSetting = ImportExportUitl
|
||||
.ConvertDrsSettingToProfileSetting(exportSetting);
|
||||
|
||||
result.Settings.Add(profileSetting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +128,7 @@ namespace nspector.Common
|
||||
try
|
||||
{
|
||||
UpdateApplications(hSession, hProfile, profile);
|
||||
UpdateSettings(hSession, hProfile, profile);
|
||||
UpdateSettings(hSession, hProfile, profile, profile.ProfileName);
|
||||
}
|
||||
catch (NvapiException nex)
|
||||
{
|
||||
@@ -202,18 +204,24 @@ namespace nspector.Common
|
||||
.FirstOrDefault(x => x.SettingId.Equals(settingId));
|
||||
|
||||
if (setting != null)
|
||||
return setting.SettingValue;
|
||||
return uint.Parse(setting.SettingValue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private ProfileSetting GetImportProfileSetting(uint settingId, Profile importProfile)
|
||||
{
|
||||
return importProfile.Settings
|
||||
.FirstOrDefault(x => x.SettingId.Equals(settingId));
|
||||
}
|
||||
|
||||
private bool ExistsImportValue(uint settingId, Profile importProfile)
|
||||
{
|
||||
return importProfile.Settings
|
||||
.Any(x => x.SettingId.Equals(settingId));
|
||||
}
|
||||
|
||||
private void UpdateSettings(IntPtr hSession, IntPtr hProfile, Profile importProfile)
|
||||
private void UpdateSettings(IntPtr hSession, IntPtr hProfile, Profile importProfile, string profileName)
|
||||
{
|
||||
var alreadySet = new HashSet<uint>();
|
||||
|
||||
@@ -221,20 +229,24 @@ namespace nspector.Common
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
var isCurrentProfile = setting.settingLocation == NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION;
|
||||
var isDwordSetting = setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
|
||||
var isPredefined = setting.isCurrentPredefined == 1;
|
||||
|
||||
if (isCurrentProfile && isDwordSetting)
|
||||
if (isCurrentProfile)
|
||||
{
|
||||
bool exitsValue = ExistsImportValue(setting.settingId, importProfile);
|
||||
uint importValue = GetImportValue(setting.settingId, importProfile);
|
||||
if (isPredefined && exitsValue && importValue == setting.currentValue.dwordValue)
|
||||
bool exitsValueInImport = ExistsImportValue(setting.settingId, importProfile);
|
||||
var importSetting = GetImportProfileSetting(setting.settingId, importProfile);
|
||||
|
||||
var decryptedSetting = setting;
|
||||
_DecrypterService.DecryptSettingIfNeeded(profileName, ref decryptedSetting);
|
||||
|
||||
if (isPredefined && exitsValueInImport && ImportExportUitl.AreDrsSettingEqualToProfileSetting(decryptedSetting, importSetting))
|
||||
{
|
||||
alreadySet.Add(setting.settingId);
|
||||
}
|
||||
else if (exitsValue)
|
||||
else if (exitsValueInImport)
|
||||
{
|
||||
StoreDwordValue(hSession, hProfile, setting.settingId, importValue);
|
||||
var updatedSetting = ImportExportUitl.ConvertProfileSettingToDrsSetting(importSetting);
|
||||
StoreSetting(hSession, hProfile, updatedSetting);
|
||||
alreadySet.Add(setting.settingId);
|
||||
}
|
||||
else if (!isPredefined)
|
||||
@@ -248,7 +260,8 @@ namespace nspector.Common
|
||||
{
|
||||
if (!alreadySet.Contains(setting.SettingId))
|
||||
{
|
||||
StoreDwordValue(hSession, hProfile, setting.SettingId, setting.SettingValue);
|
||||
var newSetting = ImportExportUitl.ConvertProfileSettingToDrsSetting(setting);
|
||||
StoreSetting(hSession, hProfile, newSetting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace nspector.Common
|
||||
DecrypterService = new DrsDecrypterService(MetaService);
|
||||
ScannerService = new DrsScannerService(MetaService, DecrypterService);
|
||||
SettingService = new DrsSettingsService(MetaService, DecrypterService);
|
||||
ImportService = new DrsImportService(MetaService, SettingService, ScannerService);
|
||||
ImportService = new DrsImportService(MetaService, SettingService, ScannerService, DecrypterService);
|
||||
}
|
||||
|
||||
private static CustomSettingNames LoadCustomSettings()
|
||||
|
||||
@@ -115,6 +115,13 @@ namespace nspector.Common
|
||||
return tmpProfile;
|
||||
}
|
||||
|
||||
protected void StoreSetting(IntPtr hSession, IntPtr hProfile, NVDRS_SETTING newSetting)
|
||||
{
|
||||
var ssRes = nvw.DRS_SetSetting(hSession, hProfile, ref newSetting);
|
||||
if (ssRes != NvAPI_Status.NVAPI_OK)
|
||||
throw new NvapiException("DRS_SetSetting", ssRes);
|
||||
}
|
||||
|
||||
protected void StoreDwordValue(IntPtr hSession, IntPtr hProfile, uint settingId, uint dwordValue)
|
||||
{
|
||||
var newSetting = new NVDRS_SETTING()
|
||||
|
||||
110
nspector/Common/Import/ImportExportUitl.cs
Normal file
110
nspector/Common/Import/ImportExportUitl.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using nspector.Native.NVAPI2;
|
||||
|
||||
namespace nspector.Common.Import
|
||||
{
|
||||
internal class ImportExportUitl
|
||||
{
|
||||
public static bool AreDrsSettingEqualToProfileSetting(NVDRS_SETTING drsSetting, ProfileSetting profileSetting)
|
||||
{
|
||||
var profileSettingCompare = ConvertDrsSettingToProfileSetting(drsSetting);
|
||||
return profileSetting.SettingValue.Equals(profileSettingCompare.SettingValue);
|
||||
}
|
||||
|
||||
public static ProfileSetting ConvertDrsSettingToProfileSetting(NVDRS_SETTING setting)
|
||||
{
|
||||
return new ProfileSetting
|
||||
{
|
||||
SettingId = setting.settingId,
|
||||
SettingNameInfo = setting.settingName,
|
||||
SettingValue = ConvertSettingValueToString(setting),
|
||||
ValueType = MapValueType(setting.settingType),
|
||||
};
|
||||
}
|
||||
|
||||
private static string ConvertSettingValueToString(NVDRS_SETTING setting)
|
||||
{
|
||||
var settingUnion = setting.currentValue;
|
||||
if (setting.isCurrentPredefined == 1)
|
||||
{
|
||||
settingUnion = setting.predefinedValue;
|
||||
}
|
||||
|
||||
switch (setting.settingType)
|
||||
{
|
||||
case NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE:
|
||||
return settingUnion.dwordValue.ToString();
|
||||
case NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE:
|
||||
return settingUnion.ansiStringValue;
|
||||
case NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE:
|
||||
return settingUnion.stringValue;
|
||||
case NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE:
|
||||
return Convert.ToBase64String(settingUnion.binaryValue);
|
||||
default:
|
||||
throw new Exception("invalid setting type");
|
||||
}
|
||||
}
|
||||
|
||||
private static SettingValueType MapValueType(NVDRS_SETTING_TYPE input)
|
||||
{
|
||||
switch (input)
|
||||
{
|
||||
case NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE: return SettingValueType.Binary;
|
||||
case NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE: return SettingValueType.AnsiString;
|
||||
case NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE: return SettingValueType.String;
|
||||
default: return SettingValueType.Dword;
|
||||
}
|
||||
}
|
||||
|
||||
public static NVDRS_SETTING ConvertProfileSettingToDrsSetting(ProfileSetting setting)
|
||||
{
|
||||
var newSetting = new NVDRS_SETTING()
|
||||
{
|
||||
version = NvapiDrsWrapper.NVDRS_SETTING_VER,
|
||||
settingId = setting.SettingId,
|
||||
settingType = MapValueType(setting.ValueType),
|
||||
settingLocation = NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION,
|
||||
currentValue = ConvertStringToSettingUnion(setting.ValueType, setting.SettingValue),
|
||||
};
|
||||
return newSetting;
|
||||
}
|
||||
|
||||
private static NVDRS_SETTING_UNION ConvertStringToSettingUnion(SettingValueType valueType, string valueString)
|
||||
{
|
||||
var union = new NVDRS_SETTING_UNION();
|
||||
switch (valueType)
|
||||
{
|
||||
case SettingValueType.Dword:
|
||||
union.dwordValue = uint.Parse(valueString);
|
||||
break;
|
||||
case SettingValueType.String:
|
||||
union.stringValue = valueString;
|
||||
break;
|
||||
case SettingValueType.AnsiString:
|
||||
union.ansiStringValue = valueString;
|
||||
break;
|
||||
case SettingValueType.Binary:
|
||||
union.binaryValue = Convert.FromBase64String(valueString);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("invalid value type");
|
||||
}
|
||||
return union;
|
||||
}
|
||||
|
||||
private static NVDRS_SETTING_TYPE MapValueType(SettingValueType input)
|
||||
{
|
||||
switch (input)
|
||||
{
|
||||
case SettingValueType.Binary: return NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE;
|
||||
case SettingValueType.AnsiString: return NVDRS_SETTING_TYPE.NVDRS_STRING_TYPE;
|
||||
case SettingValueType.String: return NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE;
|
||||
default: return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ namespace nspector.Common.Import
|
||||
[XmlElement(ElementName = "SettingID")]
|
||||
public uint SettingId = 0;
|
||||
|
||||
public uint SettingValue = 0;
|
||||
public string SettingValue = "0";
|
||||
|
||||
public SettingValueType ValueType = SettingValueType.Dword;
|
||||
}
|
||||
}
|
||||
10
nspector/Common/Import/SettingValueType.cs
Normal file
10
nspector/Common/Import/SettingValueType.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace nspector.Common.Import
|
||||
{
|
||||
public enum SettingValueType: int
|
||||
{
|
||||
Dword,
|
||||
AnsiString,
|
||||
String,
|
||||
Binary
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,23 @@
|
||||
<CustomSettingNames>
|
||||
<ShowCustomizedSettingNamesOnly>false</ShowCustomizedSettingNamesOnly>
|
||||
<Settings>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>Anisotropic filtering HQ Fix</UserfriendlyName>
|
||||
<HexSettingID>0X00CE2692</HexSettingID>
|
||||
<GroupName>4 - Texture Filtering</GroupName>
|
||||
<MinRequiredDriverVersion>418.00</MinRequiredDriverVersion>
|
||||
<SettingValues>
|
||||
<CustomSettingValue>
|
||||
<UserfriendlyName>Off</UserfriendlyName>
|
||||
<HexValue>0x00000000</HexValue>
|
||||
</CustomSettingValue>
|
||||
<CustomSettingValue>
|
||||
<UserfriendlyName>On</UserfriendlyName>
|
||||
<HexValue>0x00000001</HexValue>
|
||||
</CustomSettingValue>
|
||||
</SettingValues>
|
||||
<SettingMasks />
|
||||
</CustomSetting>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>Enable Maxwell sample interleaving (MFAA)</UserfriendlyName>
|
||||
<HexSettingID>0x0098C1AC</HexSettingID>
|
||||
@@ -1941,6 +1958,13 @@
|
||||
</SettingValues>
|
||||
<SettingMasks />
|
||||
</CustomSetting>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>SLI compatibility bits (OGL)</UserfriendlyName>
|
||||
<HexSettingID>0x209746C1</HexSettingID>
|
||||
<Description />
|
||||
<GroupName>1 - Compatibility</GroupName>
|
||||
<SettingValues />
|
||||
</CustomSetting>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>SLI compatibility bits (DX12)</UserfriendlyName>
|
||||
<HexSettingID>0x00A04746</HexSettingID>
|
||||
@@ -2686,6 +2710,23 @@
|
||||
</SettingValues>
|
||||
<SettingMasks />
|
||||
</CustomSetting>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>Optimize for Compute Performance</UserfriendlyName>
|
||||
<HexSettingID>0x10C158AD</HexSettingID>
|
||||
<Description />
|
||||
<GroupName>5 - Common</GroupName>
|
||||
<SettingValues>
|
||||
<CustomSettingValue>
|
||||
<UserfriendlyName>Off</UserfriendlyName>
|
||||
<HexValue>0x00000000</HexValue>
|
||||
</CustomSettingValue>
|
||||
<CustomSettingValue>
|
||||
<UserfriendlyName>On</UserfriendlyName>
|
||||
<HexValue>0x00000001</HexValue>
|
||||
</CustomSettingValue>
|
||||
</SettingValues>
|
||||
<SettingMasks />
|
||||
</CustomSetting>
|
||||
<CustomSetting>
|
||||
<UserfriendlyName>Extension limit</UserfriendlyName>
|
||||
<HexSettingID>0x20FF7493</HexSettingID>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -270,7 +270,7 @@ namespace nspector.Native.NVAPI2
|
||||
{
|
||||
get
|
||||
{
|
||||
return Encoding.Unicode.GetString(rawData).Trim('\0');
|
||||
return Encoding.Unicode.GetString(rawData).Split(new[] { '\0' }, 2)[0];
|
||||
}
|
||||
|
||||
set
|
||||
@@ -281,6 +281,21 @@ namespace nspector.Native.NVAPI2
|
||||
}
|
||||
}
|
||||
|
||||
public string ansiStringValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return Encoding.Default.GetString(rawData).Split(new[] { '\0' }, 2)[0];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
rawData = new byte[4100];
|
||||
var bytesRaw = Encoding.Default.GetBytes(value);
|
||||
Buffer.BlockCopy(bytesRaw, 0, rawData, 0, bytesRaw.Length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Unicode)]
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NVIDIA Profile Inspector")]
|
||||
[assembly: AssemblyCopyright("©2017 by Orbmu2k")]
|
||||
[assembly: AssemblyCopyright("©2019 by Orbmu2k")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.1.3.0")]
|
||||
[assembly: AssemblyFileVersion("2.1.3.0")]
|
||||
[assembly: AssemblyVersion("2.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.2.0.0")]
|
||||
|
||||
|
||||
|
||||
1
nspector/frmDrvSettings.Designer.cs
generated
1
nspector/frmDrvSettings.Designer.cs
generated
@@ -514,6 +514,7 @@
|
||||
this.lvSettings.ColumnWidthChanging += new System.Windows.Forms.ColumnWidthChangingEventHandler(this.lvSettings_ColumnWidthChanging);
|
||||
this.lvSettings.SelectedIndexChanged += new System.EventHandler(this.lvSettings_SelectedIndexChanged);
|
||||
this.lvSettings.DoubleClick += new System.EventHandler(this.lvSettings_DoubleClick);
|
||||
this.lvSettings.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvSettings_KeyDown);
|
||||
this.lvSettings.Resize += new System.EventHandler(this.lvSettings_Resize);
|
||||
//
|
||||
// chSettingID
|
||||
|
||||
@@ -1215,6 +1215,11 @@ namespace nspector
|
||||
Clipboard.SetText(string.Format($"0x{settingId:X8} {settingName}"));
|
||||
}
|
||||
}
|
||||
|
||||
private void lvSettings_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,8 @@
|
||||
<Compile Include="Common\Helper\ListViewGroupSorter.cs" />
|
||||
<Compile Include="Common\Helper\ShortcutResolver.cs" />
|
||||
<Compile Include="Common\Helper\SteamAppResolver.cs" />
|
||||
<Compile Include="Common\Import\ImportExportUitl.cs" />
|
||||
<Compile Include="Common\Import\SettingValueType.cs" />
|
||||
<Compile Include="Common\Meta\NvD3dUmxSettingMetaService.cs" />
|
||||
<Compile Include="Common\Meta\MetaServiceItem.cs" />
|
||||
<Compile Include="Common\Meta\ConstantSettingMetaService.cs" />
|
||||
|
||||
Reference in New Issue
Block a user