Skip to content

Commit

Permalink
'Raytracing - (Vulkan RT) enabled' setting added
Browse files Browse the repository at this point in the history
added support for descriptions in CSN
added setting name filter (CTRL + F) revert with ESCAPE
added devmode view (CTRL + ALT + D)
and some fixes
  • Loading branch information
Orbmu2k committed Nov 19, 2022
1 parent 3f1d636 commit 76e5d34
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 221 deletions.
2 changes: 2 additions & 0 deletions nspector/Common/CustomSettings/CustomSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class CustomSetting
public string OverrideDefault { get; set; }
public float MinRequiredDriverVersion { get; set; }
public bool Hidden { get; set; }
public bool HasConstraints { get; set; }
public string DataType { get; set; }

public List<CustomSettingValue> SettingValues { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions nspector/Common/DrsScannerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ public async Task ScanProfileSettingsAsync(bool justModified, IProgress<int> pro

private void AddScannedSettingToCache(NVDRS_PROFILE profile, NVDRS_SETTING setting)
{
// Skip 3D Vision string values here for improved scan performance
bool allowAddValue = setting.settingId < 0x70000000 || setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;

// 3D Vision is dead so dont bother scanning those values for improved scan performance
bool allowAddValue = !((setting.settingId & 0x70000000) == 0x70000000);
//bool allowAddValue = true;

var cachedSetting = CachedSettings
Expand All @@ -186,6 +185,7 @@ private void AddScannedSettingToCache(NVDRS_PROFILE profile, NVDRS_SETTING setti
cachedSetting.AddDwordValue(setting.predefinedValue.dwordValue, profile.profileName);
else if (setting.settingType == NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE)
cachedSetting.AddBinaryValue(setting.predefinedValue.binaryValue, profile.profileName);

}
else
cachedSetting.ProfileCount++;
Expand Down
13 changes: 13 additions & 0 deletions nspector/Common/DrsSettingsMetaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ private SettingMeta CreateSettingMeta(uint settingId)

IsApiExposed = GetIsApiExposed(settingId),
IsSettingHidden = GetIsSettingHidden(settingId),
Description = GetDescription(settingId),

DefaultDwordValue =
settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE
Expand Down Expand Up @@ -352,6 +353,7 @@ private SettingMeta PostProcessMeta(uint settingId, SettingMeta settingMeta, Set
GroupName = settingMeta.GroupName,
IsApiExposed = settingMeta.IsApiExposed,
IsSettingHidden = settingMeta.IsSettingHidden,
Description = settingMeta.Description,
};

if (string.IsNullOrEmpty(newMeta.SettingName))
Expand Down Expand Up @@ -421,5 +423,16 @@ private bool GetIsSettingHidden(uint settingId)
var csnMeta = MetaServices.FirstOrDefault(m => m.Service.Source == SettingMetaSource.CustomSettings);
return (csnMeta != null && ((CustomSettingMetaService)csnMeta.Service).IsSettingHidden(settingId));
}

private string GetDescription(uint settingId)
{
var csn = MetaServices.FirstOrDefault(m => m.Service.Source == SettingMetaSource.CustomSettings);
var csnDescription = csn != null ? ((CustomSettingMetaService)csn.Service).GetDescription(settingId) ?? "" : "";

var refs = MetaServices.FirstOrDefault(m => m.Service.Source == SettingMetaSource.ReferenceSettings);
var refsDescription = refs != null ? ((CustomSettingMetaService)refs.Service).GetDescription(settingId) ?? "" : "";

return !string.IsNullOrEmpty(csnDescription) ? csnDescription : refsDescription;
}
}
}
33 changes: 33 additions & 0 deletions nspector/Common/DrsSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,39 @@ public void ResetValue(string profileName, uint settingId, out bool removeFromMo
removeFromModified = tmpRemoveFromModified;
}

public void DeleteValue(string profileName, uint settingId, out bool removeFromModified)
{
var tmpRemoveFromModified = false;

DrsSession((hSession) =>
{
var hProfile = GetProfileHandle(hSession, profileName);
if (hProfile != IntPtr.Zero)
{
int dropCount = 0;
var settings = GetProfileSettings(hSession, hProfile);
foreach (var setting in settings)
{
if (setting.settingId != settingId) continue;
if (setting.settingLocation == NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION)
{
if (nvw.DRS_DeleteProfileSetting(hSession, hProfile, setting.settingId) == NvAPI_Status.NVAPI_OK)
{
dropCount++;
break;
}
}
}
tmpRemoveFromModified = (dropCount == 0);
SaveSettings(hSession);
}
});

removeFromModified = tmpRemoveFromModified;
}

public uint GetDwordValueFromProfile(string profileName, uint settingId, bool returnDefaultValue = false, bool forceDedicatedScope = false)
{
return DrsSession((hSession) =>
Expand Down
2 changes: 1 addition & 1 deletion nspector/Common/DrsUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal static string GetDwordSettingValueName(SettingMeta meta, uint dwordValu

internal static string ParseStringSettingValue(SettingMeta meta, string text)
{
var valueByName = meta.StringValues.FirstOrDefault(x => x.ValueName != null && x.ValueName.Equals(text));
var valueByName = meta.StringValues?.FirstOrDefault(x => x.ValueName != null && x.ValueName.Equals(text));
if (valueByName != null)
return valueByName.Value;

Expand Down
30 changes: 29 additions & 1 deletion nspector/Common/Meta/CustomSettingMetaService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using nspector.Common.CustomSettings;
using nspector.Native.NVAPI2;
using System;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -19,7 +20,26 @@ public CustomSettingMetaService(CustomSettingNames customSettings, SettingMetaSo

public NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId)
{
return null;
var setting = customSettings.Settings
.FirstOrDefault(x => x.SettingId.Equals(settingId));

return MapType(setting?.DataType);
}

private NVDRS_SETTING_TYPE? MapType(string type)
{
if (string.IsNullOrEmpty(type)) return null;

switch(type.ToLower())
{
case "dword":
return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
case "string":
return NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE;
case "binary":
return NVDRS_SETTING_TYPE.NVDRS_BINARY_TYPE;
default: throw new ArgumentOutOfRangeException(type);
}
}

public string GetSettingName(uint settingId)
Expand Down Expand Up @@ -109,6 +129,14 @@ public bool IsSettingHidden(uint settingId)
return setting?.Hidden ?? false;
}

public string GetDescription(uint settingId)
{
var setting = customSettings.Settings
.FirstOrDefault(x => x.SettingId.Equals(settingId));

return setting?.Description;
}

public SettingMetaSource Source
{
get { return _source; }
Expand Down
2 changes: 2 additions & 0 deletions nspector/Common/Meta/SettingMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ internal class SettingMeta

public bool IsSettingHidden { get; set; }

public string Description { get; set; }

public List<SettingValue<string>> StringValues { get; set; }

public List<SettingValue<uint>> DwordValues { get; set; }
Expand Down

0 comments on commit 76e5d34

Please sign in to comment.