diff --git a/Runtime/FSR3/Fsr3ShaderIDs.cs b/Runtime/FSR3/Fsr3ShaderIDs.cs index 6e543fe..95aeb58 100644 --- a/Runtime/FSR3/Fsr3ShaderIDs.cs +++ b/Runtime/FSR3/Fsr3ShaderIDs.cs @@ -50,8 +50,6 @@ namespace FidelityFX.FSR3 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"); // Unordered access views, i.e. random read/write bindings public static readonly int UavReconstructedPrevNearestDepth = Shader.PropertyToID("rw_reconstructed_previous_nearest_depth"); @@ -78,9 +76,6 @@ namespace FidelityFX.FSR3 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"); // Constant buffer bindings public static readonly int CbFsr3Upscaler = Shader.PropertyToID("cbFSR3Upscaler"); diff --git a/Runtime/FSR3/Fsr3Upscaler.cs b/Runtime/FSR3/Fsr3Upscaler.cs index d69aa29..b168913 100644 --- a/Runtime/FSR3/Fsr3Upscaler.cs +++ b/Runtime/FSR3/Fsr3Upscaler.cs @@ -130,7 +130,7 @@ namespace FidelityFX.FSR3 #if !UNITY_2021_1_OR_NEWER internal static void SetBufferData(this CommandBuffer commandBuffer, ComputeBuffer computeBuffer, Array data) { - commandBuffer.SetComputeBufferData(computeBuffer, data); + computeBuffer.SetData(data); } #endif @@ -201,15 +201,6 @@ namespace FidelityFX.FSR3 public float CameraFovAngleVertical; public float ViewSpaceToMetersFactor; public DispatchFlags Flags; - public bool UseTextureArrays; // Enable texture array bindings, primarily used for HDRP and XR - - // EXPERIMENTAL reactive mask generation parameters - public bool EnableAutoReactive; - public ResourceView ColorOpaqueOnly; - public float AutoTcThreshold = 0.05f; - public float AutoTcScale = 1.0f; - public float AutoReactiveScale = 5.0f; - public float AutoReactiveMax = 0.9f; } /// @@ -284,15 +275,6 @@ namespace FidelityFX.FSR3 public float binaryValue; public uint flags; } - - [Serializable, StructLayout(LayoutKind.Sequential)] - internal struct GenerateReactiveConstants2 - { - public float autoTcThreshold; - public float autoTcScale; - public float autoReactiveScale; - public float autoReactiveMax; - } [Serializable, StructLayout(LayoutKind.Sequential)] internal struct RcasConstants diff --git a/Runtime/FSR3/Fsr3UpscalerContext.cs b/Runtime/FSR3/Fsr3UpscalerContext.cs index 2b7f2ef..31be2f9 100644 --- a/Runtime/FSR3/Fsr3UpscalerContext.cs +++ b/Runtime/FSR3/Fsr3UpscalerContext.cs @@ -47,7 +47,6 @@ namespace FidelityFX.FSR3 private Fsr3UpscalerPass _accumulatePass; private Fsr3UpscalerPass _sharpenPass; private Fsr3UpscalerPass _generateReactivePass; - private Fsr3UpscalerPass _tcrAutogeneratePass; #if UNITY_EDITOR || DEVELOPMENT_BUILD private Fsr3UpscalerPass _debugViewPass; #endif @@ -70,10 +69,6 @@ namespace FidelityFX.FSR3 private readonly Fsr3Upscaler.GenerateReactiveConstants[] _generateReactiveConstantsArray = { new Fsr3Upscaler.GenerateReactiveConstants() }; private ref Fsr3Upscaler.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0]; - private ComputeBuffer _tcrAutogenerateConstantsBuffer; - private readonly Fsr3Upscaler.GenerateReactiveConstants2[] _tcrAutogenerateConstantsArray = { new Fsr3Upscaler.GenerateReactiveConstants2() }; - private ref Fsr3Upscaler.GenerateReactiveConstants2 TcrAutoGenConsts => ref _tcrAutogenerateConstantsArray[0]; - private bool _firstExecution; private int _resourceFrameIndex; private Vector2 _previousJitterOffset; @@ -89,7 +84,6 @@ namespace FidelityFX.FSR3 _spdConstantsBuffer = CreateConstantBuffer(); _rcasConstantsBuffer = CreateConstantBuffer(); _generateReactiveConstantsBuffer = CreateConstantBuffer(); - _tcrAutogenerateConstantsBuffer = CreateConstantBuffer(); // Set defaults _firstExecution = true; @@ -112,7 +106,6 @@ namespace FidelityFX.FSR3 _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); #if UNITY_EDITOR || DEVELOPMENT_BUILD _debugViewPass = new Fsr3UpscalerDebugViewPass(_contextDescription, _resources, _upscalerConstantsBuffer); #endif @@ -123,7 +116,6 @@ namespace FidelityFX.FSR3 #if UNITY_EDITOR || DEVELOPMENT_BUILD DestroyPass(ref _debugViewPass); #endif - DestroyPass(ref _tcrAutogeneratePass); DestroyPass(ref _generateReactivePass); DestroyPass(ref _lumaPyramidPass); DestroyPass(ref _sharpenPass); @@ -136,7 +128,6 @@ namespace FidelityFX.FSR3 _resources.Destroy(); - DestroyConstantBuffer(ref _tcrAutogenerateConstantsBuffer); DestroyConstantBuffer(ref _generateReactiveConstantsBuffer); DestroyConstantBuffer(ref _rcasConstantsBuffer); DestroyConstantBuffer(ref _spdConstantsBuffer); @@ -163,9 +154,6 @@ namespace FidelityFX.FSR3 DebugCheckDispatch(dispatchParams); } - if (dispatchParams.UseTextureArrays) - commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); - if (_firstExecution) { commandBuffer.SetRenderTarget(_resources.Accumulation[0]); @@ -187,24 +175,6 @@ namespace FidelityFX.FSR3 dispatchParams.Exposure = new ResourceView(_resources.FrameInfo); else if (!dispatchParams.Exposure.IsValid) dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); - - if (dispatchParams.EnableAutoReactive) - { - // Create the auto-TCR resources only when we need them - if (_resources.AutoReactive == null) - _resources.CreateTcrAutogenResources(_contextDescription); - - if (resetAccumulation) - { - RenderTargetIdentifier opaqueOnly = dispatchParams.ColorOpaqueOnly.IsValid ? dispatchParams.ColorOpaqueOnly.RenderTarget : Fsr3ShaderIDs.SrvOpaqueOnly; - commandBuffer.Blit(_resources.PrevPreAlpha[frameIndex ^ 1], opaqueOnly); - } - } - else if (_resources.AutoReactive != null) - { - // Destroy the auto-TCR resources if we don't use the feature - _resources.DestroyTcrAutogenResources(); - } if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new ResourceView(_resources.DefaultReactive); if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new ResourceView(_resources.DefaultReactive); @@ -251,13 +221,8 @@ namespace FidelityFX.FSR3 commandBuffer.SetBufferData(_upscalerConstantsBuffer, _upscalerConstantsArray); commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); - // Auto reactive - if (dispatchParams.EnableAutoReactive) - { - GenerateTransparencyCompositionReactive(dispatchParams, commandBuffer, frameIndex); - dispatchParams.Reactive = new ResourceView(_resources.AutoReactive); - dispatchParams.TransparencyAndComposition = new ResourceView(_resources.AutoComposition); - } + commandBuffer.SetGlobalConstantBuffer(_upscalerConstantsBuffer, Fsr3ShaderIDs.CbFsr3Upscaler, 0, Marshal.SizeOf()); + commandBuffer.SetGlobalConstantBuffer(_spdConstantsBuffer, Fsr3ShaderIDs.CbSpd, 0, Marshal.SizeOf()); _prepareInputsPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); _lumaPyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); @@ -274,6 +239,8 @@ namespace FidelityFX.FSR3 SetupRcasConstants(dispatchParams); commandBuffer.SetBufferData(_rcasConstantsBuffer, _rcasConstantsArray); + commandBuffer.SetGlobalConstantBuffer(_rcasConstantsBuffer, Fsr3ShaderIDs.CbRcas, 0, Marshal.SizeOf()); + // Dispatch RCAS const int threadGroupWorkRegionDimRcas = 16; int threadGroupsX = (UpscalerConsts.upscaleSize.x + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; @@ -291,8 +258,6 @@ namespace FidelityFX.FSR3 _resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames; Fsr3UpscalerResources.DestroyAliasableResources(commandBuffer); - - commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); } public void GenerateReactiveMask(Fsr3Upscaler.GenerateReactiveDescription dispatchParams) @@ -314,22 +279,9 @@ namespace FidelityFX.FSR3 GenReactiveConsts.flags = (uint)dispatchParams.Flags; commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray); - ((Fsr3UpscalerGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); - } - - private void GenerateTransparencyCompositionReactive(Fsr3Upscaler.DispatchDescription dispatchParams, CommandBuffer commandBuffer, int frameIndex) - { - const int threadGroupWorkRegionDim = 8; - int dispatchSrcX = (dispatchParams.RenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; - int dispatchSrcY = (dispatchParams.RenderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; - - TcrAutoGenConsts.autoTcThreshold = dispatchParams.AutoTcThreshold; - TcrAutoGenConsts.autoTcScale = dispatchParams.AutoTcScale; - TcrAutoGenConsts.autoReactiveScale = dispatchParams.AutoReactiveScale; - TcrAutoGenConsts.autoReactiveMax = dispatchParams.AutoReactiveMax; - commandBuffer.SetBufferData(_tcrAutogenerateConstantsBuffer, _tcrAutogenerateConstantsArray); + commandBuffer.SetGlobalConstantBuffer(_generateReactiveConstantsBuffer, Fsr3ShaderIDs.CbGenReactive, 0, Marshal.SizeOf()); - _tcrAutogeneratePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); + ((Fsr3UpscalerGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); } private void SetupConstants(Fsr3Upscaler.DispatchDescription dispatchParams, bool resetAccumulation) diff --git a/Runtime/FSR3/Fsr3UpscalerPass.cs b/Runtime/FSR3/Fsr3UpscalerPass.cs index 3b76eb4..ac5741e 100644 --- a/Runtime/FSR3/Fsr3UpscalerPass.cs +++ b/Runtime/FSR3/Fsr3UpscalerPass.cs @@ -39,8 +39,6 @@ namespace FidelityFX.FSR3 protected ComputeShader ComputeShader; protected int KernelIndex; - - protected CustomSampler Sampler; protected Fsr3UpscalerPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) { @@ -55,9 +53,7 @@ namespace FidelityFX.FSR3 public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { - commandBuffer.BeginSample(Sampler); DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY); - commandBuffer.EndSample(Sampler); } protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); @@ -76,23 +72,6 @@ namespace FidelityFX.FSR3 ComputeShader = shader; KernelIndex = ComputeShader.FindKernel("CS"); - Sampler = CustomSampler.Create(passName); - - bool useLut = false; -#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+ - if (SystemInfo.computeSubGroupSize == 64) - { - useLut = true; - } -#endif - - // This matches the permutation rules from the CreatePipeline* functions - 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 (useLut) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE"); - if ((flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF"); } } @@ -120,8 +99,6 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFarthestDepth, Fsr3ShaderIDs.UavIntermediate); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavCurrentLuma, Resources.Luma[frameIndex]); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } @@ -151,10 +128,8 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip3, Resources.SpdMips, 3); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip4, Resources.SpdMips, 4); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip5, Resources.SpdMips, 5); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFarthestDepthMip1, Fsr3ShaderIDs.UavFarthestDepthMip1); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } @@ -187,9 +162,7 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip3, Resources.SpdMips, 3); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip4, Resources.SpdMips, 4); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip5, Resources.SpdMips, 5); - - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavShadingChange, Fsr3ShaderIDs.UavShadingChange); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } @@ -206,8 +179,8 @@ namespace FidelityFX.FSR3 protected override void DoScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvSpdMips, Resources.SpdMips); - - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavShadingChange, Fsr3ShaderIDs.UavShadingChange); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } @@ -237,10 +210,10 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavNewLocks, Fsr3ShaderIDs.UavNewLocks); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAccumulation, Resources.Accumulation[frameIndex]); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } @@ -268,8 +241,6 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLumaHistory, Resources.LumaHistory[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLumaInstability, Fsr3ShaderIDs.UavIntermediate); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } @@ -328,12 +299,11 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaInstability, Fsr3ShaderIDs.UavIntermediate); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavNewLocks, Fsr3ShaderIDs.UavNewLocks); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } @@ -359,9 +329,6 @@ namespace FidelityFX.FSR3 ref var 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()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbRcas, _rcasConstants, 0, Marshal.SizeOf()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } @@ -384,8 +351,6 @@ namespace FidelityFX.FSR3 public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) { - commandBuffer.BeginSample(Sampler); - ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly; ref var color = ref dispatchParams.ColorPreUpscale; ref var reactive = ref dispatchParams.OutReactive; @@ -394,50 +359,6 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf()); - - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); - - commandBuffer.EndSample(Sampler); - } - } - - 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) - { - ref var color = ref dispatchParams.Color; - ref var motionVectors = ref dispatchParams.MotionVectors; - ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly; - ref var reactive = ref dispatchParams.Reactive; - ref var tac = ref dispatchParams.TransparencyAndComposition; - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.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, Resources.PrevPreAlpha[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, Resources.AutoReactive); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoComposition, Resources.AutoComposition); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex]); - - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _tcrAutogenerateConstants, 0, Marshal.SizeOf()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } @@ -463,8 +384,6 @@ namespace FidelityFX.FSR3 ref var 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()); - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } diff --git a/Shaders/ffx_fsr3upscaler_accumulate_pass.compute b/Shaders/ffx_fsr3upscaler_accumulate_pass.compute index a8d6864..e63ac87 100644 --- a/Shaders/ffx_fsr3upscaler_accumulate_pass.compute +++ b/Shaders/ffx_fsr3upscaler_accumulate_pass.compute @@ -20,13 +20,10 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE -#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT -#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 +#define FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute b/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute index 500352a..ef8cd48 100644 --- a/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute +++ b/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute @@ -20,9 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_debug_view_pass.compute b/Shaders/ffx_fsr3upscaler_debug_view_pass.compute index 027e414..41d91db 100644 --- a/Shaders/ffx_fsr3upscaler_debug_view_pass.compute +++ b/Shaders/ffx_fsr3upscaler_debug_view_pass.compute @@ -20,9 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute b/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute index 5cffc66..b18d573 100644 --- a/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute +++ b/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute @@ -20,9 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute b/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute index 347b0d6..95738c6 100644 --- a/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute +++ b/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute @@ -20,9 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute b/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute index b71ea5d..e3d997c 100644 --- a/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute +++ b/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute @@ -20,11 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute b/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute index ebf4e91..084e620 100644 --- a/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute +++ b/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute @@ -20,9 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_rcas_pass.compute b/Shaders/ffx_fsr3upscaler_rcas_pass.compute index 282a9ae..4301c5a 100644 --- a/Shaders/ffx_fsr3upscaler_rcas_pass.compute +++ b/Shaders/ffx_fsr3upscaler_rcas_pass.compute @@ -20,7 +20,9 @@ #pragma kernel CS -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_shading_change_pass.compute b/Shaders/ffx_fsr3upscaler_shading_change_pass.compute index 34c3ade..9b549f7 100644 --- a/Shaders/ffx_fsr3upscaler_shading_change_pass.compute +++ b/Shaders/ffx_fsr3upscaler_shading_change_pass.compute @@ -20,9 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute b/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute index ffe5bfe..78be8ff 100644 --- a/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute +++ b/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute @@ -20,9 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc" diff --git a/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute b/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute index 952c052..fc5a702 100644 --- a/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute +++ b/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute @@ -20,10 +20,9 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS - -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#define FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT 1 +#define FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS 1 +#define FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH 1 #include "ffx_fsr_unity_common.cginc"