@ -28,35 +28,40 @@ namespace FidelityFX
internal static readonly int SrvInputMotionVectors = Shader . PropertyToID ( "r_input_motion_vectors" ) ;
internal static readonly int SrvInputMotionVectors = Shader . PropertyToID ( "r_input_motion_vectors" ) ;
internal static readonly int SrvInputDepth = Shader . PropertyToID ( "r_input_depth" ) ;
internal static readonly int SrvInputDepth = Shader . PropertyToID ( "r_input_depth" ) ;
internal static readonly int SrvInputExposure = Shader . PropertyToID ( "r_input_exposure" ) ;
internal static readonly int SrvInputExposure = Shader . PropertyToID ( "r_input_exposure" ) ;
internal static readonly int SrvDilatedMotionVectors = Shader . PropertyToID ( "r_dilated_motion_vectors " ) ;
internal static readonly int SrvAutoExposure = Shader . PropertyToID ( "r_auto_exposure " ) ;
internal static readonly int SrvReactiveMask = Shader . PropertyToID ( "r_reactive_mask" ) ;
internal static readonly int SrvReactiveMask = Shader . PropertyToID ( "r_reactive_mask" ) ;
internal static readonly int SrvTransparencyAndCompositionMask = Shader . PropertyToID ( "r_transparency_and_composition_mask" ) ;
internal static readonly int SrvTransparencyAndCompositionMask = Shader . PropertyToID ( "r_transparency_and_composition_mask" ) ;
internal static readonly int SrvReconstructedPrevNearestDepth = Shader . PropertyToID ( "r_reconstructed_previous_nearest_depth" ) ;
internal static readonly int SrvDilatedMotionVectors = Shader . PropertyToID ( "r_dilated_motion_vectors" ) ;
internal static readonly int SrvPrevDilatedMotionVectors = Shader . PropertyToID ( "r_previous_dilated_motion_vectors" ) ;
internal static readonly int SrvPrevDilatedMotionVectors = Shader . PropertyToID ( "r_previous_dilated_motion_vectors" ) ;
internal static readonly int SrvDilatedDepth = Shader . PropertyToID ( "r_dilatedDepth" ) ;
internal static readonly int SrvInternalUpscaled = Shader . PropertyToID ( "r_internal_upscaled_color" ) ;
internal static readonly int SrvInternalUpscaled = Shader . PropertyToID ( "r_internal_upscaled_color" ) ;
internal static readonly int SrvLockStatus = Shader . PropertyToID ( "r_lock_status" ) ;
internal static readonly int SrvLockStatus = Shader . PropertyToID ( "r_lock_status" ) ;
internal static readonly int SrvLanczosLut = Shader . PropertyToID ( "r_lanczos_lut" ) ;
internal static readonly int SrvUpscaleMaximumBiasLut = Shader . PropertyToID ( "r_upsample_maximum_bias_lut" ) ;
internal static readonly int SrvSceneLuminanceMips = Shader . PropertyToID ( "r_imgMips" ) ;
internal static readonly int SrvAutoExposure = Shader . PropertyToID ( "r_auto_exposure" ) ;
internal static readonly int SrvLockInputLuma = Shader . PropertyToID ( "r_lock_input_luma" ) ;
internal static readonly int SrvPreparedInputColor = Shader . PropertyToID ( "r_prepared_input_color" ) ;
internal static readonly int SrvLumaHistory = Shader . PropertyToID ( "r_luma_history" ) ;
internal static readonly int SrvLumaHistory = Shader . PropertyToID ( "r_luma_history" ) ;
internal static readonly int SrvRcasInput = Shader . PropertyToID ( "r_rcas_input" ) ;
internal static readonly int SrvRcasInput = Shader . PropertyToID ( "r_rcas_input" ) ;
internal static readonly int SrvLanczosLut = Shader . PropertyToID ( "r_lanczos_lut" ) ;
internal static readonly int SrvSceneLuminanceMips = Shader . PropertyToID ( "r_imgMips" ) ;
internal static readonly int SrvUpscaleMaximumBiasLut = Shader . PropertyToID ( "r_upsample_maximum_bias_lut" ) ;
internal static readonly int SrvDilatedReactiveMasks = Shader . PropertyToID ( "r_dilated_reactive_masks" ) ;
// Unordered access views, i.e. random read/write bindings
// Unordered access views, i.e. random read/write bindings
internal static readonly int UavUpscaledOutput = Shader . PropertyToID ( "rw_upscaled_output" ) ;
internal static readonly int UavExposureMipLumaChange = Shader . PropertyToID ( "rw_img_mip_shading_change" ) ;
internal static readonly int UavExposureMip5 = Shader . PropertyToID ( "rw_img_mip_5" ) ;
internal static readonly int UavAutoExposure = Shader . PropertyToID ( "rw_auto_exposure" ) ;
internal static readonly int UavSpdAtomicCount = Shader . PropertyToID ( "rw_spd_global_atomic" ) ;
internal static readonly int UavReconstructedPrevNearestDepth = Shader . PropertyToID ( "rw_reconstructed_previous_nearest_depth" ) ;
internal static readonly int UavReconstructedPrevNearestDepth = Shader . PropertyToID ( "rw_reconstructed_previous_nearest_depth" ) ;
internal static readonly int UavDilatedMotionVectors = Shader . PropertyToID ( "rw_dilated_motion_vectors" ) ;
internal static readonly int UavDilatedMotionVectors = Shader . PropertyToID ( "rw_dilated_motion_vectors" ) ;
internal static readonly int UavDilatedDepth = Shader . PropertyToID ( "rw_dilatedDepth" ) ;
internal static readonly int UavDilatedDepth = Shader . PropertyToID ( "rw_dilatedDepth" ) ;
internal static readonly int UavLockInputLuma = Shader . PropertyToID ( "rw_lock_input_luma" ) ;
internal static readonly int UavDilatedReactiveMasks = Shader . PropertyToID ( "rw_dilated_reactive_masks" ) ;
internal static readonly int UavPreparedInputColor = Shader . PropertyToID ( "rw_prepared_input_color" ) ;
internal static readonly int UavNewLocks = Shader . PropertyToID ( "rw_new_locks" ) ;
internal static readonly int UavInternalUpscaled = Shader . PropertyToID ( "rw_internal_upscaled_color" ) ;
internal static readonly int UavInternalUpscaled = Shader . PropertyToID ( "rw_internal_upscaled_color" ) ;
internal static readonly int UavLockStatus = Shader . PropertyToID ( "rw_lock_status" ) ;
internal static readonly int UavLockStatus = Shader . PropertyToID ( "rw_lock_status" ) ;
internal static readonly int UavLockInputLuma = Shader . PropertyToID ( "rw_lock_input_luma" ) ;
internal static readonly int UavNewLocks = Shader . PropertyToID ( "rw_new_locks" ) ;
internal static readonly int UavPreparedInputColor = Shader . PropertyToID ( "rw_prepared_input_color" ) ;
internal static readonly int UavLumaHistory = Shader . PropertyToID ( "rw_luma_history" ) ;
internal static readonly int UavLumaHistory = Shader . PropertyToID ( "rw_luma_history" ) ;
internal static readonly int UavUpscaledOutput = Shader . PropertyToID ( "rw_upscaled_output" ) ;
internal static readonly int UavExposureMipLumaChange = Shader . PropertyToID ( "rw_img_mip_shading_change" ) ;
internal static readonly int UavExposureMip5 = Shader . PropertyToID ( "rw_img_mip_5" ) ;
internal static readonly int UavDilatedReactiveMasks = Shader . PropertyToID ( "rw_dilated_reactive_masks" ) ;
internal static readonly int UavAutoExposure = Shader . PropertyToID ( "rw_auto_exposure" ) ;
internal static readonly int UavSpdAtomicCount = Shader . PropertyToID ( "rw_spd_global_atomic" ) ;
internal static readonly int UavAutoReactive = Shader . PropertyToID ( "rw_output_autoreactive" ) ;
internal static readonly int UavAutoReactive = Shader . PropertyToID ( "rw_output_autoreactive" ) ;
// Constant buffer bindings
// Constant buffer bindings
@ -255,7 +260,9 @@ namespace FidelityFX
if ( dispatchParams . Reactive . HasValue )
if ( dispatchParams . Reactive . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvReactiveMask , dispatchParams . Reactive . Value ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvReactiveMask , dispatchParams . Reactive . Value ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvReconstructedPrevNearestDepth , UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvDilatedDepth , UavDilatedDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvTransparencyAndCompositionMask , Resources . DefaultReactive ) ; // Default reactive mask, as we don't support TCR (yet)
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvTransparencyAndCompositionMask , Resources . DefaultReactive ) ; // Default reactive mask, as we don't support TCR (yet)
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
@ -275,6 +282,7 @@ namespace FidelityFX
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 )
{
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvLockInputLuma , UavLockInputLuma ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , CbFsr2 , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , CbFsr2 , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
@ -302,8 +310,10 @@ namespace FidelityFX
if ( dispatchParams . Exposure . HasValue )
if ( dispatchParams . Exposure . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvInputExposure , dispatchParams . Exposure . Value ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvInputExposure , dispatchParams . Exposure . Value ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvDilatedReactiveMasks , UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvLockStatus , Resources . LockStatus [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvLockStatus , Resources . LockStatus [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvPreparedInputColor , UavPreparedInputColor ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvLanczosLut , Resources . LanczosLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvLanczosLut , Resources . LanczosLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvUpscaleMaximumBiasLut , Resources . MaximumBiasLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvUpscaleMaximumBiasLut , Resources . MaximumBiasLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvSceneLuminanceMips , Resources . SceneLuminance ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , SrvSceneLuminanceMips , Resources . SceneLuminance ) ;