|
|
@ -85,18 +85,18 @@ namespace FidelityFX |
|
|
bool supportedFP16 = ((flags & Fsr2.InitializationFlags.EnableFP16Usage) != 0 && AllowFP16); |
|
|
bool supportedFP16 = ((flags & Fsr2.InitializationFlags.EnableFP16Usage) != 0 && AllowFP16); |
|
|
|
|
|
|
|
|
// This matches the permutation rules from the CreatePipeline* functions
|
|
|
// This matches the permutation rules from the CreatePipeline* functions
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableHighDynamicRange) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_HDR_COLOR_INPUT"); |
|
|
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); |
|
|
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS"); |
|
|
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_INVERTED_DEPTH"); |
|
|
|
|
|
if (useLut) shaderRef.EnableKeyword("FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"); |
|
|
|
|
|
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableHighDynamicRange) != 0) shaderRef.EnableKeyword("FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT"); |
|
|
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) shaderRef.EnableKeyword("FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); |
|
|
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) shaderRef.EnableKeyword("FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS"); |
|
|
|
|
|
if ((flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0) shaderRef.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH"); |
|
|
|
|
|
if (useLut) shaderRef.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE"); |
|
|
if (supportedFP16) shaderRef.EnableKeyword("FFX_HALF"); |
|
|
if (supportedFP16) shaderRef.EnableKeyword("FFX_HALF"); |
|
|
|
|
|
|
|
|
// Inform the shader which render pipeline we're currently using
|
|
|
// Inform the shader which render pipeline we're currently using
|
|
|
var pipeline = GraphicsSettings.currentRenderPipeline; |
|
|
var pipeline = GraphicsSettings.currentRenderPipeline; |
|
|
if (pipeline != null && pipeline.GetType().Name.Contains("HDRenderPipeline")) |
|
|
if (pipeline != null && pipeline.GetType().Name.Contains("HDRenderPipeline")) |
|
|
{ |
|
|
{ |
|
|
shaderRef.EnableKeyword("UNITY_FSR2_HDRP"); |
|
|
|
|
|
|
|
|
shaderRef.EnableKeyword("UNITY_FSR3UPSCALER_HDRP"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -124,7 +124,7 @@ namespace FidelityFX |
|
|
{ |
|
|
{ |
|
|
_spdConstants = spdConstants; |
|
|
_spdConstants = spdConstants; |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR2/ffx_fsr2_compute_luminance_pyramid_pass"); |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) |
|
|
@ -149,7 +149,7 @@ namespace FidelityFX |
|
|
public Fsr2ReconstructPreviousDepthPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
public Fsr2ReconstructPreviousDepthPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
{ |
|
|
{ |
|
|
LoadComputeShader("FSR2/ffx_fsr2_reconstruct_previous_depth_pass"); |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) |
|
|
@ -177,7 +177,7 @@ namespace FidelityFX |
|
|
public Fsr2DepthClipPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
public Fsr2DepthClipPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
{ |
|
|
{ |
|
|
LoadComputeShader("FSR2/ffx_fsr2_depth_clip_pass"); |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR3/ffx_fsr3upscaler_depth_clip_pass"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) |
|
|
@ -212,7 +212,7 @@ namespace FidelityFX |
|
|
public Fsr2LockPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
public Fsr2LockPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
{ |
|
|
{ |
|
|
LoadComputeShader("FSR2/ffx_fsr2_lock_pass"); |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR3/ffx_fsr3upscaler_lock_pass"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) |
|
|
@ -226,7 +226,7 @@ namespace FidelityFX |
|
|
|
|
|
|
|
|
internal class Fsr2AccumulatePass : Fsr2Pass |
|
|
internal class Fsr2AccumulatePass : Fsr2Pass |
|
|
{ |
|
|
{ |
|
|
private const string SharpeningKeyword = "FFX_FSR2_OPTION_APPLY_SHARPENING"; |
|
|
|
|
|
|
|
|
private const string SharpeningKeyword = "FFX_FSR3UPSCALER_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; |
|
|
@ -238,7 +238,7 @@ namespace FidelityFX |
|
|
public Fsr2AccumulatePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
public Fsr2AccumulatePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
: base(contextDescription, resources, constants) |
|
|
{ |
|
|
{ |
|
|
LoadComputeShader("FSR2/ffx_fsr2_accumulate_pass"); |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR3/ffx_fsr3upscaler_accumulate_pass"); |
|
|
#if UNITY_2021_2_OR_NEWER
|
|
|
#if UNITY_2021_2_OR_NEWER
|
|
|
_sharpeningKeyword = new LocalKeyword(ComputeShader, SharpeningKeyword); |
|
|
_sharpeningKeyword = new LocalKeyword(ComputeShader, SharpeningKeyword); |
|
|
#endif
|
|
|
#endif
|
|
|
@ -303,7 +303,7 @@ namespace FidelityFX |
|
|
{ |
|
|
{ |
|
|
_rcasConstants = rcasConstants; |
|
|
_rcasConstants = rcasConstants; |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR2/ffx_fsr2_rcas_pass"); |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR3/ffx_fsr3upscaler_rcas_pass"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) |
|
|
@ -331,7 +331,7 @@ namespace FidelityFX |
|
|
{ |
|
|
{ |
|
|
_generateReactiveConstants = generateReactiveConstants; |
|
|
_generateReactiveConstants = generateReactiveConstants; |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR2/ffx_fsr2_autogen_reactive_pass"); |
|
|
|
|
|
|
|
|
LoadComputeShader("FSR3/ffx_fsr3upscaler_autogen_reactive_pass"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) |
|
|
@ -354,7 +354,7 @@ namespace FidelityFX |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
internal class Fsr2TcrAutogeneratePass : Fsr2Pass |
|
|
|
|
|
|
|
|
internal class Fsr2TcrAutogeneratePass : Fsr2Pass // TODO: where did this pass go in FSR3?
|
|
|
{ |
|
|
{ |
|
|
private readonly ComputeBuffer _tcrAutogenerateConstants; |
|
|
private readonly ComputeBuffer _tcrAutogenerateConstants; |
|
|
|
|
|
|
|
|
|