Browse Source

Restored compatibility with Unity versions older than 2021.2, which didn't have the LocalKeyword struct yet.

stable
Nico de Poel 3 years ago
parent
commit
70c7ea0e51
  1. 15
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/FSR2/Fsr2Pipeline.cs

15
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/FSR2/Fsr2Pipeline.cs

@ -271,24 +271,37 @@ namespace FidelityFX
internal class Fsr2AccumulatePipeline : Fsr2Pipeline internal class Fsr2AccumulatePipeline : Fsr2Pipeline
{ {
private const string SharpeningKeyword = "FFX_FSR2_OPTION_APPLY_SHARPENING";
// Workaround: Disable FP16 path for the accumulate pass on NVIDIA due to reduced occupancy and high VRAM throughput. // Workaround: Disable FP16 path for the accumulate pass on NVIDIA due to reduced occupancy and high VRAM throughput.
protected override bool AllowFP16 => SystemInfo.graphicsDeviceVendorID != 0x10DE; protected override bool AllowFP16 => SystemInfo.graphicsDeviceVendorID != 0x10DE;
#if UNITY_2021_2_OR_NEWER
private readonly LocalKeyword _sharpeningKeyword; private readonly LocalKeyword _sharpeningKeyword;
#endif
public Fsr2AccumulatePipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) public Fsr2AccumulatePipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants) : base(contextDescription, resources, constants)
{ {
LoadComputeShader("FSR2/ffx_fsr2_accumulate_pass"); LoadComputeShader("FSR2/ffx_fsr2_accumulate_pass");
_sharpeningKeyword = new LocalKeyword(ComputeShader, "FFX_FSR2_OPTION_APPLY_SHARPENING");
#if UNITY_2021_2_OR_NEWER
_sharpeningKeyword = new LocalKeyword(ComputeShader, SharpeningKeyword);
#endif
} }
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{ {
#if UNITY_2021_2_OR_NEWER
if (dispatchParams.EnableSharpening) if (dispatchParams.EnableSharpening)
commandBuffer.EnableKeyword(ComputeShader, _sharpeningKeyword); commandBuffer.EnableKeyword(ComputeShader, _sharpeningKeyword);
else else
commandBuffer.DisableKeyword(ComputeShader, _sharpeningKeyword); commandBuffer.DisableKeyword(ComputeShader, _sharpeningKeyword);
#else
if (dispatchParams.EnableSharpening)
commandBuffer.EnableShaderKeyword(SharpeningKeyword);
else
commandBuffer.DisableShaderKeyword(SharpeningKeyword);
#endif
if ((ContextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) if ((ContextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0)
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]);

Loading…
Cancel
Save