@ -277,14 +277,22 @@ namespace FidelityFX
// Workaround: Disable FP16 path for the accumulate pass on NVIDIA due to reduced occupancy and high VRAM throughput.
protected override bool AllowFP16 = > SystemInfo . graphicsDeviceVendorID ! = 0 x10DE ;
private readonly LocalKeyword _sharpeningKeyword ;
public Fsr2AccumulatePipeline ( Fsr2 . ContextDescription contextDescription , Fsr2Resources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
LoadComputeShader ( "FSR2/ffx_fsr2_accumulate_pass" ) ;
_sharpeningKeyword = new LocalKeyword ( ComputeShader , "FFX_FSR2_OPTION_APPLY_SHARPENING" ) ;
}
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
if ( dispatchParams . EnableSharpening )
commandBuffer . EnableKeyword ( ComputeShader , _sharpeningKeyword ) ;
else
commandBuffer . DisableKeyword ( ComputeShader , _sharpeningKeyword ) ;
if ( ( ContextDescription . Flags & Fsr2 . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
else if ( dispatchParams . MotionVectors . HasValue )
@ -316,40 +324,6 @@ namespace FidelityFX
}
}
internal class Fsr2AccumulateSharpenPipeline : Fsr2AccumulatePipeline
{
private readonly ComputeShader _shaderCopy ;
public Fsr2AccumulateSharpenPipeline ( Fsr2 . ContextDescription contextDescription , Fsr2Resources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
// Simply loading the accumulate_pass compute shader will give us the same instance as the non-sharpen pipeline
// So we have to clone the shader instance and set the extra keyword on the new copy
_shaderCopy = UnityEngine . Object . Instantiate ( ComputeShader ) ;
foreach ( var keyword in ComputeShader . shaderKeywords )
{
_shaderCopy . EnableKeyword ( keyword ) ;
}
_shaderCopy . EnableKeyword ( "FFX_FSR2_OPTION_APPLY_SHARPENING" ) ;
}
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
// Temporarily swap around the shaders so that the dispatch will bind and execute the correct one
ComputeShader tmp = ComputeShader ;
ComputeShader = _shaderCopy ;
base . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchX , dispatchY ) ;
ComputeShader = tmp ;
}
public override void Dispose ( )
{
// Since we instantiated this copy, we have to destroy it instead of unloading the shader resource
UnityEngine . Object . Destroy ( _shaderCopy ) ;
base . Dispose ( ) ;
}
}
internal class Fsr2RcasPipeline : Fsr2Pipeline
{
private readonly ComputeBuffer _rcasConstants ;