@ -27,21 +27,21 @@ namespace FidelityFX
{
/// <summary>
/// Base class for all of the compute passes that make up the FSR3 Upscaler process.
/// This loosely matches the FfxPipelineState struct from the original FSR3 Upscaler codebase, wrapped in an object-oriented blanket.
/// This loosely matches the FfxPipelineState struct from the original FSR3 codebase, wrapped in an object-oriented blanket.
/// These classes are responsible for loading compute shaders, managing temporary resources, binding resources to shader kernels and dispatching said shaders.
/// </summary>
internal abstract class Fsr2 Pass : IDisposable
internal abstract class Fsr3Upscaler Pass : IDisposable
{
internal const int ShadingChangeMipLevel = 4 ; // This matches the FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL define
protected readonly Fsr2 . ContextDescription ContextDescription ;
protected readonly Fsr2 Resources Resources ;
protected readonly Fsr3Upscaler . ContextDescription ContextDescription ;
protected readonly Fsr3Upscaler Resources Resources ;
protected readonly ComputeBuffer Constants ;
protected ComputeShader ComputeShader ;
protected int KernelIndex ;
protected Fsr2Pass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants )
protected Fsr3UpscalerPass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants )
{
ContextDescription = contextDescription ;
Resources = resources ;
@ -53,14 +53,14 @@ namespace FidelityFX
UnloadComputeShader ( ) ;
}
public abstract void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY ) ;
public abstract void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY ) ;
protected void LoadComputeShader ( string name )
{
LoadComputeShader ( name , ContextDescription . Flags , ref ComputeShader , out KernelIndex ) ;
}
private void LoadComputeShader ( string name , Fsr2 . InitializationFlags flags , ref ComputeShader shaderRef , out int kernelIndex )
private void LoadComputeShader ( string name , Fsr3Upscaler . InitializationFlags flags , ref ComputeShader shaderRef , out int kernelIndex )
{
if ( shaderRef = = null )
{
@ -80,12 +80,12 @@ namespace FidelityFX
#endif
// This matches the permutation rules from the CreatePipeline* functions
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 ( ( flags & Fsr3Upscaler . InitializationFlags . EnableHighDynamicRange ) ! = 0 ) shaderRef . EnableKeyword ( "FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT" ) ;
if ( ( flags & Fsr3Upscaler . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 ) shaderRef . EnableKeyword ( "FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS" ) ;
if ( ( flags & Fsr3Upscaler . InitializationFlags . EnableMotionVectorsJitterCancellation ) ! = 0 ) shaderRef . EnableKeyword ( "FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS" ) ;
if ( ( flags & Fsr3Upscaler . InitializationFlags . EnableDepthInverted ) ! = 0 ) shaderRef . EnableKeyword ( "FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH" ) ;
if ( useLut ) shaderRef . EnableKeyword ( "FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE" ) ;
if ( ( flags & Fsr2 . InitializationFlags . EnableFP16Usage ) ! = 0 ) shaderRef . EnableKeyword ( "FFX_HALF" ) ;
if ( ( flags & Fsr3Upscaler . InitializationFlags . EnableFP16Usage ) ! = 0 ) shaderRef . EnableKeyword ( "FFX_HALF" ) ;
// Inform the shader which render pipeline we're currently using
var pipeline = GraphicsSettings . currentRenderPipeline ;
@ -110,11 +110,11 @@ namespace FidelityFX
}
}
internal class Fsr2ComputeLuminancePyramidPass : Fsr2 Pass
internal class Fsr3UpscalerComputeLuminancePyramidPass : Fsr3Upscaler Pass
{
private readonly ComputeBuffer _spdConstants ;
public Fsr2ComputeLuminancePyramidPass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants , ComputeBuffer spdConstants )
public Fsr3UpscalerComputeLuminancePyramidPass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants , ComputeBuffer spdConstants )
: base ( contextDescription , resources , constants )
{
_spdConstants = spdConstants ;
@ -122,60 +122,60 @@ namespace FidelityFX
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 , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var color = ref dispatchParams . Color ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavSpdAtomicCount , Resources . SpdAtomicCounter ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavExposureMipLumaChange , Resources . SceneLuminance , ShadingChangeMipLevel ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavExposureMip5 , Resources . SceneLuminance , 5 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavSpdAtomicCount , Resources . SpdAtomicCounter ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavExposureMipLumaChange , Resources . SceneLuminance , ShadingChangeMipLevel ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavExposureMip5 , Resources . SceneLuminance , 5 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbSpd , _spdConstants , 0 , Marshal . SizeOf < Fsr2 . SpdConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbSpd , _spdConstants , 0 , Marshal . SizeOf < Fsr3Upscaler . SpdConstants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
internal class Fsr2ReconstructPreviousDepthPass : Fsr2 Pass
internal class Fsr3UpscalerReconstructPreviousDepthPass : Fsr3Upscaler Pass
{
public Fsr2ReconstructPreviousDepthPass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants )
public Fsr3UpscalerReconstructPreviousDepthPass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
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 , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var color = ref dispatchParams . Color ;
ref var depth = ref dispatchParams . Depth ;
ref var motionVectors = ref dispatchParams . MotionVectors ;
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . Fsr2Constants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
internal class Fsr2DepthClipPass : Fsr2 Pass
internal class Fsr3UpscalerDepthClipPass : Fsr3Upscaler Pass
{
public Fsr2DepthClipPass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants )
public Fsr3UpscalerDepthClipPass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
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 , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var color = ref dispatchParams . Color ;
ref var depth = ref dispatchParams . Depth ;
@ -184,42 +184,42 @@ namespace FidelityFX
ref var reactive = ref dispatchParams . Reactive ;
ref var tac = ref dispatchParams . TransparencyAndComposition ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvReconstructedPrevNearestDepth , Fsr2 ShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvDilatedDepth , Fsr2 ShaderIDs . UavDilatedDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvReconstructedPrevNearestDepth , Fsr3 ShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvDilatedDepth , Fsr3 ShaderIDs . UavDilatedDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . Fsr2Constants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
internal class Fsr2LockPass : Fsr2 Pass
internal class Fsr3UpscalerLockPass : Fsr3Upscaler Pass
{
public Fsr2LockPass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants )
public Fsr3UpscalerLockPass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
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 , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvLockInputLuma , Fsr2 ShaderIDs . UavLockInputLuma ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvLockInputLuma , Fsr3 ShaderIDs . UavLockInputLuma ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . Fsr2Constants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
internal class Fsr2AccumulatePass : Fsr2 Pass
internal class Fsr3UpscalerAccumulatePass : Fsr3Upscaler Pass
{
private const string SharpeningKeyword = "FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING" ;
@ -227,7 +227,7 @@ namespace FidelityFX
private readonly LocalKeyword _sharpeningKeyword ;
#endif
public Fsr2AccumulatePass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants )
public Fsr3UpscalerAccumulatePass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
LoadComputeShader ( "FSR3/ffx_fsr3upscaler_accumulate_pass" ) ;
@ -236,7 +236,7 @@ namespace FidelityFX
#endif
}
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
#if UNITY_2021_2_OR_NEWER
if ( dispatchParams . EnableSharpening )
@ -250,47 +250,47 @@ namespace FidelityFX
commandBuffer . DisableShaderKeyword ( SharpeningKeyword ) ;
#endif
if ( ( ContextDescription . Flags & Fsr2 . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 )
if ( ( ContextDescription . Flags & Fsr3Upscaler . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 )
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
}
else
{
ref var motionVectors = ref dispatchParams . MotionVectors ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
}
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvDilatedReactiveMasks , Fsr2 ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvLockStatus , Resources . LockStatus [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvPreparedInputColor , Fsr2 ShaderIDs . UavPreparedInputColor ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvLanczosLut , Resources . LanczosLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvUpscaleMaximumBiasLut , Resources . MaximumBiasLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvSceneLuminanceMips , Resources . SceneLuminance ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvLumaHistory , Resources . LumaHistory [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavInternalUpscaled , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavLockStatus , Resources . LockStatus [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvDilatedReactiveMasks , Fsr3 ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvLockStatus , Resources . LockStatus [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvPreparedInputColor , Fsr3 ShaderIDs . UavPreparedInputColor ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvLanczosLut , Resources . LanczosLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvUpscaleMaximumBiasLut , Resources . MaximumBiasLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvSceneLuminanceMips , Resources . SceneLuminance ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvLumaHistory , Resources . LumaHistory [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavInternalUpscaled , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavLockStatus , Resources . LockStatus [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . Fsr2Constants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
internal class Fsr2RcasPass : Fsr2 Pass
internal class Fsr3UpscalerRcasPass : Fsr3Upscaler Pass
{
private readonly ComputeBuffer _rcasConstants ;
public Fsr2RcasPass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants , ComputeBuffer rcasConstants )
public Fsr3UpscalerRcasPass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants , ComputeBuffer rcasConstants )
: base ( contextDescription , resources , constants )
{
_rcasConstants = rcasConstants ;
@ -298,27 +298,27 @@ namespace FidelityFX
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 , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvRcasInput , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvRcasInput , Resources . InternalUpscaled [ frameIndex ] ) ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbRcas , _rcasConstants , 0 , Marshal . SizeOf < Fsr2 . RcasConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbRcas , _rcasConstants , 0 , Marshal . SizeOf < Fsr3Upscaler . RcasConstants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
internal class Fsr2GenerateReactivePass : Fsr2 Pass
internal class Fsr3UpscalerGenerateReactivePass : Fsr3Upscaler Pass
{
private readonly ComputeBuffer _generateReactiveConstants ;
public Fsr2GenerateReactivePass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer generateReactiveConstants )
public Fsr3UpscalerGenerateReactivePass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer generateReactiveConstants )
: base ( contextDescription , resources , null )
{
_generateReactiveConstants = generateReactiveConstants ;
@ -326,31 +326,31 @@ namespace FidelityFX
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 , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
}
public void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . GenerateReactiveDescription dispatchParams , int dispatchX , int dispatchY )
public void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr3Upscaler . GenerateReactiveDescription dispatchParams , int dispatchX , int dispatchY )
{
ref var opaqueOnly = ref dispatchParams . ColorOpaqueOnly ;
ref var color = ref dispatchParams . ColorPreUpscale ;
ref var reactive = ref dispatchParams . OutReactive ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvOpaqueOnly , opaqueOnly . RenderTarget , opaqueOnly . MipLevel , opaqueOnly . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavAutoReactive , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvOpaqueOnly , opaqueOnly . RenderTarget , opaqueOnly . MipLevel , opaqueOnly . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavAutoReactive , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , Marshal . SizeOf < Fsr2 . GenerateReactiveConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , Marshal . SizeOf < Fsr3Upscaler . GenerateReactiveConstants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
internal class Fsr2TcrAutogeneratePass : Fsr2 Pass
internal class Fsr3UpscalerTcrAutogeneratePass : Fsr3Upscaler Pass
{
private readonly ComputeBuffer _tcrAutogenerateConstants ;
public Fsr2TcrAutogeneratePass ( Fsr2 . ContextDescription contextDescription , Fsr2 Resources resources , ComputeBuffer constants , ComputeBuffer tcrAutogenerateConstants )
public Fsr3UpscalerTcrAutogeneratePass ( Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler Resources resources , ComputeBuffer constants , ComputeBuffer tcrAutogenerateConstants )
: base ( contextDescription , resources , constants )
{
_tcrAutogenerateConstants = tcrAutogenerateConstants ;
@ -358,7 +358,7 @@ namespace FidelityFX
LoadComputeShader ( "FSR3/ffx_fsr3upscaler_tcr_autogen_pass" ) ;
}
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var color = ref dispatchParams . Color ;
ref var motionVectors = ref dispatchParams . MotionVectors ;
@ -366,21 +366,21 @@ namespace FidelityFX
ref var reactive = ref dispatchParams . Reactive ;
ref var tac = ref dispatchParams . TransparencyAndComposition ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvOpaqueOnly , opaqueOnly . RenderTarget , opaqueOnly . MipLevel , opaqueOnly . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvPrevColorPreAlpha , Resources . PrevPreAlpha [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvPrevColorPostAlpha , Resources . PrevPostAlpha [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavAutoReactive , Resources . AutoReactive ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavAutoComposition , Resources . AutoComposition ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavPrevColorPreAlpha , Resources . PrevPreAlpha [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2 ShaderIDs . UavPrevColorPostAlpha , Resources . PrevPostAlpha [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvOpaqueOnly , opaqueOnly . RenderTarget , opaqueOnly . MipLevel , opaqueOnly . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvPrevColorPreAlpha , Resources . PrevPreAlpha [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvPrevColorPostAlpha , Resources . PrevPostAlpha [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavAutoReactive , Resources . AutoReactive ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavAutoComposition , Resources . AutoComposition ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavPrevColorPreAlpha , Resources . PrevPreAlpha [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3 ShaderIDs . UavPrevColorPostAlpha , Resources . PrevPostAlpha [ frameIndex ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2 ShaderIDs . CbGenReactive , _tcrAutogenerateConstants , 0 , Marshal . SizeOf < Fsr2 . GenerateReactiveConstants2 > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3 ShaderIDs . CbGenReactive , _tcrAutogenerateConstants , 0 , Marshal . SizeOf < Fsr3Upscaler . GenerateReactiveConstants2 > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}