Decompiled source of OutwardFSR v1.0.1
plugins/OutwardFSR.dll
Decompiled 10 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FidelityFX; using FidelityFX.FSR3; using HarmonyLib; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Profiling; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("pierp")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+41b18cb147e98fa9ec4a5e2bc7a05e7c058be650")] [assembly: AssemblyProduct("OutwardFSR")] [assembly: AssemblyTitle("OutwardFSR")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] namespace FidelityFX { public readonly struct ResourceView { public static readonly ResourceView Unassigned = new ResourceView(default(RenderTargetIdentifier), (RenderTextureSubElement)3); public static readonly ResourceView None = new ResourceView(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)0), (RenderTextureSubElement)3); public readonly RenderTargetIdentifier RenderTarget; public readonly RenderTextureSubElement SubElement; public readonly int MipLevel; public bool IsValid { get { //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_000b: 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) RenderTargetIdentifier renderTarget = RenderTarget; return !((RenderTargetIdentifier)(ref renderTarget)).Equals(default(RenderTargetIdentifier)); } } public ResourceView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = (RenderTextureSubElement)3, int mipLevel = 0) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references) RenderTarget = renderTarget; SubElement = subElement; MipLevel = mipLevel; } } } namespace FidelityFX.FSR3 { public static class Fsr3ShaderIDs { public static readonly int SrvInputColor = Shader.PropertyToID("r_input_color_jittered"); public static readonly int SrvOpaqueOnly = Shader.PropertyToID("r_input_opaque_only"); public static readonly int SrvInputMotionVectors = Shader.PropertyToID("r_input_motion_vectors"); public static readonly int SrvInputDepth = Shader.PropertyToID("r_input_depth"); public static readonly int SrvInputExposure = Shader.PropertyToID("r_input_exposure"); public static readonly int SrvFrameInfo = Shader.PropertyToID("r_frame_info"); public static readonly int SrvReactiveMask = Shader.PropertyToID("r_reactive_mask"); public static readonly int SrvTransparencyAndCompositionMask = Shader.PropertyToID("r_transparency_and_composition_mask"); public static readonly int SrvReconstructedPrevNearestDepth = Shader.PropertyToID("r_reconstructed_previous_nearest_depth"); public static readonly int SrvDilatedMotionVectors = Shader.PropertyToID("r_dilated_motion_vectors"); public static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilated_depth"); public static readonly int SrvInternalUpscaled = Shader.PropertyToID("r_internal_upscaled_color"); public static readonly int SrvAccumulation = Shader.PropertyToID("r_accumulation"); public static readonly int SrvLumaHistory = Shader.PropertyToID("r_luma_history"); public static readonly int SrvRcasInput = Shader.PropertyToID("r_rcas_input"); public static readonly int SrvLanczosLut = Shader.PropertyToID("r_lanczos_lut"); public static readonly int SrvSpdMips = Shader.PropertyToID("r_spd_mips"); public static readonly int SrvDilatedReactiveMasks = Shader.PropertyToID("r_dilated_reactive_masks"); public static readonly int SrvNewLocks = Shader.PropertyToID("r_new_locks"); public static readonly int SrvFarthestDepth = Shader.PropertyToID("r_farthest_depth"); public static readonly int SrvFarthestDepthMip1 = Shader.PropertyToID("r_farthest_depth_mip1"); public static readonly int SrvShadingChange = Shader.PropertyToID("r_shading_change"); public static readonly int SrvCurrentLuma = Shader.PropertyToID("r_current_luma"); public static readonly int SrvPreviousLuma = Shader.PropertyToID("r_previous_luma"); public static readonly int SrvLumaInstability = Shader.PropertyToID("r_luma_instability"); public static readonly int SrvPrevColorPreAlpha = Shader.PropertyToID("r_input_prev_color_pre_alpha"); public static readonly int SrvPrevColorPostAlpha = Shader.PropertyToID("r_input_prev_color_post_alpha"); public static readonly int UavReconstructedPrevNearestDepth = Shader.PropertyToID("rw_reconstructed_previous_nearest_depth"); public static readonly int UavDilatedMotionVectors = Shader.PropertyToID("rw_dilated_motion_vectors"); public static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilated_depth"); public static readonly int UavInternalUpscaled = Shader.PropertyToID("rw_internal_upscaled_color"); public static readonly int UavAccumulation = Shader.PropertyToID("rw_accumulation"); public static readonly int UavLumaHistory = Shader.PropertyToID("rw_luma_history"); public static readonly int UavUpscaledOutput = Shader.PropertyToID("rw_upscaled_output"); public static readonly int UavDilatedReactiveMasks = Shader.PropertyToID("rw_dilated_reactive_masks"); public static readonly int UavFrameInfo = Shader.PropertyToID("rw_frame_info"); public static readonly int UavSpdAtomicCount = Shader.PropertyToID("rw_spd_global_atomic"); public static readonly int UavNewLocks = Shader.PropertyToID("rw_new_locks"); public static readonly int UavAutoReactive = Shader.PropertyToID("rw_output_autoreactive"); public static readonly int UavShadingChange = Shader.PropertyToID("rw_shading_change"); public static readonly int UavFarthestDepth = Shader.PropertyToID("rw_farthest_depth"); public static readonly int UavFarthestDepthMip1 = Shader.PropertyToID("rw_farthest_depth_mip1"); public static readonly int UavCurrentLuma = Shader.PropertyToID("rw_current_luma"); public static readonly int UavLumaInstability = Shader.PropertyToID("rw_luma_instability"); public static readonly int UavIntermediate = Shader.PropertyToID("rw_intermediate_fp16x1"); public static readonly int UavSpdMip0 = Shader.PropertyToID("rw_spd_mip0"); public static readonly int UavSpdMip1 = Shader.PropertyToID("rw_spd_mip1"); public static readonly int UavSpdMip2 = Shader.PropertyToID("rw_spd_mip2"); public static readonly int UavSpdMip3 = Shader.PropertyToID("rw_spd_mip3"); public static readonly int UavSpdMip4 = Shader.PropertyToID("rw_spd_mip4"); public static readonly int UavSpdMip5 = Shader.PropertyToID("rw_spd_mip5"); public static readonly int UavAutoComposition = Shader.PropertyToID("rw_output_autocomposition"); public static readonly int UavPrevColorPreAlpha = Shader.PropertyToID("rw_output_prev_color_pre_alpha"); public static readonly int UavPrevColorPostAlpha = Shader.PropertyToID("rw_output_prev_color_post_alpha"); public static readonly int CbFsr3Upscaler = Shader.PropertyToID("cbFSR3Upscaler"); public static readonly int CbSpd = Shader.PropertyToID("cbSPD"); public static readonly int CbRcas = Shader.PropertyToID("cbRCAS"); public static readonly int CbGenReactive = Shader.PropertyToID("cbGenerateReactive"); } public static class Fsr3Upscaler { public enum QualityMode { NativeAA, UltraQuality, Quality, Balanced, Performance, UltraPerformance } [Flags] public enum InitializationFlags { EnableHighDynamicRange = 1, EnableDisplayResolutionMotionVectors = 2, EnableMotionVectorsJitterCancellation = 4, EnableDepthInverted = 8, EnableDepthInfinite = 0x10, EnableAutoExposure = 0x20, EnableDynamicResolution = 0x40, EnableFP16Usage = 0x80, EnableDebugChecking = 0x100 } [Flags] public enum DispatchFlags { DrawDebugView = 1 } public struct ContextDescription { public InitializationFlags Flags; public Vector2Int MaxRenderSize; public Vector2Int MaxUpscaleSize; public Fsr3UpscalerShaders Shaders; } public class DispatchDescription { public ResourceView Color; public ResourceView Depth; public ResourceView MotionVectors; public ResourceView Exposure; public ResourceView Reactive; public ResourceView TransparencyAndComposition; public ResourceView Output; public Vector2 JitterOffset; public Vector2 MotionVectorScale; public Vector2Int RenderSize; public Vector2Int UpscaleSize; public bool EnableSharpening; public float Sharpness; public float FrameTimeDelta; public float PreExposure; public bool Reset; public float CameraNear; public float CameraFar; public float CameraFovAngleVertical; public float ViewSpaceToMetersFactor; public float VelocityFactor = 1f; public DispatchFlags Flags; public bool UseTextureArrays; public bool EnableAutoReactive; public ResourceView ColorOpaqueOnly; public float AutoTcThreshold = 0.05f; public float AutoTcScale = 1f; public float AutoReactiveScale = 5f; public float AutoReactiveMax = 0.9f; } public class GenerateReactiveDescription { public ResourceView ColorOpaqueOnly; public ResourceView ColorPreUpscale; public ResourceView OutReactive; public Vector2Int RenderSize; public float Scale = 0.5f; public float CutoffThreshold = 0.2f; public float BinaryValue = 0.9f; public GenerateReactiveFlags Flags = GenerateReactiveFlags.ApplyTonemap | GenerateReactiveFlags.ApplyThreshold | GenerateReactiveFlags.UseComponentsMax; } [Flags] public enum GenerateReactiveFlags { ApplyTonemap = 1, ApplyInverseTonemap = 2, ApplyThreshold = 4, UseComponentsMax = 8 } [Serializable] internal struct UpscalerConstants { public Vector2Int renderSize; public Vector2Int previousFrameRenderSize; public Vector2Int upscaleSize; public Vector2Int previousFrameUpscaleSize; public Vector2Int maxRenderSize; public Vector2Int maxUpscaleSize; public Vector4 deviceToViewDepth; public Vector2 jitterOffset; public Vector2 previousFrameJitterOffset; public Vector2 motionVectorScale; public Vector2 downscaleFactor; public Vector2 motionVectorJitterCancellation; public float tanHalfFOV; public float jitterPhaseCount; public float deltaTime; public float deltaPreExposure; public float viewSpaceToMetersFactor; public float frameIndex; public float velocityFactor; } [Serializable] internal struct SpdConstants { public uint mips; public uint numWorkGroups; public uint workGroupOffsetX; public uint workGroupOffsetY; public uint renderSizeX; public uint renderSizeY; } [Serializable] internal struct GenerateReactiveConstants { public float scale; public float threshold; public float binaryValue; public uint flags; } [Serializable] internal struct GenerateReactiveConstants2 { public float autoTcThreshold; public float autoTcScale; public float autoReactiveScale; public float autoReactiveMax; } [Serializable] internal struct RcasConstants { public readonly uint sharpness; public readonly uint halfSharp; public readonly uint dummy0; public readonly uint dummy1; public RcasConstants(uint sharpness, uint halfSharp) { this.sharpness = sharpness; this.halfSharp = halfSharp; dummy0 = (dummy1 = 0u); } } public static Fsr3UpscalerContext CreateContext(Vector2Int displaySize, Vector2Int maxRenderSize, Fsr3UpscalerShaders shaders, InitializationFlags flags = (InitializationFlags)0) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0089: Unknown result type (might be due to invalid IL or missing references) flags = ((!SystemInfo.usesReversedZBuffer) ? (flags & ~InitializationFlags.EnableDepthInverted) : (flags | InitializationFlags.EnableDepthInverted)); Debug.Log((object)$"Setting up FSR3 Upscaler with render size: {((Vector2Int)(ref maxRenderSize)).x}x{((Vector2Int)(ref maxRenderSize)).y}, display size: {((Vector2Int)(ref displaySize)).x}x{((Vector2Int)(ref displaySize)).y}, flags: {flags}"); ContextDescription contextDescription = new ContextDescription { Flags = flags, MaxUpscaleSize = displaySize, MaxRenderSize = maxRenderSize, Shaders = shaders }; Fsr3UpscalerContext fsr3UpscalerContext = new Fsr3UpscalerContext(); fsr3UpscalerContext.Create(contextDescription); return fsr3UpscalerContext; } public static float GetUpscaleRatioFromQualityMode(QualityMode qualityMode) { return qualityMode switch { QualityMode.NativeAA => 1f, QualityMode.UltraQuality => 1.2f, QualityMode.Quality => 1.5f, QualityMode.Balanced => 1.7f, QualityMode.Performance => 2f, QualityMode.UltraPerformance => 3f, _ => 1f, }; } public static void GetRenderResolutionFromQualityMode(out int renderWidth, out int renderHeight, int displayWidth, int displayHeight, QualityMode qualityMode) { float upscaleRatioFromQualityMode = GetUpscaleRatioFromQualityMode(qualityMode); renderWidth = Mathf.RoundToInt((float)displayWidth / upscaleRatioFromQualityMode); renderHeight = Mathf.RoundToInt((float)displayHeight / upscaleRatioFromQualityMode); } public static float GetMipmapBiasOffset(int renderWidth, int displayWidth) { return Mathf.Log((float)renderWidth / (float)displayWidth, 2f) - 1f; } public static int GetJitterPhaseCount(int renderWidth, int displayWidth) { return (int)(8f * Mathf.Pow((float)displayWidth / (float)renderWidth, 2f)); } public static void GetJitterOffset(out float outX, out float outY, int index, int phaseCount) { outX = Halton(index % phaseCount + 1, 2) - 0.5f; outY = Halton(index % phaseCount + 1, 3) - 0.5f; } private static float Halton(int index, int @base) { float num = 1f; float num2 = 0f; for (int num3 = index; num3 > 0; num3 = (int)Mathf.Floor((float)num3 / (float)@base)) { num /= (float)@base; num2 += num * (float)(num3 % @base); } return num2; } public static float Lanczos2(float value) { if (!(Mathf.Abs(value) < Mathf.Epsilon)) { return Mathf.Sin((float)Math.PI * value) / ((float)Math.PI * value) * (Mathf.Sin((float)Math.PI / 2f * value) / ((float)Math.PI / 2f * value)); } return 1f; } internal static void SetBufferData(this CommandBuffer commandBuffer, ComputeBuffer computeBuffer, Array data) { commandBuffer.SetComputeBufferData(computeBuffer, data); } } [CreateAssetMenu(fileName = "FSR3 Upscaler Assets", menuName = "FidelityFX/FSR3 Upscaler Assets", order = 1103)] public class Fsr3UpscalerAssets : ScriptableObject { public Fsr3UpscalerShaders shaders; } [Serializable] public class Fsr3UpscalerShaders { public ComputeShader prepareInputsPass; public ComputeShader lumaPyramidPass; public ComputeShader shadingChangePyramidPass; public ComputeShader shadingChangePass; public ComputeShader prepareReactivityPass; public ComputeShader lumaInstabilityPass; public ComputeShader accumulatePass; public ComputeShader sharpenPass; public ComputeShader autoGenReactivePass; public ComputeShader tcrAutoGenPass; public ComputeShader debugViewPass; public Fsr3UpscalerShaders Clone() { return (Fsr3UpscalerShaders)MemberwiseClone(); } public Fsr3UpscalerShaders DeepCopy() { return new Fsr3UpscalerShaders { prepareInputsPass = Object.Instantiate<ComputeShader>(prepareInputsPass), lumaPyramidPass = Object.Instantiate<ComputeShader>(lumaPyramidPass), shadingChangePyramidPass = Object.Instantiate<ComputeShader>(shadingChangePyramidPass), shadingChangePass = Object.Instantiate<ComputeShader>(shadingChangePass), prepareReactivityPass = Object.Instantiate<ComputeShader>(prepareReactivityPass), lumaInstabilityPass = Object.Instantiate<ComputeShader>(lumaInstabilityPass), accumulatePass = Object.Instantiate<ComputeShader>(accumulatePass), sharpenPass = Object.Instantiate<ComputeShader>(sharpenPass), autoGenReactivePass = Object.Instantiate<ComputeShader>(autoGenReactivePass), tcrAutoGenPass = Object.Instantiate<ComputeShader>(tcrAutoGenPass), debugViewPass = Object.Instantiate<ComputeShader>(debugViewPass) }; } public void Dispose() { Object.Destroy((Object)(object)prepareInputsPass); Object.Destroy((Object)(object)lumaPyramidPass); Object.Destroy((Object)(object)shadingChangePyramidPass); Object.Destroy((Object)(object)shadingChangePass); Object.Destroy((Object)(object)prepareReactivityPass); Object.Destroy((Object)(object)lumaInstabilityPass); Object.Destroy((Object)(object)accumulatePass); Object.Destroy((Object)(object)sharpenPass); Object.Destroy((Object)(object)autoGenReactivePass); Object.Destroy((Object)(object)tcrAutoGenPass); Object.Destroy((Object)(object)debugViewPass); } } public interface IFsr3UpscalerCallbacks { void ApplyMipmapBias(float biasOffset); void UndoMipmapBias(); } public class Fsr3UpscalerCallbacksBase : IFsr3UpscalerCallbacks { protected float CurrentBiasOffset; public virtual void ApplyMipmapBias(float biasOffset) { if (float.IsNaN(biasOffset) || float.IsInfinity(biasOffset)) { return; } CurrentBiasOffset += biasOffset; if (Mathf.Approximately(CurrentBiasOffset, 0f)) { CurrentBiasOffset = 0f; } Texture2D[] array = Resources.FindObjectsOfTypeAll<Texture2D>(); foreach (Texture2D val in array) { if (((Texture)val).mipmapCount > 1) { ((Texture)val).mipMapBias = ((Texture)val).mipMapBias + biasOffset; } } } public virtual void UndoMipmapBias() { if (CurrentBiasOffset != 0f) { ApplyMipmapBias(0f - CurrentBiasOffset); } } } public class Fsr3UpscalerContext { private const int MaxQueuedFrames = 16; private Fsr3Upscaler.ContextDescription _contextDescription; private CommandBuffer _commandBuffer; private Fsr3UpscalerPass _prepareInputsPass; private Fsr3UpscalerPass _lumaPyramidPass; private Fsr3UpscalerPass _shadingChangePyramidPass; private Fsr3UpscalerPass _shadingChangePass; private Fsr3UpscalerPass _prepareReactivityPass; private Fsr3UpscalerPass _lumaInstabilityPass; private Fsr3UpscalerPass _accumulatePass; private Fsr3UpscalerPass _sharpenPass; private Fsr3UpscalerPass _generateReactivePass; private Fsr3UpscalerPass _tcrAutogeneratePass; private readonly Fsr3UpscalerResources _resources = new Fsr3UpscalerResources(); private ComputeBuffer _upscalerConstantsBuffer; private readonly Fsr3Upscaler.UpscalerConstants[] _upscalerConstantsArray = new Fsr3Upscaler.UpscalerConstants[1]; private ComputeBuffer _spdConstantsBuffer; private readonly Fsr3Upscaler.SpdConstants[] _spdConstantsArray = new Fsr3Upscaler.SpdConstants[1]; private ComputeBuffer _rcasConstantsBuffer; private readonly Fsr3Upscaler.RcasConstants[] _rcasConstantsArray = new Fsr3Upscaler.RcasConstants[1]; private ComputeBuffer _generateReactiveConstantsBuffer; private readonly Fsr3Upscaler.GenerateReactiveConstants[] _generateReactiveConstantsArray = new Fsr3Upscaler.GenerateReactiveConstants[1]; private ComputeBuffer _tcrAutogenerateConstantsBuffer; private readonly Fsr3Upscaler.GenerateReactiveConstants2[] _tcrAutogenerateConstantsArray = new Fsr3Upscaler.GenerateReactiveConstants2[1]; private bool _firstExecution; private int _resourceFrameIndex; private Vector2 _previousJitterOffset; private float _preExposure; private float _previousFramePreExposure; private static readonly Fsr3Upscaler.RcasConstants[] RcasConfigs = new Fsr3Upscaler.RcasConstants[21] { new Fsr3Upscaler.RcasConstants(1048576000u, 872428544u), new Fsr3Upscaler.RcasConstants(1049178080u, 877212745u), new Fsr3Upscaler.RcasConstants(1049823372u, 882390168u), new Fsr3Upscaler.RcasConstants(1050514979u, 887895276u), new Fsr3Upscaler.RcasConstants(1051256227u, 893859143u), new Fsr3Upscaler.RcasConstants(1052050675u, 900216232u), new Fsr3Upscaler.RcasConstants(1052902144u, 907032080u), new Fsr3Upscaler.RcasConstants(1053814727u, 914306687u), new Fsr3Upscaler.RcasConstants(1054792807u, 922105590u), new Fsr3Upscaler.RcasConstants(1055841087u, 930494326u), new Fsr3Upscaler.RcasConstants(1056964608u, 939538432u), new Fsr3Upscaler.RcasConstants(1057566688u, 944322633u), new Fsr3Upscaler.RcasConstants(1058211980u, 949500056u), new Fsr3Upscaler.RcasConstants(1058903587u, 955005164u), new Fsr3Upscaler.RcasConstants(1059644835u, 960969031u), new Fsr3Upscaler.RcasConstants(1060439283u, 967326120u), new Fsr3Upscaler.RcasConstants(1061290752u, 974141968u), new Fsr3Upscaler.RcasConstants(1062203335u, 981416575u), new Fsr3Upscaler.RcasConstants(1063181415u, 989215478u), new Fsr3Upscaler.RcasConstants(1064229695u, 997604214u), new Fsr3Upscaler.RcasConstants(1065353216u, 1006648320u) }; private ref Fsr3Upscaler.UpscalerConstants UpscalerConsts => ref _upscalerConstantsArray[0]; private ref Fsr3Upscaler.SpdConstants SpdConsts => ref _spdConstantsArray[0]; private ref Fsr3Upscaler.RcasConstants RcasConsts => ref _rcasConstantsArray[0]; private ref Fsr3Upscaler.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0]; private ref Fsr3Upscaler.GenerateReactiveConstants2 TcrAutoGenConsts => ref _tcrAutogenerateConstantsArray[0]; public void Create(Fsr3Upscaler.ContextDescription contextDescription) { //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_001d: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) _contextDescription = contextDescription; _commandBuffer = new CommandBuffer { name = "FSR3 Upscaler" }; _upscalerConstantsBuffer = CreateConstantBuffer<Fsr3Upscaler.UpscalerConstants>(); _spdConstantsBuffer = CreateConstantBuffer<Fsr3Upscaler.SpdConstants>(); _rcasConstantsBuffer = CreateConstantBuffer<Fsr3Upscaler.RcasConstants>(); _generateReactiveConstantsBuffer = CreateConstantBuffer<Fsr3Upscaler.GenerateReactiveConstants>(); _tcrAutogenerateConstantsBuffer = CreateConstantBuffer<Fsr3Upscaler.GenerateReactiveConstants2>(); _firstExecution = true; _resourceFrameIndex = 0; UpscalerConsts.maxUpscaleSize = _contextDescription.MaxUpscaleSize; UpscalerConsts.velocityFactor = 1f; _resources.Create(_contextDescription); CreatePasses(); } private void CreatePasses() { _prepareInputsPass = new Fsr3UpscalerPrepareInputsPass(_contextDescription, _resources, _upscalerConstantsBuffer); _lumaPyramidPass = new Fsr3UpscalerLumaPyramidPass(_contextDescription, _resources, _upscalerConstantsBuffer, _spdConstantsBuffer); _shadingChangePyramidPass = new Fsr3UpscalerShadingChangePyramidPass(_contextDescription, _resources, _upscalerConstantsBuffer, _spdConstantsBuffer); _shadingChangePass = new Fsr3UpscalerShadingChangePass(_contextDescription, _resources, _upscalerConstantsBuffer); _prepareReactivityPass = new Fsr3UpscalerPrepareReactivityPass(_contextDescription, _resources, _upscalerConstantsBuffer); _lumaInstabilityPass = new Fsr3UpscalerLumaInstabilityPass(_contextDescription, _resources, _upscalerConstantsBuffer); _accumulatePass = new Fsr3UpscalerAccumulatePass(_contextDescription, _resources, _upscalerConstantsBuffer); _sharpenPass = new Fsr3UpscalerSharpenPass(_contextDescription, _resources, _upscalerConstantsBuffer, _rcasConstantsBuffer); _generateReactivePass = new Fsr3UpscalerGenerateReactivePass(_contextDescription, _resources, _generateReactiveConstantsBuffer); _tcrAutogeneratePass = new Fsr3UpscalerTcrAutogeneratePass(_contextDescription, _resources, _upscalerConstantsBuffer, _tcrAutogenerateConstantsBuffer); } public void Destroy() { DestroyPass(ref _tcrAutogeneratePass); DestroyPass(ref _generateReactivePass); DestroyPass(ref _lumaPyramidPass); DestroyPass(ref _sharpenPass); DestroyPass(ref _accumulatePass); DestroyPass(ref _prepareReactivityPass); DestroyPass(ref _shadingChangePass); DestroyPass(ref _shadingChangePyramidPass); DestroyPass(ref _lumaInstabilityPass); DestroyPass(ref _prepareInputsPass); _resources.Destroy(); DestroyConstantBuffer(ref _tcrAutogenerateConstantsBuffer); DestroyConstantBuffer(ref _generateReactiveConstantsBuffer); DestroyConstantBuffer(ref _rcasConstantsBuffer); DestroyConstantBuffer(ref _spdConstantsBuffer); DestroyConstantBuffer(ref _upscalerConstantsBuffer); if (_commandBuffer != null) { _commandBuffer.Dispose(); _commandBuffer = null; } } public void Dispatch(Fsr3Upscaler.DispatchDescription dispatchParams) { _commandBuffer.Clear(); Dispatch(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } public void Dispatch(Fsr3Upscaler.DispatchDescription dispatchParams, CommandBuffer commandBuffer) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDebugChecking) != 0) { DebugCheckDispatch(dispatchParams); } if (dispatchParams.UseTextureArrays) { commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); } if (_firstExecution) { commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.Accumulation[0])); commandBuffer.ClearRenderTarget(false, true, Color.clear); commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.Accumulation[1])); commandBuffer.ClearRenderTarget(false, true, Color.clear); commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.Luma[0])); commandBuffer.ClearRenderTarget(false, true, Color.clear); commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.Luma[1])); commandBuffer.ClearRenderTarget(false, true, Color.clear); } int num = _resourceFrameIndex % 2; bool flag = dispatchParams.Reset || _firstExecution; _firstExecution = false; if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) { dispatchParams.Exposure = new ResourceView(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.FrameInfo), (RenderTextureSubElement)3); } else if (!dispatchParams.Exposure.IsValid) { dispatchParams.Exposure = new ResourceView(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.DefaultExposure), (RenderTextureSubElement)3); } if (dispatchParams.EnableAutoReactive) { if ((Object)(object)_resources.AutoReactive == (Object)null) { _resources.CreateTcrAutogenResources(_contextDescription); } if (flag) { RenderTargetIdentifier val = (dispatchParams.ColorOpaqueOnly.IsValid ? dispatchParams.ColorOpaqueOnly.RenderTarget : RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.SrvOpaqueOnly)); commandBuffer.Blit((Texture)(object)_resources.PrevPreAlpha[num ^ 1], val); } } else if ((Object)(object)_resources.AutoReactive != (Object)null) { _resources.DestroyTcrAutogenResources(); } if (!dispatchParams.Reactive.IsValid) { dispatchParams.Reactive = new ResourceView(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.DefaultReactive), (RenderTextureSubElement)3); } if (!dispatchParams.TransparencyAndComposition.IsValid) { dispatchParams.TransparencyAndComposition = new ResourceView(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.DefaultReactive), (RenderTextureSubElement)3); } Fsr3UpscalerResources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); SetupConstants(dispatchParams, flag); int dispatchX = (((Vector2Int)(ref UpscalerConsts.renderSize)).x + 7) / 8; int dispatchY = (((Vector2Int)(ref UpscalerConsts.renderSize)).y + 7) / 8; int dispatchX2 = (((Vector2Int)(ref UpscalerConsts.upscaleSize)).x + 7) / 8; int dispatchY2 = (((Vector2Int)(ref UpscalerConsts.upscaleSize)).y + 7) / 8; int dispatchX3 = (((Vector2Int)(ref UpscalerConsts.renderSize)).x / 2 + 7) / 8; int dispatchY3 = (((Vector2Int)(ref UpscalerConsts.renderSize)).y / 2 + 7) / 8; if (flag) { commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.Accumulation[num ^ 1])); commandBuffer.ClearRenderTarget(false, true, Color.clear); commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.SpdMips)); commandBuffer.ClearRenderTarget(false, true, Color.clear); commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.FrameInfo)); commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1f, 0f, 0f)); commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.SpdAtomicCounter)); commandBuffer.ClearRenderTarget(false, true, Color.clear); } bool flag2 = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) == Fsr3Upscaler.InitializationFlags.EnableDepthInverted; commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.ReconstructedPrevNearestDepth)); commandBuffer.ClearRenderTarget(false, true, flag2 ? Color.clear : Color.white); SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); commandBuffer.SetBufferData(_upscalerConstantsBuffer, _upscalerConstantsArray); commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); if (dispatchParams.EnableAutoReactive) { GenerateTransparencyCompositionReactive(dispatchParams, commandBuffer, num); dispatchParams.Reactive = new ResourceView(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.AutoReactive), (RenderTextureSubElement)3); dispatchParams.TransparencyAndComposition = new ResourceView(RenderTargetIdentifier.op_Implicit((Texture)(object)_resources.AutoComposition), (RenderTextureSubElement)3); } _prepareInputsPass.ScheduleDispatch(commandBuffer, dispatchParams, num, dispatchX, dispatchY); _lumaPyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, num, ((Vector2Int)(ref dispatchThreadGroupCount)).x, ((Vector2Int)(ref dispatchThreadGroupCount)).y); _shadingChangePyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, num, ((Vector2Int)(ref dispatchThreadGroupCount)).x, ((Vector2Int)(ref dispatchThreadGroupCount)).y); _shadingChangePass.ScheduleDispatch(commandBuffer, dispatchParams, num, dispatchX3, dispatchY3); _prepareReactivityPass.ScheduleDispatch(commandBuffer, dispatchParams, num, dispatchX, dispatchY); _lumaInstabilityPass.ScheduleDispatch(commandBuffer, dispatchParams, num, dispatchX, dispatchY); _accumulatePass.ScheduleDispatch(commandBuffer, dispatchParams, num, dispatchX2, dispatchY2); if (dispatchParams.EnableSharpening) { SetupRcasConstants(dispatchParams); commandBuffer.SetBufferData(_rcasConstantsBuffer, _rcasConstantsArray); int dispatchX4 = (((Vector2Int)(ref UpscalerConsts.upscaleSize)).x + 16 - 1) / 16; int dispatchY4 = (((Vector2Int)(ref UpscalerConsts.upscaleSize)).y + 16 - 1) / 16; _sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, num, dispatchX4, dispatchY4); } _resourceFrameIndex = (_resourceFrameIndex + 1) % 16; Fsr3UpscalerResources.DestroyAliasableResources(commandBuffer); commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); } public void GenerateReactiveMask(Fsr3Upscaler.GenerateReactiveDescription dispatchParams) { _commandBuffer.Clear(); GenerateReactiveMask(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } public void GenerateReactiveMask(Fsr3Upscaler.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) { int dispatchX = (((Vector2Int)(ref dispatchParams.RenderSize)).x + 7) / 8; int dispatchY = (((Vector2Int)(ref dispatchParams.RenderSize)).y + 7) / 8; GenReactiveConsts.scale = dispatchParams.Scale; GenReactiveConsts.threshold = dispatchParams.CutoffThreshold; GenReactiveConsts.binaryValue = dispatchParams.BinaryValue; GenReactiveConsts.flags = (uint)dispatchParams.Flags; commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray); ((Fsr3UpscalerGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchX, dispatchY); } private void GenerateTransparencyCompositionReactive(Fsr3Upscaler.DispatchDescription dispatchParams, CommandBuffer commandBuffer, int frameIndex) { int dispatchX = (((Vector2Int)(ref dispatchParams.RenderSize)).x + 7) / 8; int dispatchY = (((Vector2Int)(ref dispatchParams.RenderSize)).y + 7) / 8; TcrAutoGenConsts.autoTcThreshold = dispatchParams.AutoTcThreshold; TcrAutoGenConsts.autoTcScale = dispatchParams.AutoTcScale; TcrAutoGenConsts.autoReactiveScale = dispatchParams.AutoReactiveScale; TcrAutoGenConsts.autoReactiveMax = dispatchParams.AutoReactiveMax; commandBuffer.SetBufferData(_tcrAutogenerateConstantsBuffer, _tcrAutogenerateConstantsArray); _tcrAutogeneratePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY); } private void SetupConstants(Fsr3Upscaler.DispatchDescription dispatchParams, bool resetAccumulation) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001a: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c2: 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_00fb: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) ref Fsr3Upscaler.UpscalerConstants upscalerConsts = ref UpscalerConsts; upscalerConsts.previousFrameJitterOffset = upscalerConsts.jitterOffset; upscalerConsts.jitterOffset = dispatchParams.JitterOffset; upscalerConsts.previousFrameRenderSize = upscalerConsts.renderSize; upscalerConsts.renderSize = dispatchParams.RenderSize; upscalerConsts.maxRenderSize = _contextDescription.MaxRenderSize; float num = (float)((Vector2Int)(ref dispatchParams.RenderSize)).x / (float)((Vector2Int)(ref dispatchParams.RenderSize)).y; float num2 = Mathf.Atan(Mathf.Tan(dispatchParams.CameraFovAngleVertical / 2f) * num) * 2f; upscalerConsts.tanHalfFOV = Mathf.Tan(num2 * 0.5f); upscalerConsts.viewSpaceToMetersFactor = ((dispatchParams.ViewSpaceToMetersFactor > 0f) ? dispatchParams.ViewSpaceToMetersFactor : 1f); upscalerConsts.deviceToViewDepth = SetupDeviceDepthToViewSpaceDepthParams(dispatchParams); upscalerConsts.previousFrameUpscaleSize = upscalerConsts.upscaleSize; if (((Vector2Int)(ref dispatchParams.UpscaleSize)).x == 0 && ((Vector2Int)(ref dispatchParams.UpscaleSize)).y == 0) { upscalerConsts.upscaleSize = _contextDescription.MaxUpscaleSize; } else { upscalerConsts.upscaleSize = dispatchParams.UpscaleSize; } upscalerConsts.downscaleFactor = new Vector2((float)((Vector2Int)(ref upscalerConsts.renderSize)).x / (float)((Vector2Int)(ref upscalerConsts.upscaleSize)).x, (float)((Vector2Int)(ref upscalerConsts.renderSize)).y / (float)((Vector2Int)(ref upscalerConsts.upscaleSize)).y); upscalerConsts.deltaPreExposure = 1f; _previousFramePreExposure = _preExposure; _preExposure = ((dispatchParams.PreExposure != 0f) ? dispatchParams.PreExposure : 1f); if (_previousFramePreExposure > 0f) { upscalerConsts.deltaPreExposure = _preExposure / _previousFramePreExposure; } Vector2Int val = (((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0) ? upscalerConsts.upscaleSize : upscalerConsts.renderSize); upscalerConsts.motionVectorScale = dispatchParams.MotionVectorScale / Vector2Int.op_Implicit(val); if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) { upscalerConsts.motionVectorJitterCancellation = (_previousJitterOffset - upscalerConsts.jitterOffset) / Vector2Int.op_Implicit(val); _previousJitterOffset = upscalerConsts.jitterOffset; } int jitterPhaseCount = Fsr3Upscaler.GetJitterPhaseCount(((Vector2Int)(ref dispatchParams.RenderSize)).x, ((Vector2Int)(ref _contextDescription.MaxUpscaleSize)).x); if (resetAccumulation || upscalerConsts.jitterPhaseCount == 0f) { upscalerConsts.jitterPhaseCount = jitterPhaseCount; } else { int num3 = (int)((float)jitterPhaseCount - upscalerConsts.jitterPhaseCount); if (num3 > 0) { upscalerConsts.jitterPhaseCount += 1f; } else if (num3 < 0) { upscalerConsts.jitterPhaseCount -= 1f; } } upscalerConsts.deltaTime = Mathf.Clamp01(dispatchParams.FrameTimeDelta); if (resetAccumulation) { upscalerConsts.frameIndex = 0f; } else { upscalerConsts.frameIndex += 1f; } upscalerConsts.velocityFactor = dispatchParams.VelocityFactor; } private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr3Upscaler.DispatchDescription dispatchParams) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) bool flag = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0; bool flag2 = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInfinite) != 0; float num = Mathf.Min(dispatchParams.CameraNear, dispatchParams.CameraFar); float num2 = Mathf.Max(dispatchParams.CameraNear, dispatchParams.CameraFar); if (flag) { float num3 = num2; num2 = num; num = num3; } float num4 = num2 / (num - num2); Vector4 val = default(Vector4); ((Vector4)(ref val))..ctor(num4, -1f - Mathf.Epsilon, num4, 0f + Mathf.Epsilon); Vector4 val2 = default(Vector4); ((Vector4)(ref val2))..ctor(num4 * num, 0f - num - Mathf.Epsilon, num4 * num, num2); float num5 = (float)((Vector2Int)(ref dispatchParams.RenderSize)).x / (float)((Vector2Int)(ref dispatchParams.RenderSize)).y; float num6 = Mathf.Cos(0.5f * dispatchParams.CameraFovAngleVertical) / Mathf.Sin(0.5f * dispatchParams.CameraFovAngleVertical); int num7 = (flag ? 2 : 0) + (flag2 ? 1 : 0); return new Vector4(-1f * ((Vector4)(ref val))[num7], ((Vector4)(ref val2))[num7], num5 / num6, 1f / num6); } private void SetupRcasConstants(Fsr3Upscaler.DispatchDescription dispatchParams) { int num = Mathf.RoundToInt(Mathf.Clamp01(dispatchParams.Sharpness) * (float)(RcasConfigs.Length - 1)); RcasConsts = RcasConfigs[num]; } private void SetupSpdConstants(Fsr3Upscaler.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) SpdSetup(new RectInt(0, 0, ((Vector2Int)(ref dispatchParams.RenderSize)).x, ((Vector2Int)(ref dispatchParams.RenderSize)).y), out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips); ref Fsr3Upscaler.SpdConstants spdConsts = ref SpdConsts; spdConsts.numWorkGroups = (uint)((Vector2Int)(ref numWorkGroupsAndMips)).x; spdConsts.mips = (uint)((Vector2Int)(ref numWorkGroupsAndMips)).y; spdConsts.workGroupOffsetX = (uint)((Vector2Int)(ref workGroupOffset)).x; spdConsts.workGroupOffsetY = (uint)((Vector2Int)(ref workGroupOffset)).y; spdConsts.renderSizeX = (uint)((Vector2Int)(ref dispatchParams.RenderSize)).x; spdConsts.renderSizeY = (uint)((Vector2Int)(ref dispatchParams.RenderSize)).y; } private static void SpdSetup(RectInt rectInfo, out Vector2Int dispatchThreadGroupCount, out Vector2Int workGroupOffset, out Vector2Int numWorkGroupsAndMips, int mips = -1) { //IL_0015: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) //IL_007d: Unknown result type (might be due to invalid IL or missing references) workGroupOffset = new Vector2Int(((RectInt)(ref rectInfo)).x / 64, ((RectInt)(ref rectInfo)).y / 64); int num = (((RectInt)(ref rectInfo)).x + ((RectInt)(ref rectInfo)).width - 1) / 64; int num2 = (((RectInt)(ref rectInfo)).y + ((RectInt)(ref rectInfo)).height - 1) / 64; dispatchThreadGroupCount = new Vector2Int(num + 1 - ((Vector2Int)(ref workGroupOffset)).x, num2 + 1 - ((Vector2Int)(ref workGroupOffset)).y); numWorkGroupsAndMips = new Vector2Int(((Vector2Int)(ref dispatchThreadGroupCount)).x * ((Vector2Int)(ref dispatchThreadGroupCount)).y, mips); if (mips < 0) { float num3 = Math.Max(((RectInt)(ref rectInfo)).width, ((RectInt)(ref rectInfo)).height); ((Vector2Int)(ref numWorkGroupsAndMips)).y = Math.Min(Mathf.FloorToInt(Mathf.Log(num3, 2f)), 12); } } private void DebugCheckDispatch(Fsr3Upscaler.DispatchDescription dispatchParams) { if (!dispatchParams.Color.IsValid) { Debug.LogError((object)"Color resource is null"); } if (!dispatchParams.Depth.IsValid) { Debug.LogError((object)"Depth resource is null"); } if (!dispatchParams.MotionVectors.IsValid) { Debug.LogError((object)"MotionVectors resource is null"); } if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) { Debug.LogWarning((object)"Exposure resource provided, however auto exposure flag is present"); } if (!dispatchParams.Output.IsValid) { Debug.LogError((object)"Output resource is null"); } if (Mathf.Abs(dispatchParams.JitterOffset.x) > 1f || Mathf.Abs(dispatchParams.JitterOffset.y) > 1f) { Debug.LogWarning((object)"JitterOffset contains value outside of expected range [-1.0, 1.0]"); } if (dispatchParams.MotionVectorScale.x > (float)((Vector2Int)(ref _contextDescription.MaxRenderSize)).x || dispatchParams.MotionVectorScale.y > (float)((Vector2Int)(ref _contextDescription.MaxRenderSize)).y) { Debug.LogWarning((object)"MotionVectorScale contains scale value greater than MaxRenderSize"); } if (dispatchParams.MotionVectorScale.x == 0f || dispatchParams.MotionVectorScale.y == 0f) { Debug.LogWarning((object)"MotionVectorScale contains zero scale value"); } if (((Vector2Int)(ref dispatchParams.RenderSize)).x > ((Vector2Int)(ref _contextDescription.MaxRenderSize)).x || ((Vector2Int)(ref dispatchParams.RenderSize)).y > ((Vector2Int)(ref _contextDescription.MaxRenderSize)).y) { Debug.LogWarning((object)"RenderSize is greater than context MaxRenderSize"); } if (((Vector2Int)(ref dispatchParams.RenderSize)).x == 0 || ((Vector2Int)(ref dispatchParams.RenderSize)).y == 0) { Debug.LogWarning((object)"RenderSize contains zero dimension"); } if (dispatchParams.Sharpness < 0f || dispatchParams.Sharpness > 1f) { Debug.LogWarning((object)"Sharpness contains value outside of expected range [0.0, 1.0]"); } if (dispatchParams.FrameTimeDelta > 1f) { Debug.LogWarning((object)"FrameTimeDelta is greater than 1.0f - this value should be seconds (~0.0166 for 60fps)"); } if (dispatchParams.PreExposure == 0f) { Debug.LogError((object)"PreExposure provided as 0.0f which is invalid"); } bool flag = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInfinite) != 0; if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) { if (dispatchParams.CameraNear < dispatchParams.CameraFar) { Debug.LogWarning((object)"EnableDepthInverted flag is present yet CameraNear is less than CameraFar"); } if (flag && dispatchParams.CameraNear < float.MaxValue) { Debug.LogWarning((object)"EnableDepthInfinite and EnableDepthInverted present, yet CameraNear != float.MaxValue"); } if (dispatchParams.CameraFar < 0.075f) { Debug.LogWarning((object)"EnableDepthInverted present, CameraFar value is very low which may result in depth separation artefacting"); } } else { if (dispatchParams.CameraNear > dispatchParams.CameraFar) { Debug.LogWarning((object)"CameraNear is greater than CameraFar in non-inverted-depth context"); } if (flag && dispatchParams.CameraFar < float.MaxValue) { Debug.LogWarning((object)"EnableDepthInfinite present, yet CameraFar != float.MaxValue"); } if (dispatchParams.CameraNear < 0.075f) { Debug.LogWarning((object)"CameraNear value is very low which may result in depth separation artefacting"); } } if (dispatchParams.CameraFovAngleVertical <= 0f) { Debug.LogError((object)"CameraFovAngleVertical is 0.0f - this value should be > 0.0f"); } if (dispatchParams.CameraFovAngleVertical > (float)Math.PI) { Debug.LogError((object)"CameraFovAngleVertical is greater than 180 degrees/PI"); } } private static ComputeBuffer CreateConstantBuffer<TConstants>() where TConstants : struct { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ComputeBuffer(1, Marshal.SizeOf<TConstants>(), (ComputeBufferType)8); } private static void DestroyConstantBuffer(ref ComputeBuffer bufferRef) { if (bufferRef != null) { bufferRef.Release(); bufferRef = null; } } private static void DestroyPass(ref Fsr3UpscalerPass pass) { if (pass != null) { pass.Dispose(); pass = null; } } } internal abstract class Fsr3UpscalerPass : IDisposable { protected readonly Fsr3Upscaler.ContextDescription ContextDescription; protected readonly Fsr3UpscalerResources Resources; protected readonly ComputeBuffer Constants; protected ComputeShader ComputeShader; protected int KernelIndex; private CustomSampler _sampler; protected Fsr3UpscalerPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) { ContextDescription = contextDescription; Resources = resources; Constants = constants; } public virtual void Dispose() { } public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY); } protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); protected void InitComputeShader(string passName, ComputeShader shader) { InitComputeShader(passName, shader, ContextDescription.Flags); } private void InitComputeShader(string passName, ComputeShader shader, Fsr3Upscaler.InitializationFlags flags) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)shader == (Object)null) { throw new MissingReferenceException("Shader for FSR3 Upscaler pass '" + passName + "' could not be loaded! Please ensure it is included in the project correctly."); } ComputeShader = shader; KernelIndex = ComputeShader.FindKernel("CS"); _sampler = CustomSampler.Create(passName, false); if ((flags & Fsr3Upscaler.InitializationFlags.EnableHighDynamicRange) != 0) { ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT"); } if ((flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) { ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); } if ((flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) { ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS"); } if ((flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) { ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH"); } if (false) { ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE"); } if ((flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) { ComputeShader.EnableKeyword("FFX_HALF"); } } [Conditional("ENABLE_PROFILER")] protected void BeginSample(CommandBuffer cmd) { cmd.BeginSample(_sampler); } [Conditional("ENABLE_PROFILER")] protected void EndSample(CommandBuffer cmd) { cmd.EndSample(_sampler); } } internal class Fsr3UpscalerPrepareInputsPass : Fsr3UpscalerPass { public Fsr3UpscalerPrepareInputsPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { InitComputeShader("Prepare Inputs", contextDescription.Shaders.prepareInputsPass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_0028: 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_0051: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) ref ResourceView color = ref dispatchParams.Color; ref ResourceView depth = ref dispatchParams.Depth; ref ResourceView motionVectors = ref dispatchParams.MotionVectors; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavDilatedMotionVectors, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.DilatedVelocity)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavDilatedDepth, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.DilatedDepth)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavReconstructedPrevNearestDepth, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.ReconstructedPrevNearestDepth)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFarthestDepth, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavIntermediate)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavCurrentLuma, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Luma[frameIndex])); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerLumaPyramidPass : Fsr3UpscalerPass { private readonly ComputeBuffer _spdConstants; public Fsr3UpscalerLumaPyramidPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) : base(contextDescription, resources, constants) { _spdConstants = spdConstants; InitComputeShader("Compute Luminance Pyramid", contextDescription.Shaders.lumaPyramidPass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_001f: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Luma[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepth, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavIntermediate)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdAtomicCount, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdAtomicCounter)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFrameInfo, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.FrameInfo)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip0, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 0); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip1, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 1); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip2, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 2); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip3, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 3); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip4, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 4); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip5, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 5); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf<Fsr3Upscaler.SpdConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerShadingChangePyramidPass : Fsr3UpscalerPass { private readonly ComputeBuffer _spdConstants; public Fsr3UpscalerShadingChangePyramidPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) : base(contextDescription, resources, constants) { _spdConstants = spdConstants; InitComputeShader("Compute Shading Change Pyramid", contextDescription.Shaders.shadingChangePyramidPass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) //IL_0095: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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) ref ResourceView exposure = ref dispatchParams.Exposure; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Luma[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPreviousLuma, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Luma[frameIndex ^ 1])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.DilatedVelocity)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdAtomicCount, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdAtomicCounter)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip0, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 0); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip1, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 1); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip2, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 2); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip3, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 3); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip4, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 4); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip5, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips), 5); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf<Fsr3Upscaler.SpdConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerShadingChangePass : Fsr3UpscalerPass { public Fsr3UpscalerShadingChangePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { InitComputeShader("Compute Shading Change", contextDescription.Shaders.shadingChangePass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvSpdMips, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.SpdMips)); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerPrepareReactivityPass : Fsr3UpscalerPass { public Fsr3UpscalerPrepareReactivityPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { InitComputeShader("Prepare Reactivity", contextDescription.Shaders.prepareReactivityPass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) ref ResourceView exposure = ref dispatchParams.Exposure; ref ResourceView reactive = ref dispatchParams.Reactive; ref ResourceView transparencyAndComposition = ref dispatchParams.TransparencyAndComposition; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReconstructedPrevNearestDepth, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.ReconstructedPrevNearestDepth)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.DilatedVelocity)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedDepth, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.DilatedDepth)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvTransparencyAndCompositionMask, transparencyAndComposition.RenderTarget, transparencyAndComposition.MipLevel, transparencyAndComposition.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvAccumulation, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Accumulation[frameIndex ^ 1])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvShadingChange, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavShadingChange)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Luma[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAccumulation, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Accumulation[frameIndex])); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerLumaInstabilityPass : Fsr3UpscalerPass { public Fsr3UpscalerLumaInstabilityPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { InitComputeShader("Compute Luminance Instability", contextDescription.Shaders.lumaInstabilityPass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_001a: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) ref ResourceView exposure = ref dispatchParams.Exposure; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavDilatedReactiveMasks)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.DilatedVelocity)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFrameInfo, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.FrameInfo)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaHistory, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.LumaHistory[frameIndex ^ 1])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepthMip1, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavFarthestDepthMip1)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Luma[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLumaHistory, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.LumaHistory[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLumaInstability, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavIntermediate)); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerAccumulatePass : Fsr3UpscalerPass { private const string SharpeningKeyword = "FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING"; public Fsr3UpscalerAccumulatePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { InitComputeShader("Accumulate", contextDescription.Shaders.accumulatePass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_00dd: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) if (dispatchParams.EnableSharpening) { commandBuffer.EnableShaderKeyword("FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING"); } else { commandBuffer.DisableShaderKeyword("FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING"); } ref ResourceView color = ref dispatchParams.Color; ref ResourceView exposure = ref dispatchParams.Exposure; ref ResourceView output = ref dispatchParams.Output; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavDilatedReactiveMasks)); if ((ContextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.DilatedVelocity)); } else { ref ResourceView motionVectors = ref dispatchParams.MotionVectors; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); } commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInternalUpscaled, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.InternalUpscaled[frameIndex ^ 1])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLanczosLut, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.LanczosLut)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepthMip1, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavFarthestDepthMip1)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.Luma[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaInstability, RenderTargetIdentifier.op_Implicit(Fsr3ShaderIDs.UavIntermediate)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavInternalUpscaled, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.InternalUpscaled[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerSharpenPass : Fsr3UpscalerPass { private readonly ComputeBuffer _rcasConstants; public Fsr3UpscalerSharpenPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer rcasConstants) : base(contextDescription, resources, constants) { _rcasConstants = rcasConstants; InitComputeShader("RCAS Sharpening", contextDescription.Shaders.sharpenPass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_001a: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) ref ResourceView exposure = ref dispatchParams.Exposure; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvRcasInput, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.InternalUpscaled[frameIndex])); ref ResourceView output = ref dispatchParams.Output; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbRcas, _rcasConstants, 0, Marshal.SizeOf<Fsr3Upscaler.RcasConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerGenerateReactivePass : Fsr3UpscalerPass { private readonly ComputeBuffer _generateReactiveConstants; public Fsr3UpscalerGenerateReactivePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer generateReactiveConstants) : base(contextDescription, resources, null) { _generateReactiveConstants = generateReactiveConstants; InitComputeShader("Auto-Generate Reactive Mask", contextDescription.Shaders.autoGenReactivePass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { } public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) { //IL_0028: 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_0051: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) ref ResourceView colorOpaqueOnly = ref dispatchParams.ColorOpaqueOnly; ref ResourceView colorPreUpscale = ref dispatchParams.ColorPreUpscale; ref ResourceView outReactive = ref dispatchParams.OutReactive; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, colorOpaqueOnly.RenderTarget, colorOpaqueOnly.MipLevel, colorOpaqueOnly.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, colorPreUpscale.RenderTarget, colorPreUpscale.MipLevel, colorPreUpscale.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, outReactive.RenderTarget, outReactive.MipLevel, outReactive.SubElement); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf<Fsr3Upscaler.GenerateReactiveConstants>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerTcrAutogeneratePass : Fsr3UpscalerPass { private readonly ComputeBuffer _tcrAutogenerateConstants; public Fsr3UpscalerTcrAutogeneratePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer tcrAutogenerateConstants) : base(contextDescription, resources, constants) { _tcrAutogenerateConstants = tcrAutogenerateConstants; InitComputeShader("Auto-Generate Transparency & Composition Mask", contextDescription.Shaders.tcrAutoGenPass); } protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00eb: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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_01e0: Unknown result type (might be due to invalid IL or missing references) ref ResourceView color = ref dispatchParams.Color; ref ResourceView motionVectors = ref dispatchParams.MotionVectors; ref ResourceView colorOpaqueOnly = ref dispatchParams.ColorOpaqueOnly; ref ResourceView reactive = ref dispatchParams.Reactive; ref ResourceView transparencyAndComposition = ref dispatchParams.TransparencyAndComposition; commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, colorOpaqueOnly.RenderTarget, colorOpaqueOnly.MipLevel, colorOpaqueOnly.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevColorPreAlpha, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.PrevPreAlpha[frameIndex ^ 1])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevColorPostAlpha, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.PrevPostAlpha[frameIndex ^ 1])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvTransparencyAndCompositionMask, transparencyAndComposition.RenderTarget, transparencyAndComposition.MipLevel, transparencyAndComposition.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.AutoReactive)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoComposition, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.AutoComposition)); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPreAlpha, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.PrevPreAlpha[frameIndex])); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPostAlpha, RenderTargetIdentifier.op_Implicit((Texture)(object)Resources.PrevPostAlpha[frameIndex])); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _tcrAutogenerateConstants, 0, Marshal.SizeOf<Fsr3Upscaler.GenerateReactiveConstants2>()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } internal class Fsr3UpscalerResources { public Texture2D LanczosLut; public Texture2D DefaultExposure; public Texture2D DefaultReactive; public RenderTexture SpdAtomicCounter; public RenderTexture SpdMips; public RenderTexture DilatedVelocity; public RenderTexture DilatedDepth; public RenderTexture ReconstructedPrevNearestDepth; public RenderTexture FrameInfo; public RenderTexture AutoReactive; public RenderTexture AutoComposition; public readonly RenderTexture[] Accumulation = (RenderTexture[])(object)new RenderTexture[2]; public readonly RenderTexture[] Luma = (RenderTexture[])(object)new RenderTexture[2]; public readonly RenderTexture[] InternalUpscaled = (RenderTexture[])(object)new RenderTexture[2]; public readonly RenderTexture[] LumaHistory = (RenderTexture[])(object)new RenderTexture[2]; public readonly RenderTexture[] PrevPreAlpha = (RenderTexture[])(object)new RenderTexture[2]; public readonly RenderTexture[] PrevPostAlpha = (RenderTexture[])(object)new RenderTexture[2]; public void Create(Fsr3Upscaler.ContextDescription contextDescription) { //IL_003c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0113: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Expected O, but got Unknown //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[128]; for (int i = 0; i < 128; i++) { float num = Fsr3Upscaler.Lanczos2(2f * (float)i / 127f); array[i] = num; } Vector2Int maxRenderSize = contextDescription.MaxRenderSize; Vector2Int val = maxRenderSize / 2; LanczosLut = new Texture2D(128, 1, (GraphicsFormat)49, (TextureCreationFlags)0) { name = "FSR3UPSCALER_LanczosLutData" }; LanczosLut.SetPixelData<float>(array, 0, 0); LanczosLut.Apply(); DefaultReactive = new Texture2D(1, 1, (GraphicsFormat)5, (TextureCreationFlags)0) { name = "FSR3UPSCALER_DefaultReactivityMask" }; DefaultReactive.SetPixel(0, 0, Color.clear); DefaultReactive.Apply(); DefaultExposure = new Texture2D(1, 1, (GraphicsFormat)50, (TextureCreationFlags)0) { name = "FSR3UPSCALER_DefaultExposure" }; DefaultExposure.SetPixel(0, 0, Color.clear); DefaultExposure.Apply(); SpdAtomicCounter = new RenderTexture(1, 1, 0, (GraphicsFormat)37) { name = "FSR3UPSCALER_SpdAtomicCounter", enableRandomWrite = true }; SpdAtomicCounter.Create(); int num2 = 1 + Mathf.FloorToInt(Mathf.Log((float)Math.Max(((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y), 2f)); SpdMips = new RenderTexture(((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y, 0, (GraphicsFormat)46, num2) { name = "FSR3UPSCALER_SpdMips", enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; SpdMips.Create(); DilatedVelocity = new RenderTexture(((Vector2Int)(ref maxRenderSize)).x, ((Vector2Int)(ref maxRenderSize)).y, 0, (GraphicsFormat)46) { name = "FSR3UPSCALER_DilatedVelocity", enableRandomWrite = true }; DilatedVelocity.Create(); DilatedDepth = new RenderTexture(((Vector2Int)(ref maxRenderSize)).x, ((Vector2Int)(ref maxRenderSize)).y, 0, (GraphicsFormat)49) { name = "FSR3UPSCALER_DilatedDepth", enableRandomWrite = true }; DilatedDepth.Create(); ReconstructedPrevNearestDepth = new RenderTexture(((Vector2Int)(ref maxRenderSize)).x, ((Vector2Int)(ref maxRenderSize)).y, 0, (GraphicsFormat)37) { name = "FSR3UPSCALER_ReconstructedPrevNearestDepth", enableRandomWrite = true }; ReconstructedPrevNearestDepth.Create(); FrameInfo = new RenderTexture(1, 1, 0, (GraphicsFormat)52) { name = "FSR3UPSCALER_FrameInfo", enableRandomWrite = true }; FrameInfo.Create(); CreateDoubleBufferedResource(Accumulation, "FSR3UPSCALER_Accumulation", maxRenderSize, (GraphicsFormat)5); CreateDoubleBufferedResource(Luma, "FSR3UPSCALER_Luma", maxRenderSize, (GraphicsFormat)45); CreateDoubleBufferedResource(InternalUpscaled, "FSR3UPSCALER_InternalUpscaled", contextDescription.MaxUpscaleSize, (GraphicsFormat)48); CreateDoubleBufferedResource(LumaHistory, "FSR3UPSCALER_LumaHistory", maxRenderSize, (GraphicsFormat)48); } public void CreateTcrAutogenResources(Fsr3Upscaler.ContextDescription contextDescription) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) AutoReactive = new RenderTexture(((Vector2Int)(ref contextDescription.MaxRenderSize)).x, ((Vector2Int)(ref contextDescription.MaxRenderSize)).y, 0, (GraphicsFormat)5) { name = "FSR3UPSCALER_AutoReactive", enableRandomWrite = true }; AutoReactive.Create(); AutoComposition = new RenderTexture(((Vector2Int)(ref contextDescription.MaxRenderSize)).x, ((Vector2Int)(ref contextDescription.MaxRenderSize)).y, 0, (GraphicsFormat)5) { name = "FSR3UPSCALER_AutoComposition", enableRandomWrite = true }; AutoComposition.Create(); CreateDoubleBufferedResource(PrevPreAlpha, "FSR3UPSCALER_PrevPreAlpha", contextDescription.MaxRenderSize, (GraphicsFormat)74); CreateDoubleBufferedResource(PrevPostAlpha, "FSR3UPSCALER_PrevPostAlpha", contextDescription.MaxRenderSize, (GraphicsFormat)74); } public static void CreateAliasableResources(CommandBuffer commandBuffer, Fsr3Upscaler.ContextDescription contextDescription, Fsr3Upscaler.DispatchDescription dispatchParams) { //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_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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) Vector2Int maxUpscaleSize = contextDescription.MaxUpscaleSize; Vector2Int maxRenderSize = contextDescription.MaxRenderSize; Vector2Int val = maxRenderSize / 2; commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavIntermediate, ((Vector2Int)(ref maxRenderSize)).x, ((Vector2Int)(ref maxRenderSize)).y, 0, (FilterMode)0, (GraphicsFormat)45, 1, true); commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavShadingChange, ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y, 0, (FilterMode)0, (GraphicsFormat)5, 1, true); commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavNewLocks, ((Vector2Int)(ref maxUpscaleSize)).x, ((Vector2Int)(ref maxUpscaleSize)).y, 0, (FilterMode)0, (GraphicsFormat)5, 1, true); commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavFarthestDepthMip1, ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y, 0, (FilterMode)0, (GraphicsFormat)45, 1, true); commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavDilatedReactiveMasks, ((Vector2Int)(ref maxRenderSize)).x, ((Vector2Int)(ref maxRenderSize)).y, 0, (FilterMode)0, (GraphicsFormat)8, 1, true); } public static void DestroyAliasableResources(CommandBuffer commandBuffer) { commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavDilatedReactiveMasks); commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavFarthestDepthMip1); commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavNewLocks); commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavShadingChange); commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavIntermediate); } private static void CreateDoubleBufferedResource(RenderTexture[] resource, string name, Vector2Int size, GraphicsFormat format) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown for (int i = 0; i < 2; i++) { resource[i] = new RenderTexture(((Vector2Int)(ref size)).x, ((Vector2Int)(ref size)).y, 0, format) { name = name + (i + 1), enableRandomWrite = true }; resource[i].Create(); } } public void Destroy() { DestroyTcrAutogenResources(); DestroyResource(L