From 8f1be6d3e62b20cc5dc39f084eb109a75189e6b8 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Wed, 1 Mar 2023 22:09:18 +0100 Subject: [PATCH] Re-added transparency & composition parameter, even though we never use it and just fall back to the default reactivity mask, we officially support it as an input now. --- Assets/Scripts/Fsr2.cs | 1 + Assets/Scripts/Fsr2Context.cs | 1 + Assets/Scripts/Fsr2Controller.cs | 6 +++++- Assets/Scripts/Fsr2Pipeline.cs | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Fsr2.cs b/Assets/Scripts/Fsr2.cs index 620e983..4360712 100644 --- a/Assets/Scripts/Fsr2.cs +++ b/Assets/Scripts/Fsr2.cs @@ -152,6 +152,7 @@ namespace FidelityFX public RenderTargetIdentifier? MotionVectors; public RenderTargetIdentifier? Exposure; public RenderTargetIdentifier? Reactive; + public RenderTargetIdentifier? TransparencyAndComposition; public RenderTargetIdentifier? Output; public Vector2 JitterOffset; public Vector2 MotionVectorScale; diff --git a/Assets/Scripts/Fsr2Context.cs b/Assets/Scripts/Fsr2Context.cs index d0126e0..c777d04 100644 --- a/Assets/Scripts/Fsr2Context.cs +++ b/Assets/Scripts/Fsr2Context.cs @@ -130,6 +130,7 @@ namespace FidelityFX // TODO: auto-exposure flag if (dispatchParams.Exposure == null) dispatchParams.Exposure = _resources.DefaultExposure; if (dispatchParams.Reactive == null) dispatchParams.Reactive = _resources.DefaultReactive; + if (dispatchParams.TransparencyAndComposition == null) dispatchParams.TransparencyAndComposition = _resources.DefaultReactive; Fsr2Pipeline.RegisterResources(commandBuffer, _contextDescription, dispatchParams); SetupConstants(dispatchParams, resetAccumulation); diff --git a/Assets/Scripts/Fsr2Controller.cs b/Assets/Scripts/Fsr2Controller.cs index d6a412a..a36d7cb 100644 --- a/Assets/Scripts/Fsr2Controller.cs +++ b/Assets/Scripts/Fsr2Controller.cs @@ -165,6 +165,7 @@ namespace FidelityFX _renderCamera.aspect = (Screen.width * _originalRect.width) / (Screen.height * _originalRect.height); _renderCamera.rect = new Rect(0, 0, _originalRect.width * _renderSize.x / _displaySize.x, _originalRect.height * _renderSize.y / _displaySize.y); + // Set up the parameters to auto-generate a reactive mask if (generateReactiveMask) { _genReactiveDescription.ColorOpaqueOnly = null; @@ -177,12 +178,15 @@ namespace FidelityFX _genReactiveDescription.Flags = generateReactiveParameters.flags; } + // Set up the main FSR2 dispatch parameters + // The input and output textures are left blank here, as they are already being bound elsewhere in this source file _dispatchDescription.Color = null; _dispatchDescription.Depth = null; _dispatchDescription.MotionVectors = null; - _dispatchDescription.Output = null; _dispatchDescription.Exposure = null; _dispatchDescription.Reactive = null; + _dispatchDescription.TransparencyAndComposition = null; + _dispatchDescription.Output = null; _dispatchDescription.PreExposure = 0; _dispatchDescription.EnableSharpening = performSharpenPass; _dispatchDescription.Sharpness = sharpness; diff --git a/Assets/Scripts/Fsr2Pipeline.cs b/Assets/Scripts/Fsr2Pipeline.cs index b1f05e8..e0ec324 100644 --- a/Assets/Scripts/Fsr2Pipeline.cs +++ b/Assets/Scripts/Fsr2Pipeline.cs @@ -260,10 +260,12 @@ namespace FidelityFX if (dispatchParams.Reactive.HasValue) commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvReactiveMask, dispatchParams.Reactive.Value); + if (dispatchParams.TransparencyAndComposition.HasValue) + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvTransparencyAndCompositionMask, dispatchParams.TransparencyAndComposition.Value); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvReconstructedPrevNearestDepth, UavReconstructedPrevNearestDepth); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvDilatedDepth, UavDilatedDepth); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvTransparencyAndCompositionMask, Resources.DefaultReactive); // Default reactive mask, as we don't support TCR (yet) commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]); commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbFsr2, Constants, 0, Marshal.SizeOf());