Browse Source

Added the ability to clone the shaders, in case multiple FSR3 instances with different configurations are needed.

fsr3
Nico de Poel 2 years ago
parent
commit
2d05d08f86
  1. 35
      Assets/Scripts/Core/Fsr3UpscalerShaders.cs

35
Assets/Scripts/Core/Fsr3UpscalerShaders.cs

@ -56,6 +56,41 @@ namespace FidelityFX
{
return (Fsr3UpscalerShaders)MemberwiseClone();
}
/// <summary>
/// Returns a copy of this class with clones of all its shaders.
/// This can be useful if you're running multiple FSR3 Upscaler instances with different shader configurations.
/// Be sure to clean up these clones through Dispose once you're done with them.
/// </summary>
public Fsr3UpscalerShaders DeepCopy()
{
Fsr3UpscalerShaders copy = CreateInstance<Fsr3UpscalerShaders>();
copy.computeLuminancePyramidPass = Instantiate(computeLuminancePyramidPass);
copy.reconstructPreviousDepthPass = Instantiate(reconstructPreviousDepthPass);
copy.depthClipPass = Instantiate(depthClipPass);
copy.lockPass = Instantiate(lockPass);
copy.accumulatePass = Instantiate(accumulatePass);
copy.sharpenPass = Instantiate(sharpenPass);
copy.autoGenReactivePass = Instantiate(autoGenReactivePass);
copy.tcrAutoGenPass = Instantiate(tcrAutoGenPass);
return copy;
}
/// <summary>
/// Destroy all the shaders within this instance.
/// Use this only on clones created through DeepCopy.
/// </summary>
public void Dispose()
{
Destroy(computeLuminancePyramidPass);
Destroy(reconstructPreviousDepthPass);
Destroy(depthClipPass);
Destroy(lockPass);
Destroy(accumulatePass);
Destroy(sharpenPass);
Destroy(autoGenReactivePass);
Destroy(tcrAutoGenPass);
}
#if UNITY_EDITOR
private void Reset()

Loading…
Cancel
Save