Browse Source

Check for compute shader support when enabling FSR2, and moved debug checking flag to default context creation method.

mac-autoexp
Nico de Poel 3 years ago
parent
commit
03fd58cb5a
  1. 11
      Assets/Scripts/Fsr2ImageEffect.cs
  2. 7
      Assets/Scripts/Internal/Fsr2.cs

11
Assets/Scripts/Fsr2ImageEffect.cs

@ -69,6 +69,13 @@ namespace FidelityFX
private void OnEnable() private void OnEnable()
{ {
if (!SystemInfo.supportsComputeShaders)
{
Debug.LogError("FSR2 requires compute shader support!");
enabled = false;
return;
}
_helper = GetComponent<Fsr2ImageEffectHelper>(); _helper = GetComponent<Fsr2ImageEffectHelper>();
// Set up the original camera to output all of the required FSR2 input resources at the desired resolution // Set up the original camera to output all of the required FSR2 input resources at the desired resolution
@ -82,10 +89,6 @@ namespace FidelityFX
if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage; if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage;
if (enableAutoExposure) flags |= Fsr2.InitializationFlags.EnableAutoExposure; if (enableAutoExposure) flags |= Fsr2.InitializationFlags.EnableAutoExposure;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
flags |= Fsr2.InitializationFlags.EnableDebugChecking;
#endif
_displaySize = new Vector2Int(_renderCamera.pixelWidth, _renderCamera.pixelHeight); _displaySize = new Vector2Int(_renderCamera.pixelWidth, _renderCamera.pixelHeight);
Fsr2.GetRenderResolutionFromQualityMode(out var renderWidth, out var renderHeight, _displaySize.x, _displaySize.y, qualityMode); Fsr2.GetRenderResolutionFromQualityMode(out var renderWidth, out var renderHeight, _displaySize.x, _displaySize.y, qualityMode);
_renderSize = new Vector2Int(renderWidth, renderHeight); _renderSize = new Vector2Int(renderWidth, renderHeight);

7
Assets/Scripts/Internal/Fsr2.cs

@ -23,6 +23,10 @@ namespace FidelityFX
else else
flags &= ~InitializationFlags.EnableDepthInverted; flags &= ~InitializationFlags.EnableDepthInverted;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
flags |= InitializationFlags.EnableDebugChecking;
#endif
Debug.Log($"Setting up FSR2 with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}"); Debug.Log($"Setting up FSR2 with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}");
var contextDescription = new ContextDescription var contextDescription = new ContextDescription
@ -99,8 +103,7 @@ namespace FidelityFX
public static float Lanczos2(float value) public static float Lanczos2(float value)
{ {
return Mathf.Abs(value) < Mathf.Epsilon ? 1.0f :
Mathf.Sin(Mathf.PI * value) / (Mathf.PI * value) * (Mathf.Sin(0.5f * Mathf.PI * value) / (0.5f * Mathf.PI * value));
return Mathf.Abs(value) < Mathf.Epsilon ? 1.0f : Mathf.Sin(Mathf.PI * value) / (Mathf.PI * value) * (Mathf.Sin(0.5f * Mathf.PI * value) / (0.5f * Mathf.PI * value));
} }
public enum QualityMode public enum QualityMode

Loading…
Cancel
Save