|
|
|
@ -30,24 +30,17 @@ namespace FidelityFX.FSR3 |
|
|
|
/// </summary>
|
|
|
|
internal abstract class Fsr3UpscalerPass: FfxPassWithFlags<Fsr3Upscaler.DispatchDescription, Fsr3Upscaler.InitializationFlags> |
|
|
|
{ |
|
|
|
protected readonly Fsr3Upscaler.ContextDescription ContextDescription; |
|
|
|
protected readonly Fsr3UpscalerResources Resources; |
|
|
|
protected readonly ComputeBuffer Constants; |
|
|
|
|
|
|
|
protected Fsr3UpscalerPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
: base("FSR3 Upscaler") |
|
|
|
protected Fsr3UpscalerPass(in Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
: base("FSR3 Upscaler", contextDescription.Flags) |
|
|
|
{ |
|
|
|
ContextDescription = contextDescription; |
|
|
|
Resources = resources; |
|
|
|
Constants = constants; |
|
|
|
} |
|
|
|
|
|
|
|
protected void InitComputeShader(string passName, ComputeShader shader) |
|
|
|
{ |
|
|
|
InitComputeShader(passName, shader, ContextDescription.Flags); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void SetupShaderKeywords(Fsr3Upscaler.InitializationFlags flags) |
|
|
|
|
|
|
|
protected override void SetupShaderKeywords() |
|
|
|
{ |
|
|
|
bool useLut = false; |
|
|
|
#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+
|
|
|
|
@ -58,12 +51,12 @@ namespace FidelityFX.FSR3 |
|
|
|
#endif
|
|
|
|
|
|
|
|
// This matches the permutation rules from the CreatePipeline* functions
|
|
|
|
if ((flags & Fsr3Upscaler.InitializationFlags.EnableHighDynamicRange) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT"); |
|
|
|
if ((flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); |
|
|
|
if ((flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS"); |
|
|
|
if ((flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH"); |
|
|
|
if ((Flags & Fsr3Upscaler.InitializationFlags.EnableHighDynamicRange) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT"); |
|
|
|
if ((Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); |
|
|
|
if ((Flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS"); |
|
|
|
if ((Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH"); |
|
|
|
if (useLut) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE"); |
|
|
|
if ((flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF"); |
|
|
|
if ((Flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -267,7 +260,7 @@ namespace FidelityFX.FSR3 |
|
|
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, dispatchParams.Exposure); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); |
|
|
|
|
|
|
|
if ((ContextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) |
|
|
|
if ((Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) |
|
|
|
{ |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity); |
|
|
|
} |
|
|
|
|