Browse Source

Applied a few more recent fixes from the FSR2 codebase

asr-console
Nico de Poel 11 months ago
parent
commit
d7191b98e7
  1. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs
  2. 25
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
  3. 2
      Packages/fidelityfx.fsr

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs

@ -187,7 +187,7 @@ namespace ArmASR
// Auto exposure always used to track luma changes in locking logic // Auto exposure always used to track luma changes in locking logic
commandBuffer.SetRenderTarget(_resources.AutoExposure); commandBuffer.SetRenderTarget(_resources.AutoExposure);
commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1e8f, 0f, 0f));
commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1f, 0f, 0f));
// Reset atomic counter to 0 // Reset atomic counter to 0
commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter); commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter);

25
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs

@ -19,6 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
using System; using System;
using System.Diagnostics;
using UnityEngine; using UnityEngine;
using UnityEngine.Profiling; using UnityEngine.Profiling;
using UnityEngine.Rendering; using UnityEngine.Rendering;
@ -41,7 +42,7 @@ namespace ArmASR
protected ComputeShader ComputeShader; protected ComputeShader ComputeShader;
protected int KernelIndex; protected int KernelIndex;
protected CustomSampler Sampler;
private CustomSampler _sampler;
protected AsrPass(Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants) protected AsrPass(Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants)
{ {
@ -56,9 +57,9 @@ namespace ArmASR
public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{ {
commandBuffer.BeginSample(Sampler);
BeginSample(commandBuffer);
DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY); DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY);
commandBuffer.EndSample(Sampler);
EndSample(commandBuffer);
} }
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY);
@ -77,7 +78,7 @@ namespace ArmASR
ComputeShader = shader; ComputeShader = shader;
KernelIndex = ComputeShader.FindKernel("main"); KernelIndex = ComputeShader.FindKernel("main");
Sampler = CustomSampler.Create(passName);
_sampler = CustomSampler.Create(passName);
bool useLut = false; bool useLut = false;
#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+ #if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+
@ -95,6 +96,18 @@ namespace ArmASR
if (useLut) ComputeShader.EnableKeyword("FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"); if (useLut) ComputeShader.EnableKeyword("FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE");
if ((flags & Asr.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFXM_HALF"); if ((flags & Asr.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFXM_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 AsrComputeLuminancePyramidPass : AsrPass internal class AsrComputeLuminancePyramidPass : AsrPass
@ -319,7 +332,7 @@ namespace ArmASR
public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY)
{ {
commandBuffer.BeginSample(Sampler);
BeginSample(commandBuffer);
ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly; ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly;
ref var color = ref dispatchParams.ColorPreUpscale; ref var color = ref dispatchParams.ColorPreUpscale;
@ -333,7 +346,7 @@ namespace ArmASR
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1);
commandBuffer.EndSample(Sampler);
EndSample(commandBuffer);
} }
} }
} }

2
Packages/fidelityfx.fsr

@ -1 +1 @@
Subproject commit d65cc3a35de270a1011c8158810e3d56c579953f
Subproject commit e28400609a43f850dae2b83048e936faa54017e8
Loading…
Cancel
Save