Decompiled source of VRisingDLSS v0.2.0
VRisingDLSS.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using ProjectM.UI; using Stunlock.Core; using Stunlock.Localization; using UnityEngine; using UnityEngine.Experimental.Rendering.RenderGraphModule; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("VRisingDLSS")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c5cf01259cb88b236b0e6be39e46a65a121fbb15")] [assembly: AssemblyProduct("VRisingDLSS")] [assembly: AssemblyTitle("VRisingDLSS")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VRisingDLSS { internal static class DlssBenchmark { private readonly struct Step { public readonly DlssMode Mode; public readonly DlssPreset Preset; public readonly UpscalerChoice Upscaler; public Step(UpscalerChoice upscaler, DlssMode mode, DlssPreset preset = DlssPreset.Auto) { Upscaler = upscaler; Mode = mode; Preset = preset; } } private const float SettleSeconds = 3f; private const float MeasureSeconds = 2f; private const float MillisecondsPerSecond = 1000f; private static readonly Step[] s_Steps = new Step[13] { new Step(UpscalerChoice.DLSS, DlssMode.DLAA, DlssPreset.K), new Step(UpscalerChoice.DLSS, DlssMode.DLAA, DlssPreset.M), new Step(UpscalerChoice.DLSS, DlssMode.DLAA, DlssPreset.L), new Step(UpscalerChoice.DLSS, DlssMode.Quality, DlssPreset.K), new Step(UpscalerChoice.DLSS, DlssMode.Quality, DlssPreset.M), new Step(UpscalerChoice.DLSS, DlssMode.Performance, DlssPreset.K), new Step(UpscalerChoice.DLSS, DlssMode.Performance, DlssPreset.M), new Step(UpscalerChoice.DLSS, DlssMode.UltraPerformance, DlssPreset.L), new Step(UpscalerChoice.FSR, DlssMode.DLAA), new Step(UpscalerChoice.FSR, DlssMode.Quality), new Step(UpscalerChoice.FSR, DlssMode.Performance), new Step(UpscalerChoice.FSR, DlssMode.UltraPerformance), new Step(UpscalerChoice.DLSS, DlssMode.Quality, DlssPreset.K) }; private static int s_Step = -1; private static bool s_Finished; private static float s_StepStart; private static float s_FrameTimeSum; private static int s_FrameCount; private static DlssMode s_OriginalMode; private static DlssPreset s_OriginalPreset; private static UpscalerChoice s_OriginalUpscaler; public static void Tick(DlssSettings settings) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown float value = settings.BenchmarkAfterSeconds.Value; if (value <= 0f || s_Finished) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup < value) { return; } if (s_Step < 0) { s_OriginalMode = settings.Mode.Value; s_OriginalPreset = settings.Preset.Value; s_OriginalUpscaler = settings.Upscaler.Value; s_Step = 0; BeginStep(settings, realtimeSinceStartup); return; } float num = realtimeSinceStartup - s_StepStart; if (num < 3f) { return; } if (num < 5f) { s_FrameTimeSum += Time.unscaledDeltaTime; s_FrameCount++; return; } BridgeStatus status = NativeBridge.GetStatus(); float num2 = ((s_FrameCount > 0) ? (s_FrameTimeSum / (float)s_FrameCount * 1000f) : 0f); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Benchmark: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(status.upscalerName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" mode="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DlssMode>(s_Steps[s_Step].Mode); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" preset="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DlssPreset>(s_Steps[s_Step].Preset); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("render="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(status.renderWidth); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(status.renderHeight); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" gpu="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(status.evaluateGpuMilliseconds, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ms frame="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num2, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ms"); } logger.LogInfo(val); s_Step++; if (s_Step < s_Steps.Length) { BeginStep(settings, realtimeSinceStartup); return; } settings.Mode.Value = s_OriginalMode; settings.Preset.Value = s_OriginalPreset; settings.Upscaler.Value = s_OriginalUpscaler; DlssRuntime.RequestRefresh(); s_Finished = true; Plugin.Logger.LogInfo((object)"Benchmark finished"); } private static void BeginStep(DlssSettings settings, float now) { settings.Mode.Value = s_Steps[s_Step].Mode; settings.Preset.Value = s_Steps[s_Step].Preset; settings.Upscaler.Value = s_Steps[s_Step].Upscaler; DlssRuntime.RequestRefresh(); s_StepStart = now; s_FrameTimeSum = 0f; s_FrameCount = 0; } } internal static class DlssOptionsMenu { private enum Text { Header, Enabled, EnabledDescription, Upscaler, UpscalerDescription, Mode, ModeDescription, Preset, PresetDescription, Overlay, OverlayDescription } private const int TextGuidA = 1448232019; private const int TextGuidB = 1280529237; private const int TextGuidC = 1224736768; private const string PolishLanguageMarker = "Polish"; private static readonly Dictionary<Text, string> s_English = new Dictionary<Text, string> { [Text.Header] = "DLSS / FSR (mod)", [Text.Enabled] = "DLSS / FSR", [Text.EnabledDescription] = "Runs NVIDIA DLSS or AMD FSR instead of the game's anti-aliasing and FSR 1. While this is on, the game's Anti-Aliasing and FSR options have no effect.", [Text.Upscaler] = "Upscaler", [Text.UpscalerDescription] = "Auto uses DLSS on NVIDIA RTX cards and AMD FSR on every other card. FSR works on all graphics cards; on supported Radeon cards the newest FSR version is used.", [Text.Mode] = "Upscaling Mode", [Text.ModeDescription] = "DLAA (Native AA in FSR) renders at native resolution for the best image. The other modes render at a lower resolution and upscale for more performance.", [Text.Preset] = "DLSS Model", [Text.PresetDescription] = "Only applies to DLSS. Auto uses K for DLAA and the DLSS 4.5 models (M, or L for Ultra Performance) for the upscaling modes. K is the DLSS 4 model, L and M are the heavier DLSS 4.5 models.", [Text.Overlay] = "Upscaling Overlay", [Text.OverlayDescription] = "Shows the diagnostic overlay with the current upscaler state and log." }; private static readonly Dictionary<Text, string> s_Polish = new Dictionary<Text, string> { [Text.Header] = "DLSS / FSR (mod)", [Text.Enabled] = "DLSS / FSR", [Text.EnabledDescription] = "Uruchamia NVIDIA DLSS albo AMD FSR zamiast antyaliasingu i FSR 1 z gry. Gdy ta opcja jest włączona, ustawienia Antyaliasing i FSR z gry nie mają wpływu na obraz.", [Text.Upscaler] = "Skaler", [Text.UpscalerDescription] = "Auto używa DLSS na kartach NVIDIA RTX, a AMD FSR na pozostałych. FSR działa na wszystkich kartach graficznych; na obsługiwanych kartach Radeon używana jest najnowsza wersja FSR.", [Text.Mode] = "Tryb skalowania", [Text.ModeDescription] = "DLAA (w FSR: Native AA) renderuje w natywnej rozdzielczości i daje najlepszy obraz. Pozostałe tryby renderują w niższej rozdzielczości i skalują obraz, co zwiększa wydajność.", [Text.Preset] = "Model DLSS", [Text.PresetDescription] = "Dotyczy tylko DLSS. Auto wybiera K dla DLAA oraz modele DLSS 4.5 (M, a dla Ultra Performance L) dla trybów ze skalowaniem. K to model DLSS 4, a L i M to cięższe modele DLSS 4.5.", [Text.Overlay] = "Nakładka skalera", [Text.OverlayDescription] = "Pokazuje nakładkę diagnostyczną z aktualnym stanem skalera i logiem." }; private static readonly UpscalerChoice[] s_Upscalers = new UpscalerChoice[3] { UpscalerChoice.Auto, UpscalerChoice.DLSS, UpscalerChoice.FSR }; private static readonly DlssMode[] s_Modes = new DlssMode[5] { DlssMode.DLAA, DlssMode.Quality, DlssMode.Balanced, DlssMode.Performance, DlssMode.UltraPerformance }; private static readonly string[] s_ModeNames = new string[5] { "DLAA / Native AA", "Quality", "Balanced", "Performance", "Ultra Performance" }; private static readonly DlssPreset[] s_Presets = new DlssPreset[6] { DlssPreset.Auto, DlssPreset.Default, DlssPreset.J, DlssPreset.K, DlssPreset.L, DlssPreset.M }; private static bool s_ErrorLogged; public static void Install(Harmony harmony) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown try { harmony.Patch((MethodBase)AccessTools.Method(typeof(OptionsPanel_Graphics), "Init", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(DlssOptionsMenu), "InitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Plugin.Logger.LogInfo((object)"Upscaling section will be added to the Graphics options"); } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(84, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not hook the Graphics options panel; the mod stays available through hotkeys. "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logger.LogWarning(val); } } private static void InitPostfix(OptionsPanel_Graphics __instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown try { AddEntries(__instance); } catch (Exception ex) { if (!s_ErrorLogged) { s_ErrorLogged = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(61, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not add the upscaling section to the Graphics options: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogWarning(val); } } } private static void AddEntries(OptionsPanel_Graphics panel) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) DlssSettings settings = Plugin.Settings; RegisterTexts(); panel.AddHeader(Key(Text.Header)); panel.AddToggle(Key(Text.Enabled), Key(Text.EnabledDescription), (bool)((ConfigEntryBase)settings.Enabled).DefaultValue, settings.Enabled.Value, DelegateSupport.ConvertDelegate<Action<bool>>((Delegate)new Action<bool>(DlssRuntime.SetEnabled))); panel.AddDropdown(Key(Text.Upscaler), Key(Text.UpscalerDescription), ToOptions(Array.ConvertAll(s_Upscalers, (UpscalerChoice upscaler) => upscaler.ToString())), Array.IndexOf(s_Upscalers, (UpscalerChoice)((ConfigEntryBase)settings.Upscaler).DefaultValue), Array.IndexOf(s_Upscalers, settings.Upscaler.Value), DelegateSupport.ConvertDelegate<Action<int>>((Delegate)new Action<int>(OnUpscalerChanged))); panel.AddDropdown(Key(Text.Mode), Key(Text.ModeDescription), ToOptions(s_ModeNames), Array.IndexOf(s_Modes, (DlssMode)((ConfigEntryBase)settings.Mode).DefaultValue), Array.IndexOf(s_Modes, settings.Mode.Value), DelegateSupport.ConvertDelegate<Action<int>>((Delegate)new Action<int>(OnModeChanged))); panel.AddDropdown(Key(Text.Preset), Key(Text.PresetDescription), ToOptions(Array.ConvertAll(s_Presets, (DlssPreset preset) => preset.ToString())), Array.IndexOf(s_Presets, (DlssPreset)((ConfigEntryBase)settings.Preset).DefaultValue), Array.IndexOf(s_Presets, settings.Preset.Value), DelegateSupport.ConvertDelegate<Action<int>>((Delegate)new Action<int>(OnPresetChanged))); panel.AddToggle(Key(Text.Overlay), Key(Text.OverlayDescription), (bool)((ConfigEntryBase)settings.ShowOverlay).DefaultValue, settings.ShowOverlay.Value, DelegateSupport.ConvertDelegate<Action<bool>>((Delegate)new Action<bool>(OnOverlayChanged))); } private static void OnUpscalerChanged(int index) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (index >= 0 && index < s_Upscalers.Length) { Plugin.Settings.Upscaler.Value = s_Upscalers[index]; DlssRuntime.RequestRefresh(); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Upscaler: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<UpscalerChoice>(Plugin.Settings.Upscaler.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (using "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<NativeUpscaler>(DlssRuntime.ActiveUpscaler); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger.LogInfo(val); } } private static void OnModeChanged(int index) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (index >= 0 && index < s_Modes.Length) { Plugin.Settings.Mode.Value = s_Modes[index]; DlssRuntime.RequestRefresh(); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Upscaling mode: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DlssMode>(Plugin.Settings.Mode.Value); } logger.LogInfo(val); } } private static void OnPresetChanged(int index) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (index >= 0 && index < s_Presets.Length) { Plugin.Settings.Preset.Value = s_Presets[index]; DlssRuntime.RequestRefresh(); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS preset: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Plugin.Settings.PresetLabel); } logger.LogInfo(val); } } private static void OnOverlayChanged(bool visible) { Plugin.Settings.ShowOverlay.Value = visible; } private static List<string> ToOptions(string[] names) { List<string> val = new List<string>(); foreach (string text in names) { val.Add(text); } return val; } private static AssetGuid Guid(Text text) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return new AssetGuid(1448232019, 1280529237, 1224736768, (int)text); } private static LocalizationKey Key(Text text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return new LocalizationKey(Guid(text)); } private static void RegisterTexts() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) Dictionary<Text, string> obj = ((Localization.CurrentLanguage ?? string.Empty).Contains("Polish") ? s_Polish : s_English); Dictionary<AssetGuid, string> localizedStrings = Localization._LocalizedStrings; foreach (KeyValuePair<Text, string> item in obj) { localizedStrings[Guid(item.Key)] = item.Value; } } } internal sealed class OverlayLog : ILogListener, IDisposable { private const int Capacity = 12; private const int MaxLineLength = 150; private const string HistoryFileName = "VRisingDLSS.history.log"; private const long MaxHistoryFileBytes = 4194304L; private StreamWriter m_HistoryFile; private readonly Queue<string> m_Lines = new Queue<string>(); private readonly object m_Lock = new object(); public LogLevel LogLevelFilter => (LogLevel)63; public void LogEvent(object sender, LogEventArgs eventArgs) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) bool flag = (object)eventArgs.Source == Plugin.Logger; bool flag2 = (eventArgs.Level & 3) > 0; if (!flag && !flag2) { return; } string text = eventArgs.Data?.ToString() ?? string.Empty; int num = text.IndexOf('\n'); if (num >= 0) { text = text.Substring(0, num); } if (text.Length > 150) { text = text.Substring(0, 150) + "..."; } string value = (flag ? string.Empty : ("[" + eventArgs.Source.SourceName + "] ")); string text2 = $"{DateTime.Now:HH:mm:ss} {eventArgs.Level,-7} {value}{text.TrimEnd()}"; lock (m_Lock) { m_Lines.Enqueue(text2); while (m_Lines.Count > 12) { m_Lines.Dequeue(); } m_HistoryFile?.WriteLine($"{DateTime.Now:yyyy-MM-dd} {text2}"); } } public void OpenHistoryFile(string directory) { try { string text = Path.Combine(directory, "VRisingDLSS.history.log"); FileInfo fileInfo = new FileInfo(text); if (fileInfo.Exists && fileInfo.Length > 4194304) { fileInfo.Delete(); } m_HistoryFile = new StreamWriter(text, append: true) { AutoFlush = true }; m_HistoryFile.WriteLine($"=== session started {DateTime.Now:yyyy-MM-dd HH:mm:ss} ==="); } catch (IOException) { m_HistoryFile = null; } } public void AppendTo(StringBuilder builder) { lock (m_Lock) { foreach (string line in m_Lines) { builder.AppendLine(line); } } } public void Dispose() { } } internal static class DlssOverlay { private const float TextRefreshIntervalSeconds = 0.25f; private const float Margin = 12f; private const float Padding = 8f; private const float WidthInFontSizes = 62f; private const float LineHeightInFontSizes = 1.3f; private const float BackgroundOpacity = 0.72f; private const float FrameTimeSmoothing = 0.1f; private const float PercentScale = 100f; private const float MillisecondsPerSecond = 1000f; private static readonly StringBuilder s_Builder = new StringBuilder(); private static readonly OverlayLog s_Log = new OverlayLog(); private static GUIStyle s_Style; private static string s_Text = string.Empty; private static int s_LineCount; private static float s_NextRefreshTime; private static float s_SmoothedFrameTime; private static bool s_Broken; public static void Install() { s_Log.OpenHistoryFile(Paths.BepInExRootPath); Logger.Listeners.Add((ILogListener)(object)s_Log); } public static void Draw() { //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) DlssSettings settings = Plugin.Settings; if (s_Broken || !settings.ShowOverlay.Value || DlssRuntime.IsCalibrating || (int)Event.current.type != 7) { return; } try { float unscaledTime = Time.unscaledTime; s_SmoothedFrameTime = Mathf.Lerp(s_SmoothedFrameTime, Time.unscaledDeltaTime, 0.1f); if (unscaledTime >= s_NextRefreshTime) { s_NextRefreshTime = unscaledTime + 0.25f; BuildText(settings, unscaledTime); } int value = settings.OverlayFontSize.Value; if (s_Style == null) { s_Style = new GUIStyle(); s_Style.normal.textColor = Color.white; s_Style.wordWrap = false; s_Style.richText = false; } s_Style.fontSize = value; float num = (float)value * 62f; float num2 = (float)(s_LineCount * value) * 1.3f + 16f; Rect val = default(Rect); ((Rect)(ref val))..ctor(12f, 12f, num, num2); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.72f); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; GUI.Label(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 8f, num - 16f, num2 - 16f), s_Text, s_Style); } catch (Exception ex) { s_Broken = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(18, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Overlay disabled: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } logger.LogError(val2); } } private static void BuildText(DlssSettings settings, float now) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) BridgeStatus status = NativeBridge.GetStatus(); EvaluateCommand lastCommand = DlssRenderHook.LastCommand; NativeTextureCache textureCache = DlssRenderHook.TextureCache; int num = Time.frameCount - DlssRenderHook.LastPassFrame; bool flag = DlssRenderHook.LastPassFrame >= 0 && num <= 1; string value = (DlssRuntime.IsFaulted ? $"FAILED (NGX 0x{status.lastResult:X8})" : ((!settings.Enabled.Value) ? "OFF" : (flag ? "ON" : "ON, but the upscaling pass is NOT running"))); StringBuilder stringBuilder = s_Builder; stringBuilder.Clear(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(23, 4, stringBuilder2); handler.AppendFormatted("VRisingDLSS"); handler.AppendLiteral(" "); handler.AppendFormatted("0.2.0"); handler.AppendLiteral(" overlay ["); handler.AppendFormatted<KeyCode>(settings.OverlayKey.Value); handler.AppendLiteral("] fps "); handler.AppendFormatted((s_SmoothedFrameTime > 0f) ? (1f / s_SmoothedFrameTime) : 0f, "F0"); stringBuilder3.AppendLine(ref handler); string value2 = (string.IsNullOrEmpty(status.upscalerName) ? DlssRuntime.ActiveUpscaler.ToString().ToUpperInvariant() : status.upscalerName); stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(35, 5, stringBuilder2); handler.AppendLiteral("Upscaling: "); handler.AppendFormatted(value); handler.AppendLiteral(" ["); handler.AppendFormatted<KeyCode>(settings.ToggleKey.Value); handler.AppendLiteral("] upscaler "); handler.AppendFormatted(settings.Upscaler.Value); handler.AppendLiteral(" -> "); handler.AppendFormatted(value2); handler.AppendLiteral(" ["); handler.AppendFormatted<KeyCode>(settings.CycleUpscalerKey.Value); handler.AppendLiteral("]"); stringBuilder4.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder5 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(41, 6, stringBuilder2); handler.AppendLiteral("mode "); handler.AppendFormatted(settings.Mode.Value); handler.AppendLiteral(" ["); handler.AppendFormatted<KeyCode>(settings.CycleModeKey.Value); handler.AppendLiteral("] DLSS preset "); handler.AppendFormatted(settings.PresetLabel); handler.AppendLiteral(" ["); handler.AppendFormatted<KeyCode>(settings.CyclePresetKey.Value); handler.AppendLiteral("] inject "); handler.AppendFormatted(settings.InjectionPoint.Value); handler.AppendLiteral(" ["); handler.AppendFormatted<KeyCode>(settings.CycleInjectionPointKey.Value); handler.AppendLiteral("]"); stringBuilder5.AppendLine(ref handler); if (DlssRenderHook.LastPassFrame >= 0) { float value3 = ((lastCommand.outputWidth != 0) ? (100f * (float)lastCommand.renderWidth / (float)lastCommand.outputWidth) : 0f); stringBuilder2 = stringBuilder; StringBuilder stringBuilder6 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(35, 6, stringBuilder2); handler.AppendLiteral("render "); handler.AppendFormatted(lastCommand.renderWidth); handler.AppendLiteral("x"); handler.AppendFormatted(lastCommand.renderHeight); handler.AppendLiteral(" -> output "); handler.AppendFormatted(lastCommand.outputWidth); handler.AppendLiteral("x"); handler.AppendFormatted(lastCommand.outputHeight); handler.AppendLiteral(" ("); handler.AppendFormatted(value3, "F1"); handler.AppendLiteral("%) camera "); handler.AppendFormatted(DlssRenderHook.LastCameraName); stringBuilder6.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder7 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(40, 2, stringBuilder2); handler.AppendLiteral("passes/frame "); handler.AppendFormatted(flag ? DlssRenderHook.PassesInLastFrame : 0); handler.AppendLiteral(" last pass "); handler.AppendFormatted(num); handler.AppendLiteral(" frame(s) ago"); stringBuilder7.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder8 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(30, 5, stringBuilder2); handler.AppendLiteral("jitter raw ("); handler.AppendFormatted(DlssRenderHook.LastJitter.x, "+0.000;-0.000"); handler.AppendLiteral(", "); handler.AppendFormatted(DlssRenderHook.LastJitter.y, "+0.000;-0.000"); handler.AppendLiteral(") scale ("); handler.AppendFormatted(settings.JitterScaleX.Value, "+0;-0"); handler.AppendLiteral(", "); handler.AppendFormatted(settings.JitterScaleY.Value, "+0;-0"); handler.AppendLiteral(") ["); handler.AppendFormatted<KeyCode>(settings.CycleJitterSignKey.Value); handler.AppendLiteral("]"); stringBuilder8.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder9 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(41, 4, stringBuilder2); handler.AppendLiteral("motion vector scale ("); handler.AppendFormatted(settings.MotionVectorScaleX.Value, "+0;-0"); handler.AppendLiteral(", "); handler.AppendFormatted(settings.MotionVectorScaleY.Value, "+0;-0"); handler.AppendLiteral(") ["); handler.AppendFormatted<KeyCode>(settings.CycleMotionVectorSignKey.Value); handler.AppendLiteral("] bias mask "); handler.AppendFormatted((lastCommand.biasColorMask != IntPtr.Zero) ? "yes" : "no"); stringBuilder9.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder10 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(47, 4, stringBuilder2); handler.AppendLiteral("pre-exposure "); handler.AppendFormatted(lastCommand.preExposure, "F3"); handler.AppendLiteral(" auto exposure "); handler.AppendFormatted(settings.AutoExposure.Value ? "on" : "off"); handler.AppendLiteral(" ["); handler.AppendFormatted<KeyCode>(settings.ToggleAutoExposureKey.Value); handler.AppendLiteral("] mip bias "); handler.AppendFormatted(settings.UseMipBias.Value ? "on" : "off"); stringBuilder10.AppendLine(ref handler); } else { stringBuilder.AppendLine("no upscaling pass has run yet"); } string value4 = ((DlssRenderHook.HistoryResets > 0) ? $"{now - DlssRenderHook.LastHistoryResetTime:F1}s ago" : "never"); stringBuilder2 = stringBuilder; StringBuilder stringBuilder11 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(55, 4, stringBuilder2); handler.AppendLiteral("bridge "); handler.AppendFormatted((BridgeState)status.state); handler.AppendLiteral(" evaluations "); handler.AppendFormatted(status.evaluations); handler.AppendLiteral(" failed "); handler.AppendFormatted(status.failedEvaluations); handler.AppendLiteral(" features created "); handler.AppendFormatted(status.featuresCreated); stringBuilder11.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder12 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(39, 2, stringBuilder2); handler.AppendLiteral("upscaler GPU time "); handler.AppendFormatted(status.evaluateGpuMilliseconds, "F2"); handler.AppendLiteral(" ms frame time "); handler.AppendFormatted(s_SmoothedFrameTime * 1000f, "F2"); handler.AppendLiteral(" ms"); stringBuilder12.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder13 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(60, 4, stringBuilder2); handler.AppendLiteral("history resets "); handler.AppendFormatted(DlssRenderHook.HistoryResets); handler.AppendLiteral(" (last "); handler.AppendFormatted(value4); handler.AppendLiteral(") textures "); handler.AppendFormatted(textureCache.Count); handler.AppendLiteral(" cached, "); handler.AppendFormatted(textureCache.StalePointersReplaced); handler.AppendLiteral(" stale replaced"); stringBuilder13.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder14 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(26, 1, stringBuilder2); handler.AppendLiteral("game settings overridden: "); handler.AppendFormatted(DlssRuntime.DescribeGameSettings()); stringBuilder14.AppendLine(ref handler); stringBuilder2 = stringBuilder; StringBuilder stringBuilder15 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(53, 1, stringBuilder2); handler.AppendLiteral("jitter calibration ["); handler.AppendFormatted<KeyCode>(settings.JitterCalibrationKey.Value); handler.AppendLiteral("] - stand still, takes about 30 s"); stringBuilder15.AppendLine(ref handler); if (settings.MotionProbe.Value) { stringBuilder.AppendLine(DlssRuntime.DescribeProbe(in status)); } stringBuilder.AppendLine("--- log ---"); s_Log.AppendTo(stringBuilder); s_Text = stringBuilder.ToString(); s_LineCount = CountLines(s_Text); } private static int CountLines(string text) { int num = 0; for (int i = 0; i < text.Length; i++) { if (text[i] == '\n') { num++; } } return num; } } internal static class DlssRenderHook { private const string DlssPassLambdaMarker = "DoDLSSPass_b__"; private const string ColorMaskLambdaMarker = "DoDLSSColorMaskPass_b__"; private const int CommandRingCapacity = 64; private static readonly NativeTextureCache s_TextureCache = new NativeTextureCache(); private static readonly Dictionary<int, string> s_CameraNames = new Dictionary<int, string>(); private static readonly int s_CommandSize = Marshal.SizeOf<EvaluateCommand>(); public const float ProbeViewportX = 0.2f; public const float ProbeViewportY = 0.5f; private const int ProbeIntervalFrames = 30; private const float ClipToViewportScale = 0.5f; private const float MillisecondsPerSecond = 1000f; private static Matrix4x4 s_PreviousViewProjection; private static bool s_HasPreviousViewProjection; private static IntPtr s_CommandRing; private static int s_CommandIndex; private static bool s_ErrorLogged; public static bool ResetHistoryRequested; public static EvaluateCommand LastCommand; public static Vector4 LastJitter; public static string LastCameraName = string.Empty; public static int LastPassFrame = -1; public static int PassesInLastFrame; public static int HistoryResets; public static float LastHistoryResetTime; public static NativeTextureCache TextureCache => s_TextureCache; public static bool Install(Harmony harmony) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown s_CommandRing = Marshal.AllocHGlobal(s_CommandSize * 64); Type? typeFromHandle = typeof(__c); MethodInfo methodInfo = FindLambda(typeFromHandle, "DoDLSSPass_b__"); MethodInfo methodInfo2 = FindLambda(typeFromHandle, "DoDLSSColorMaskPass_b__"); if (methodInfo == null) { Plugin.Logger.LogError((object)"HDRP's DLSS render pass was not found in this game build."); return false; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(DlssRenderHook), "DlssPassPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(DlssRenderHook), "ColorMaskPassPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Plugin.Logger.LogInfo((object)("Hooked " + methodInfo.Name + ((methodInfo2 != null) ? (" and " + methodInfo2.Name) : string.Empty))); return true; } private static MethodInfo FindLambda(Type host, string marker) { MethodInfo[] methods = host.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name.Contains(marker)) { return methodInfo; } } return null; } private static bool ColorMaskPassPrefix(DLSSColorMaskPassData data) { return (Object)(object)data.colorMaskMaterial != (Object)null; } private static bool DlssPassPrefix(DLSSData data, RenderGraphContext ctx) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown try { Submit(data, ctx); } catch (Exception ex) { if (!s_ErrorLogged) { s_ErrorLogged = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(18, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS pass failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); } } return false; } private unsafe static void Submit(DLSSData data, RenderGraphContext ctx) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) Parameters parameters = data.parameters; HDCamera hdCamera = parameters.hdCamera; ViewResourceHandles resources = data.resourceHandles.resources; RenderTexture val = TextureHandle.op_Implicit(resources.source); RenderTexture val2 = TextureHandle.op_Implicit(resources.output); RenderTexture val3 = TextureHandle.op_Implicit(resources.depth); RenderTexture val4 = TextureHandle.op_Implicit(resources.motionVectors); RenderTexture val5 = (((TextureHandle)(ref resources.biasColorMask)).IsValid() ? TextureHandle.op_Implicit(resources.biasColorMask) : null); DlssSettings settings = Plugin.Settings; DlssModeInfo modeInfo = settings.ModeInfo; Vector2Int finalViewport = DynamicResolutionHandler.instance.finalViewport; Vector4 taaJitter = hdCamera.taaJitter; int actualWidth = hdCamera.actualWidth; int actualHeight = hdCamera.actualHeight; int frameCount = Time.frameCount; int instanceID = ((Object)hdCamera.camera).GetInstanceID(); DlssFeatureFlags dlssFeatureFlags = DlssFeatureFlags.IsHDR | DlssFeatureFlags.MVLowRes | DlssFeatureFlags.DepthInverted; if (settings.AutoExposure.Value) { dlssFeatureFlags |= DlssFeatureFlags.AutoExposure; } EvaluateCommand command = new EvaluateCommand { color = s_TextureCache.Resolve(val, frameCount), depth = s_TextureCache.Resolve(val3, frameCount), motionVectors = s_TextureCache.Resolve(val4, frameCount), biasColorMask = s_TextureCache.Resolve(val5, frameCount), output = s_TextureCache.Resolve(val2, frameCount), cameraId = (uint)instanceID, renderWidth = (uint)actualWidth, renderHeight = (uint)actualHeight, outputWidth = (uint)((Vector2Int)(ref finalViewport)).x, outputHeight = (uint)((Vector2Int)(ref finalViewport)).y, perfQuality = modeInfo.NgxPerfQuality, preset = (int)settings.ResolvedPreset, createFlags = (uint)dlssFeatureFlags, reset = ((parameters.resetHistory || ResetHistoryRequested) ? 1u : 0u), indicatorInvertY = 1u, jitterX = taaJitter.x * settings.JitterScaleX.Value, jitterY = taaJitter.y * settings.JitterScaleY.Value, mvScaleX = (float)actualWidth * settings.MotionVectorScaleX.Value, mvScaleY = (float)actualHeight * settings.MotionVectorScaleY.Value, preExposure = parameters.preExposure, upscaler = (uint)DlssRuntime.ActiveUpscaler, cameraNear = hdCamera.camera.nearClipPlane, cameraFar = hdCamera.camera.farClipPlane, cameraFovVertical = hdCamera.camera.fieldOfView * ((float)Math.PI / 180f), frameTimeDeltaMilliseconds = Time.unscaledDeltaTime * 1000f, sharpness = settings.FsrSharpness.Value }; ResetHistoryRequested = false; UpdateProbe(ref command, hdCamera.camera, settings, frameCount); if (!s_CameraNames.TryGetValue(instanceID, out var value)) { value = hdCamera.name; s_CameraNames.Add(instanceID, value); LogCamera(hdCamera, in command, val, val2, val3, val4, val5); } if (command.reset != 0) { HistoryResets++; LastHistoryResetTime = Time.unscaledTime; } PassesInLastFrame = ((frameCount != LastPassFrame) ? 1 : (PassesInLastFrame + 1)); LastPassFrame = frameCount; LastCommand = command; LastJitter = taaJitter; LastCameraName = value; IntPtr intPtr = s_CommandRing + s_CommandSize * s_CommandIndex; s_CommandIndex = (s_CommandIndex + 1) % 64; *(EvaluateCommand*)(void*)intPtr = command; ctx.cmd.IssuePluginEventAndData(NativeBridge.RenderCallback, 1, intPtr); } private static void UpdateProbe(ref EvaluateCommand command, Camera camera, DlssSettings settings, int frame) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if (!settings.MotionProbe.Value) { s_HasPreviousViewProjection = false; return; } Matrix4x4 val = camera.projectionMatrix * camera.worldToCameraMatrix; if (frame % 30 == 0) { command.probeEnabled = 1u; command.probeX = (uint)((float)command.renderWidth * 0.2f); command.probeY = (uint)((float)command.renderHeight * 0.5f); command.probeExpectedX = float.NaN; command.probeExpectedY = float.NaN; float probeDepth = NativeBridge.GetStatus().probeDepth; if (s_HasPreviousViewProjection && probeDepth > 0f) { float nearClipPlane = camera.nearClipPlane; float farClipPlane = camera.farClipPlane; float num = nearClipPlane * farClipPlane / (nearClipPlane + probeDepth * (farClipPlane - nearClipPlane)); Vector3 val2 = camera.ViewportToWorldPoint(new Vector3(0.2f, 0.5f, num)); Vector4 val3 = s_PreviousViewProjection * new Vector4(val2.x, val2.y, val2.z, 1f); if (val3.w > 0f) { float num2 = val3.x / val3.w * 0.5f + 0.5f; float num3 = val3.y / val3.w * 0.5f + 0.5f; command.probeExpectedX = 0.2f - num2; command.probeExpectedY = 0.5f - num3; } } } s_PreviousViewProjection = val; s_HasPreviousViewProjection = true; } private static void LogCamera(HDCamera hdCamera, in EvaluateCommand command, RenderTexture source, RenderTexture output, RenderTexture depth, RenderTexture motionVectors, RenderTexture biasColorMask) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown FrameSettings frameSettings = hdCamera.frameSettings; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(77, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS on camera '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(hdCamera.name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(command.renderWidth); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(command.renderHeight); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(command.outputWidth); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(command.outputHeight); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("motionVectors="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(((FrameSettings)(ref frameSettings)).IsEnabled((FrameSettingsField)10)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("objectMotionVectors="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(((FrameSettings)(ref frameSettings)).IsEnabled((FrameSettingsField)11)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("preExposure="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(command.preExposure, "F3"); } logger.LogInfo(val); ManualLogSource logger2 = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(38, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" source="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(source)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" output="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(output)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" depth="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(depth)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("motion="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(motionVectors)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" mask="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(biasColorMask)); } logger2.LogInfo(val); } private static string Describe(RenderTexture texture) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)texture == (Object)null)) { return $"{((Texture)texture).width}x{((Texture)texture).height}/{texture.graphicsFormat}"; } return "none"; } } internal static class DlssRuntime { private sealed class AssetState { public HDRenderPipelineAsset Asset; public GlobalDynamicResolutionSettings Original; public GlobalDynamicResolutionSettings Applied; } private sealed class CameraState { public HDAdditionalCameraData Data; public bool OriginalAllowDynamicResolution; public bool OriginalAllowDlss; } private const int StateRefreshIntervalFrames = 30; private const int StatusPollIntervalFrames = 60; private const float FullScreenPercentage = 100f; private const float ScreenshotIntervalSeconds = 1f; private const string ScreenshotFileFormat = "VRisingDLSS_shot_{0}.png"; private static readonly Dictionary<int, AssetState> s_Assets = new Dictionary<int, AssetState>(); private static readonly Dictionary<int, CameraState> s_Cameras = new Dictionary<int, CameraState>(); private static bool s_Applied; private static bool s_Faulted; private static bool s_DeviceChecked; private static bool s_DeviceSupported; private static bool s_RefreshRequested = true; private static int s_LastRefreshFrame; private static int s_LastStatusFrame; private static BridgeState s_LastState = BridgeState.NotInitialized; private static uint s_LastFeaturesCreated; private static int s_ScreenshotsTaken; private const float CalibrationSettleSeconds = 1.5f; private const float CalibrationShotIntervalSeconds = 0.5f; private const int CalibrationShotsPerStep = 1; private const int CalibrationRounds = 4; private const string CalibrationFileFormat = "VRisingDLSS_jitter_r{0}_c{1}.png"; private static readonly Vector2[] s_CalibrationSigns = (Vector2[])(object)new Vector2[4] { new Vector2(-1f, -1f), new Vector2(1f, -1f), new Vector2(-1f, 1f), new Vector2(1f, 1f) }; private static int s_CalibrationStep = -1; private static int s_CalibrationShot; private static float s_CalibrationStepStart; private static float s_CalibrationOriginalX; private static float s_CalibrationOriginalY; private static bool s_CalibrationTimerUsed; private static bool s_CalibrationRequested; private const string NvidiaVendorName = "NVIDIA"; private static bool s_IsNvidia; private static bool s_DlssUnavailable; private static bool s_DlssRequestWarningLogged; private static uint s_LastProbeSamples; private const float MinLoggedProbeMotion = 0.0002f; public static NativeUpscaler ActiveUpscaler { get { switch (Plugin.Settings.Upscaler.Value) { case UpscalerChoice.FSR: return NativeUpscaler.Fsr; case UpscalerChoice.DLSS: if (s_IsNvidia) { return NativeUpscaler.Dlss; } if (!s_DlssRequestWarningLogged) { s_DlssRequestWarningLogged = true; Plugin.Logger.LogWarning((object)"DLSS was selected but there is no NVIDIA GPU; using FSR instead."); } return NativeUpscaler.Fsr; default: if (!s_IsNvidia || s_DlssUnavailable) { return NativeUpscaler.Fsr; } return NativeUpscaler.Dlss; } } } public static bool DlssSelectable => s_IsNvidia; public static bool IsCalibrating => s_CalibrationStep >= 0; public static bool IsApplied => s_Applied; public static bool IsFaulted => s_Faulted; public static void Tick() { if (!CheckDevice()) { return; } int frameCount = Time.frameCount; DlssSettings settings = Plugin.Settings; HandleHotkeys(settings); if (settings.Enabled.Value && !s_Faulted) { if (s_RefreshRequested || frameCount - s_LastRefreshFrame >= 30) { s_RefreshRequested = false; s_LastRefreshFrame = frameCount; Apply(settings); } } else if (s_Applied) { Restore(); } if (frameCount - s_LastStatusFrame >= 60) { s_LastStatusFrame = frameCount; PollStatus(settings); } DlssRenderHook.TextureCache.Trim(frameCount); CaptureScreenshots(settings); RunJitterCalibration(settings); DlssBenchmark.Tick(settings); } private static void RunJitterCalibration(DlssSettings settings) { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown float realtimeSinceStartup = Time.realtimeSinceStartup; if (s_CalibrationStep < 0) { float value = settings.JitterCalibrationAfterSeconds.Value; bool flag = value > 0f && !s_CalibrationTimerUsed && realtimeSinceStartup >= value; if (flag || s_CalibrationRequested) { s_CalibrationTimerUsed |= flag; s_CalibrationRequested = false; Plugin.Logger.LogInfo((object)"Jitter calibration started - keep the camera still"); s_CalibrationOriginalX = settings.JitterScaleX.Value; s_CalibrationOriginalY = settings.JitterScaleY.Value; s_CalibrationStep = 0; s_CalibrationShot = 0; BeginCalibrationStep(settings, realtimeSinceStartup); } return; } float num = s_CalibrationStepStart + 1.5f + (float)s_CalibrationShot * 0.5f; if (realtimeSinceStartup < num) { return; } if (s_CalibrationShot < 1) { string text = $"VRisingDLSS_jitter_r{s_CalibrationStep / s_CalibrationSigns.Length}_c{s_CalibrationStep % s_CalibrationSigns.Length}.png"; ScreenCapture.CaptureScreenshot(Path.Combine(Paths.BepInExRootPath, text)); ManualLogSource logger = Plugin.Logger; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Jitter calibration: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" = scale ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(settings.JitterScaleX.Value, "+0;-0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(settings.JitterScaleY.Value, "+0;-0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger.LogInfo(val); s_CalibrationShot++; } else { s_CalibrationStep++; s_CalibrationShot = 0; if (s_CalibrationStep < s_CalibrationSigns.Length * 4) { BeginCalibrationStep(settings, realtimeSinceStartup); return; } settings.JitterScaleX.Value = s_CalibrationOriginalX; settings.JitterScaleY.Value = s_CalibrationOriginalY; DlssRenderHook.ResetHistoryRequested = true; s_CalibrationStep = -1; Plugin.Logger.LogInfo((object)"Jitter calibration finished"); } } private static void BeginCalibrationStep(DlssSettings settings, float now) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = s_CalibrationSigns[s_CalibrationStep % s_CalibrationSigns.Length]; settings.JitterScaleX.Value = val.x; settings.JitterScaleY.Value = val.y; DlssRenderHook.ResetHistoryRequested = true; s_CalibrationStepStart = now; } private static bool CheckDevice() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (s_DeviceChecked) { return s_DeviceSupported; } s_DeviceChecked = true; bool flag = default(bool); if ((int)SystemInfo.graphicsDeviceType != 2) { ManualLogSource logger = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(61, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS is only wired up for Direct3D 11, but the game runs on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<GraphicsDeviceType>(SystemInfo.graphicsDeviceType); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } logger.LogError(val); return false; } s_IsNvidia = (SystemInfo.graphicsDeviceVendor ?? string.Empty).Contains("NVIDIA", StringComparison.OrdinalIgnoreCase); ManualLogSource logger2 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("GPU: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(SystemInfo.graphicsDeviceName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(s_IsNvidia ? "DLSS and FSR" : "FSR only"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")"); } logger2.LogInfo(val2); s_DeviceSupported = true; return true; } public static void SetEnabled(bool enabled) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (enabled && s_Faulted) { NativeBridge.ResetFailure(); s_Faulted = false; } Plugin.Settings.Enabled.Value = enabled; s_RefreshRequested = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(5, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(enabled ? "enabled" : "disabled"); } logger.LogInfo(val); } public static void RequestRefresh() { s_RefreshRequested = true; DlssRenderHook.ResetHistoryRequested = true; } private static void HandleHotkeys(DlssSettings settings) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Expected O, but got Unknown if (Input.GetKeyDown(settings.ToggleKey.Value)) { SetEnabled(s_Faulted || !settings.Enabled.Value); } bool flag = default(bool); if (Input.GetKeyDown(settings.CycleModeKey.Value)) { settings.Mode.Value = settings.NextMode(); s_RefreshRequested = true; ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS mode: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DlssMode>(settings.Mode.Value); } logger.LogInfo(val); } if (Input.GetKeyDown(settings.OverlayKey.Value)) { settings.ShowOverlay.Value = !settings.ShowOverlay.Value; } if (!settings.ShowOverlay.Value) { return; } if (Input.GetKeyDown(settings.CycleUpscalerKey.Value)) { settings.Upscaler.Value = settings.NextUpscaler(); RequestRefresh(); ManualLogSource logger2 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Upscaler: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<UpscalerChoice>(settings.Upscaler.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (using "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<NativeUpscaler>(ActiveUpscaler); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger2.LogInfo(val); } if (Input.GetKeyDown(settings.CyclePresetKey.Value)) { settings.Preset.Value = settings.NextPreset(); DlssRenderHook.ResetHistoryRequested = true; ManualLogSource logger3 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS preset: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(settings.PresetLabel); } logger3.LogInfo(val); } if (Input.GetKeyDown(settings.CycleInjectionPointKey.Value)) { settings.InjectionPoint.Value = settings.NextInjectionPoint(); s_RefreshRequested = true; ManualLogSource logger4 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS injection point: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DlssInjectionPoint>(settings.InjectionPoint.Value); } logger4.LogInfo(val); } if (Input.GetKeyDown(settings.CycleJitterSignKey.Value)) { DlssSettings.CycleSigns(settings.JitterScaleX, settings.JitterScaleY); DlssRenderHook.ResetHistoryRequested = true; ManualLogSource logger5 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Jitter scale: ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(settings.JitterScaleX.Value, "+0;-0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(settings.JitterScaleY.Value, "+0;-0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger5.LogInfo(val); } if (Input.GetKeyDown(settings.CycleMotionVectorSignKey.Value)) { DlssSettings.CycleSigns(settings.MotionVectorScaleX, settings.MotionVectorScaleY); DlssRenderHook.ResetHistoryRequested = true; ManualLogSource logger6 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Motion vector scale: ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(settings.MotionVectorScaleX.Value, "+0;-0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(settings.MotionVectorScaleY.Value, "+0;-0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger6.LogInfo(val); } if (Input.GetKeyDown(settings.JitterCalibrationKey.Value) && !IsCalibrating) { s_CalibrationRequested = true; } if (Input.GetKeyDown(settings.ToggleAutoExposureKey.Value)) { settings.AutoExposure.Value = !settings.AutoExposure.Value; ManualLogSource logger7 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS auto exposure: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(settings.AutoExposure.Value ? "on" : "off"); } logger7.LogInfo(val); } } public static string DescribeGameSettings() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) using (Dictionary<int, AssetState>.ValueCollection.Enumerator enumerator = s_Assets.Values.GetEnumerator()) { if (enumerator.MoveNext()) { GlobalDynamicResolutionSettings original = enumerator.Current.Original; string text = (original.enabled ? $"{original.upsampleFilter} {(original.forceResolution ? original.forcedPercentage : original.maxPercentage):F0}%" : "off"); string text2 = "?"; foreach (CameraState value in s_Cameras.Values) { if ((Object)(object)value.Data != (Object)null) { text2 = ((object)value.Data.antialiasing/*cast due to .constrained prefix*/).ToString(); break; } } return "AA " + text2 + ", upscaling " + text; } } return "not captured"; } private static void Apply(DlssSettings settings) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown HDRenderPipeline currentPipeline = HDRenderPipeline.currentPipeline; HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; if (currentPipeline != null && !((Object)(object)currentAsset == (Object)null)) { if (!HDDynamicResolutionPlatformCapabilities.DLSSDetected) { HDDynamicResolutionPlatformCapabilities.ActivateDLSS(); } if (currentPipeline.m_DLSSPass == null) { currentPipeline.m_DLSSPass = new DLSSPass(); Plugin.Logger.LogInfo((object)"Installed DLSS pass into HDRP"); } ApplyAsset(currentAsset, settings); ApplyCameras(); s_Applied = true; } } private static void ApplyAsset(HDRenderPipelineAsset asset, DlssSettings settings) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown RenderPipelineSettings renderPipelineSettings = asset.m_RenderPipelineSettings; GlobalDynamicResolutionSettings a = renderPipelineSettings.dynamicResolutionSettings; int instanceID = ((Object)asset).GetInstanceID(); if (!s_Assets.TryGetValue(instanceID, out var value)) { value = new AssetState { Asset = asset, Original = a }; s_Assets.Add(instanceID, value); } else if (!SameUpscalingSettings(in a, in value.Applied)) { value.Original = a; } float screenPercentage = settings.ModeInfo.ScreenPercentage; GlobalDynamicResolutionSettings b = a; b.enabled = true; b.enableDLSS = true; b.useMipBias = settings.UseMipBias.Value; b.forceResolution = true; b.forcedPercentage = screenPercentage; b.minPercentage = Mathf.Min(a.minPercentage, screenPercentage); b.maxPercentage = 100f; b.DLSSInjectionPoint = ToUpsamplerSchedule(settings.InjectionPoint.Value); value.Applied = b; if (!SameUpscalingSettings(in a, in b)) { WriteDynamicResolutionSettings(asset, renderPipelineSettings, b); DlssRenderHook.ResetHistoryRequested = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Applied DLSS settings to '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)asset).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': mode="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DlssMode>(settings.Mode.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(screenPercentage, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("%), preset="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(settings.PresetLabel); } logger.LogInfo(val); } } private static void WriteDynamicResolutionSettings(HDRenderPipelineAsset asset, RenderPipelineSettings pipelineSettings, GlobalDynamicResolutionSettings dynamicResolutionSettings) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) pipelineSettings.dynamicResolutionSettings = dynamicResolutionSettings; asset.m_RenderPipelineSettings = pipelineSettings; } private static bool SameUpscalingSettings(in GlobalDynamicResolutionSettings a, in GlobalDynamicResolutionSettings b) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (a.enabled == b.enabled && a.enableDLSS == b.enableDLSS && a.useMipBias == b.useMipBias && a.forceResolution == b.forceResolution && Mathf.Approximately(a.forcedPercentage, b.forcedPercentage) && Mathf.Approximately(a.minPercentage, b.minPercentage) && Mathf.Approximately(a.maxPercentage, b.maxPercentage)) { return a.DLSSInjectionPoint == b.DLSSInjectionPoint; } return false; } private static UpsamplerScheduleType ToUpsamplerSchedule(DlssInjectionPoint injectionPoint) { return (UpsamplerScheduleType)(injectionPoint switch { DlssInjectionPoint.AfterDepthOfField => 1, DlssInjectionPoint.AfterPost => 2, _ => 0, }); } private static void ApplyCameras() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); foreach (Camera item in (Il2CppArrayBase<Camera>)(object)Camera.allCameras) { if ((Object)(object)item == (Object)null || (int)item.cameraType != 1 || (Object)(object)item.targetTexture != (Object)null) { continue; } HDAdditionalCameraData component = ((Component)item).GetComponent<HDAdditionalCameraData>(); if ((Object)(object)component == (Object)null) { continue; } int instanceID = ((Object)item).GetInstanceID(); if (!s_Cameras.ContainsKey(instanceID)) { s_Cameras.Add(instanceID, new CameraState { Data = component, OriginalAllowDynamicResolution = component.allowDynamicResolution, OriginalAllowDlss = component.allowDeepLearningSuperSampling }); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Enabling DLSS on camera '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)item).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (antialiasing was "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<AntialiasingMode>(component.antialiasing); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger.LogInfo(val); } if (!component.allowDynamicResolution) { component.allowDynamicResolution = true; } if (!component.allowDeepLearningSuperSampling) { component.allowDeepLearningSuperSampling = true; } } } private static void Restore() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown foreach (AssetState value in s_Assets.Values) { if ((Object)(object)value.Asset != (Object)null) { WriteDynamicResolutionSettings(value.Asset, value.Asset.m_RenderPipelineSettings, value.Original); } } s_Assets.Clear(); foreach (CameraState value2 in s_Cameras.Values) { if (!((Object)(object)value2.Data == (Object)null)) { value2.Data.allowDynamicResolution = value2.OriginalAllowDynamicResolution; value2.Data.allowDeepLearningSuperSampling = value2.OriginalAllowDlss; } } s_Cameras.Clear(); CommandBuffer val = new CommandBuffer(); val.IssuePluginEventAndData(NativeBridge.RenderCallback, 2, IntPtr.Zero); Graphics.ExecuteCommandBuffer(val); val.Dispose(); DlssRenderHook.TextureCache.Clear(); s_Applied = false; Plugin.Logger.LogInfo((object)"Restored the game's own anti-aliasing / upscaling settings"); } private static void PollStatus(DlssSettings settings) { //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown BridgeStatus status = NativeBridge.GetStatus(); BridgeState state = (BridgeState)status.state; bool flag = default(bool); if (state == BridgeState.Failed && !s_Faulted) { string text = ((status.needsUpdatedDriver != 0) ? $" The GPU driver is too old; DLSS needs at least {status.minDriverVersionMajor}.{status.minDriverVersionMinor}." : string.Empty); if (ActiveUpscaler == NativeUpscaler.Dlss && settings.Upscaler.Value == UpscalerChoice.Auto) { s_DlssUnavailable = true; NativeBridge.ResetFailure(); RequestRefresh(); ManualLogSource logger = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(52, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DLSS is not available (result 0x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(status.lastResult, "X8"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); switching to FSR."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } logger.LogWarning(val); } else { s_Faulted = true; ManualLogSource logger2 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(92, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ActiveUpscaler.ToString().ToUpperInvariant()); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" failed (result 0x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(status.lastResult, "X8"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") and was turned off."); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("See BepInEx/VRisingDLSS.native.log. Press "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<KeyCode>(settings.ToggleKey.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to retry."); } logger2.LogError(val2); if (s_Applied) { Restore(); } } } else if (status.featuresCreated != s_LastFeaturesCreated && state == BridgeState.Ready) { string text2 = ((ActiveUpscaler == NativeUpscaler.Dlss) ? (", preset=" + settings.PresetLabel) : string.Empty); ManualLogSource logger3 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(23, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(status.upscalerName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" running: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<uint>(status.renderWidth); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<uint>(status.renderHeight); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<uint>(status.outputWidth); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<uint>(status.outputHeight); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("mode="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<DlssMode>(settings.Mode.Value); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text2); } logger3.LogInfo(val3); } if (settings.MotionProbe.Value && status.probeSamples != s_LastProbeSamples) { s_LastProbeSamples = status.probeSamples; if (Mathf.Abs(status.probeMotionX) > 0.0002f || Mathf.Abs(status.probeMotionY) > 0.0002f || Mathf.Abs(status.probeExpectedX) > 0.0002f || Mathf.Abs(status.probeExpectedY) > 0.0002f) { Plugin.Logger.LogInfo((object)DescribeProbe(in status)); } } s_LastState = state; s_LastFeaturesCreated = status.featuresCreated; } public static string DescribeProbe(in BridgeStatus status) { if (status.probeSamples == 0) { return "MV probe: no sample yet"; } string value = ((status.probeMotionFormat != 0) ? $"({status.probeMotionX:+0.00000;-0.00000}, {status.probeMotionY:+0.00000;-0.00000})" : "unreadable"); return $"MV probe: sampled {value} expected ({status.probeExpectedX:+0.00000;-0.00000}, {status.probeExpectedY:+0.00000;-0.00000}) depth {status.probeDepth:F5} format {status.probeMotionFormat}"; } private static void CaptureScreenshots(DlssSettings settings) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown float value = settings.ScreenshotAfterSeconds.Value; if (!(value <= 0f) && s_ScreenshotsTaken < settings.ScreenshotCount.Value && !(Time.realtimeSinceStartup < value + (float)s_ScreenshotsTaken * 1f)) { string text = Path.Combine(Paths.BepInExRootPath, $"VRisingDLSS_shot_{s_ScreenshotsTaken}.png"); ScreenCapture.CaptureScreenshot(text); BridgeStatus status = NativeBridge.GetStatus(); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Screenshot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (state="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<BridgeState>((BridgeState)status.state); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", evaluations="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(status.evaluations); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", failed="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(status.failedEvaluations); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger.LogInfo(val); s_ScreenshotsTaken++; } } } public enum DlssMode { DLAA, Quality, Balanced, Performance, UltraPerformance } public enum DlssPreset { Auto = -1, Default = 0, J = 10, K = 11, L = 12, M = 13 } public enum UpscalerChoice { Auto, DLSS, FSR } public enum DlssInjectionPoint { BeforePost, AfterDepthOfField, AfterPost } internal readonly struct DlssModeInfo { public readonly float ScreenPercentage; public readonly int NgxPerfQuality; public DlssModeInfo(float screenPercentage, int ngxPerfQuality) { ScreenPercentage = screenPercentage; NgxPerfQuality = ngxPerfQuality; } } internal sealed class DlssSettings { private const float FullScreenPercentage = 100f; private const int NgxMaxPerf = 0; private const int NgxBalanced = 1; private const int NgxMaxQuality = 2; private const int NgxUltraPerformance = 3; private const int NgxDlaa = 5; private const string GeneralSection = "General"; private const string AdvancedSection = "Advanced"; private const string OverlaySection = "Overlay"; private const string DebugSection = "Debug"; public readonly ConfigEntry<bool> Enabled; public readonly ConfigEntry<UpscalerChoice> Upscaler; public readonly ConfigEntry<float> FsrSharpness; public readonly ConfigEntry<KeyCode> CycleUpscalerKey; public readonly ConfigEntry<DlssMode> Mode; public readonly ConfigEntry<DlssPreset> Preset; public readonly ConfigEntry<KeyCode> ToggleKey; public readonly ConfigEntry<KeyCode> CycleModeKey; public readonly ConfigEntry<DlssInjectionPoint> InjectionPoint; public readonly ConfigEntry<bool> AutoExposure; public readonly ConfigEntry<bool> UseMipBias; public readonly ConfigEntry<float> JitterScaleX; public readonly ConfigEntry<float> JitterScaleY; public readonly ConfigEntry<float> MotionVectorScaleX; public readonly ConfigEntry<float> MotionVectorScaleY; public readonly ConfigEntry<bool> ShowOverlay; public readonly ConfigEntry<int> OverlayFontSize; public readonly ConfigEntry<KeyCode> OverlayKey; public readonly ConfigEntry<KeyCode> CyclePresetKey; public readonly ConfigEntry<KeyCode> CycleInjectionPointKey; public readonly ConfigEntry<KeyCode> CycleJitterSignKey; public readonly ConfigEntry<KeyCode> CycleMotionVectorSignKey; public readonly ConfigEntry<KeyCode> ToggleAutoExposureKey; public readonly ConfigEntry<KeyCode> JitterCalibrationKey; public readonly ConfigEntry<bool> VerboseNgxLog; public readonly ConfigEntry<bool> MotionProbe; public readonly ConfigEntry<float> JitterCalibrationAfterSeconds; public readonly ConfigEntry<float> BenchmarkAfterSeconds; public readonly ConfigEntry<float> ScreenshotAfterSeconds; public readonly ConfigEntry<int> ScreenshotCount; public DlssModeInfo ModeInfo => GetModeInfo(Mode.Value); public DlssPreset ResolvedPreset { get { if (Preset.Value != DlssPreset.Auto) { return Preset.Value; } return Mode.Value switch { DlssMode.DLAA => DlssPreset.K, DlssMode.UltraPerformance => DlssPreset.L, _ => DlssPreset.M, }; } } public string PresetLabel { get { if (Preset.Value != DlssPreset.Auto) { return Preset.Value.ToString(); } return $"Auto ({ResolvedPreset})"; } } public DlssSettings(ConfigFile config) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown Enabled = config.Bind<bool>("General", "Enabled", true, "Run DLSS or FSR instead of the game's own anti-aliasing / FSR 1 upscaling."); Upscaler = config.Bind<UpscalerChoice>("General", "Upscaler", UpscalerChoice.Auto, "Which upscaler runs. Auto uses DLSS on NVIDIA RTX cards and AMD FSR on everything else."); FsrSharpness = config.Bind<float>("General", "FsrSharpness", 0f, new ConfigDescription("Strength of FSR's extra sharpening pass. 0 turns it off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); Mode = config.Bind<DlssMode>("General", "Mode", DlssMode.DLAA, "DLAA (called Native AA in FSR) renders at native resolution. The other modes render lower and upscale."); Preset = config.Bind<DlssPreset>("General", "Preset", DlssPreset.Auto, "DLSS model preset. L and M are the second generation transformer models (DLSS 4.5), K is the first generation transformer (DLSS 4). Auto uses K for DLAA, L for UltraPerformance and M for the other modes. Default lets DLSS pick."); ToggleKey = config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)291, "Turns DLSS on and off while playing."); CycleModeKey = config.Bind<KeyCode>("General", "CycleModeKey", (KeyCode)290, "Switches to the next DLSS mode while playing."); InjectionPoint = config.Bind<DlssInjectionPoint>("Advanced", "InjectionPoint", DlssInjectionPoint.AfterDepthOfField, "Where in HDRP post-processing DLSS runs. BeforePost makes some of the game's screen-space effects misalign in the upscaling modes (rectangular dark patches)."); AutoExposure = config.Bind<bool>("Advanced", "AutoExposure", true, "Let DLSS estimate exposure itself instead of using HDRP's pre-exposure value."); UseMipBias = config.Bind<bool>("Advanced", "UseMipBias", true, "Sharpen texture sampling to compensate for rendering below output resolution."); JitterScaleX = config.Bind<float>("Advanced", "JitterScaleX", -1f, "Multiplier applied to HDRP's camera jitter before it is passed to DLSS."); JitterScaleY = config.Bind<float>("Advanced", "JitterScaleY", -1f, "Multiplier applied to HDRP's camera jitter before it is passed to DLSS."); MotionVectorScaleX = config.Bind<float>("Advanced", "MotionVectorScaleX", -1f, "Multiplier (times render width) that converts HDRP motion vectors to DLSS pixel space."); MotionVectorScaleY = config.Bind<float>("Advanced", "MotionVectorScaleY", -1f, "Multiplier (times render height) that converts HDRP motion vectors to DLSS pixel space."); ShowOverlay = config.Bind<bool>("Overlay", "ShowOverlay", false, "Show the on-screen status and log overlay."); OverlayFontSize = config.Bind<int>("Overlay", "FontSize", 16, "Overlay text size in pixels."); OverlayKey = config.Bind<KeyCode>("Overlay", "OverlayKey", (KeyCode)289, "Shows and hides the overlay."); CycleUpscalerKey = config.Bind<KeyCode>("Overlay", "CycleUpscalerKey", (KeyCode)277, "Switches between Auto, DLSS and FSR. Only active while the overlay is visible."); CyclePresetKey = config.Bind<KeyCode>("Overlay", "CyclePresetKey", (KeyCode)286, "Switches to the next DLSS preset. Only active while the overlay is visible."); CycleInjectionPointKey = config.Bind<KeyCode>("Overlay", "CycleInjectionPointKey", (KeyCode)287, "Switches to the next injection point. Only active while the overlay is visible."); CycleJitterSignKey = config.Bind<KeyCode>("Overlay", "CycleJitterSignKey", (KeyCode)288, "Steps through the four jitter sign combinations. Only active while the overlay is visible."); CycleMotionVectorSignKey = config.Bind<KeyCode>("Overlay", "CycleMotionVectorSignKey", (KeyCode)292, "Steps through the four motion vector sign combinations. Only active while the overlay is visible."); ToggleAutoExposureKey = config.Bind<KeyCode>("Overlay", "ToggleAutoExposureKey", (KeyCode)284, "Turns DLSS auto exposure on and off. Only active while the overlay is visible."); JitterCalibrationKey = config.Bind<KeyCode>("Overlay", "JitterCalibrationKey", (KeyCode)283, "Captures screenshots under every jitter sign combination (about 30 seconds, keep the camera still). Only active while the overlay is visible."); VerboseNgxLog = config.Bind<bool>("Debug", "VerboseNgxLog", false, "Write verbose NGX output to BepInEx/VRisingDLSS.native.log."); MotionProbe = config.Bind<bool>("Debug", "MotionProbe", false, "Periodically read one motion vector back from the GPU and compare it with the camera movement. Costs a small hitch every probe."); JitterCalibrationAfterSeconds = config.Bind<float>("Debug", "JitterCalibrationAfterSeconds", 0f, "This many seconds after startup, step through all jitter sign combinations and capture screenshots of each into the BepInEx folder. 0 disables it."); BenchmarkAfterSeconds = config.Bind<float>("Debug", "BenchmarkAfterSeconds", 0f, "This many seconds after startup, step through mode / preset combinations and log the DLSS GPU time of each. 0 disables it."); ScreenshotAfterSeconds = config.Bind<float>("Debug", "ScreenshotAfterSeconds", 0f, "Capture screenshots into the BepInEx folder this many seconds after startup. 0 disables it."); ScreenshotCount = config.Bind<int>("Debug", "ScreenshotCount", 1, "How many screenshots to capture, one per second."); } public static DlssModeInfo GetModeInfo(DlssMode mode) { return mode switch { DlssMode.Quality => new DlssModeInfo(66.667f, 2), DlssMode.Balanced => new DlssModeInfo(58f, 1), DlssMode.Performance => new DlssModeInfo(50f, 0), DlssMode.UltraPerformance => new DlssModeInfo(33.333f, 3), _ => new DlssModeInfo(100f, 5), }; } public DlssMode NextMode() { return NextValue(Mode.Value); } public DlssPreset NextPreset() { return NextValue(Preset.Value); } public UpscalerChoice NextUpscaler() { return NextValue(Upscaler.Value); } public DlssInjectionPoint NextInjectionPoint() { return NextValue(InjectionPoint.Value); } private static T NextValue<T>(T current) where T : struct, Enum { T[] values = Enum.GetValues<T>(); int num = Array.IndexOf(values, current); return values[(num + 1) % values.Length]; } public static void CycleSigns(ConfigEntry<float> x, ConfigEntry<float> y) { bool num = x.Value < 0f; bool flag = y.Value < 0f; float num2 = Mathf.Abs(x.Value); float num3 = Mathf.Abs(y.Value); if (num) { x.Value = num2; return; } x.Value = 0f - num2; y.Value = (flag ? num3 : (0f - num3)); } } internal enum RenderEvent { Evaluate = 1, ReleaseAllFeatures } internal enum NativeUpscaler : uint { Dlss, Fsr } internal enum BridgeState { NotInitialized, Ready, Failed } [Flags] internal enum DlssFeatureFlags : uint { None = 0u, IsHDR = 1u, MVLowRes = 2u, MVJittered = 4u, DepthInverted = 8u, AutoExposure = 0x40u } [StructLayout(LayoutKind.Sequential, Pack = 8)] internal struct EvaluateCommand { public IntPtr color; public IntPtr depth; public IntPtr motionVectors; public IntPtr biasColorMask; public IntPtr output; public uint cameraId; public uint renderWidth; public uint renderHeight; public uint outputWidth; public uint outputHeight; public int perfQuality; public int preset; public uint createFlags; public uint reset; public uint indicatorInvertY; public float jitterX; public float jitterY; public float mvScaleX; public float mvScaleY; public float preExposure; public uint probeEnabled; public uint probeX; public uint probeY; public float probeExpectedX; public float probeExpectedY; public uint upscaler; public float cameraNear; public float cameraFar; public float cameraFovVertical; public float frameTimeDeltaMilliseconds; public float sharpness; } [StructLayout(LayoutKind.Sequential, Pack = 8)] internal struct BridgeStatus { private const int UpscalerNameCapacity = 32; public int state; public int lastResult; public int dlssAvailable; public int needsUpdatedDriver; public int minDriverVersionMajor; public int minDriverVersionMinor; public uint featuresCreated; public uint evaluations; public uint failedEvaluations; public uint renderWidth; public uint renderHeight; public uint outputWidth; public uint outputHeight; public uint probeSamples; public int probeMotionFormat; public float probeMotionX; public float probeMotionY; public float probeExpectedX; public float probeExpectedY; public float probeDepth; public float evaluateGpuMilliseconds; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string upscalerName; } internal static class NativeBridge { private const string LibraryName = "VRisingDLSS.Native"; private const string LibraryFileName = "VRisingDLSS.Native.dll"; private const int ExpectedAbiVersion = 4; private static IntPtr s_Library; public static IntPtr RenderCallback { get; private set; } [DllImport("VRisingDLSS.Native")] private static extern int DLSS_GetAbiVersion(); [DllImport("VRisingDLSS.Native", CharSet = CharSet.Unicode)] private static extern void DLSS_Configure(string pluginDirectory, string logDirectory, int verboseNgxLog); [DllImport("VRisingDLSS.Native")] private static extern IntPtr DLSS_GetRenderCallback(); [DllImport("VRisingDLSS.Native")] private static extern void DLSS_GetStatus(out BridgeStatus status); [DllImport("VRisingDLSS.Native")] private static extern void DLSS_ResetFailure(); [DllImport("VRisingDLSS.Native")] private static extern void DLSS_AddRef(IntPtr resource); [DllImport("VRisingDLSS.Native")] private static extern void DLSS_Release(IntPtr resource); public static bool Load(string pluginDirectory, string logDirectory, bool verboseNgxLog) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown string text = Path.Combine(pluginDirectory, "VRisingDLSS.Native.dll"); bool flag = default(bool); if (!File.Exists(text)) { ManualLogSource logger = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("VRisingDLSS.Native.dll"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" not found in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(pluginDirectory); } logger.LogError(val); return false; } s_Library = NativeLibrary.Load(text); NativeLibrary.SetDllImportResolver(typeof(NativeBridge).Assembly, ResolveLibrary); int num = DLSS_GetAbiVersion(); if (num != 4) { ManualLogSource logger2 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("VRisingDLSS.Native.dll"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has ABI version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", expected "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(4); } logger2.LogError(val); return false; } DLSS_Configure(pluginDirectory, logDirectory, verboseNgxLog ? 1 : 0); RenderCallback = DLSS_GetRenderCallback(); return RenderCallback != IntPtr.Zero; } private static IntPtr ResolveLibrary(string name, Assembly assembly, DllImportSearchPath? searchPath) { if (!(name == "VRisingDLSS.Native")) { return IntPtr.Zero; } return s_Library; } public static BridgeStatus GetStatus() { DLSS_GetStatus(out var status); return status; } public static void ResetFailure() { DLSS_ResetFailure(); } public static void AddRef(IntPtr resource) { DLSS_AddRef(resource); } public static void Release(IntPtr resource) { DLSS_Release(resource); } } internal sealed class NativeTextureCache { private readonly struct Key : IEquatable<Key> { private readonly int m_InstanceId;