@ -129,8 +129,8 @@ 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 )
{
{
if ( dispatchParams . Color . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , dispatchParams . Color . Value , 0 , RenderTextureSubElement . Color ) ;
ref var color = ref dispatchParams . Color ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavSpdAtomicCount , Resources . SpdAtomicCounter ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavSpdAtomicCount , Resources . SpdAtomicCounter ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavExposureMipLumaChange , Resources . SceneLuminance , ShadingChangeMipLevel ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavExposureMipLumaChange , Resources . SceneLuminance , ShadingChangeMipLevel ) ;
@ -154,17 +154,19 @@ 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 )
{
{
if ( dispatchParams . Color . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , dispatchParams . Color . Value , 0 , RenderTextureSubElement . Color ) ;
ref var color = ref dispatchParams . Color ;
ref var depth = ref dispatchParams . Depth ;
ref var motionVectors = ref dispatchParams . MotionVectors ;
if ( dispatchParams . Depth . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputDepth , dispatchParams . Depth . Value , 0 , RenderTextureSubElement . Depth ) ;
if ( dispatchParams . MotionVectors . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors . Value ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
if ( dispatchParams . Exposure . HasValue )
if ( dispatchParams . Exposure . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , dispatchParams . Exposure . Value ) ;
{
var exposure = dispatchParams . Exposure . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
}
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
@ -184,23 +186,31 @@ 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 )
{
{
if ( dispatchParams . Color . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , dispatchParams . Color . Value , 0 , RenderTextureSubElement . Color ) ;
if ( dispatchParams . Depth . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputDepth , dispatchParams . Depth . Value , 0 , RenderTextureSubElement . Depth ) ;
ref var color = ref dispatchParams . Color ;
ref var depth = ref dispatchParams . Depth ;
ref var motionVectors = ref dispatchParams . MotionVectors ;
if ( dispatchParams . MotionVectors . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors . Value ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
if ( dispatchParams . Exposure . HasValue )
if ( dispatchParams . Exposure . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , dispatchParams . Exposure . Value ) ;
{
var exposure = dispatchParams . Exposure . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
}
if ( dispatchParams . Reactive . HasValue )
if ( dispatchParams . Reactive . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvReactiveMask , dispatchParams . Reactive . Value ) ;
{
var reactive = dispatchParams . Reactive . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
}
if ( dispatchParams . TransparencyAndComposition . HasValue )
if ( dispatchParams . TransparencyAndComposition . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvTransparencyAndCompositionMask , dispatchParams . TransparencyAndComposition . Value ) ;
{
var tac = dispatchParams . TransparencyAndComposition . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
}
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvReconstructedPrevNearestDepth , Fsr2ShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvReconstructedPrevNearestDepth , Fsr2ShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
@ -265,12 +275,20 @@ namespace FidelityFX
#endif
#endif
if ( ( ContextDescription . Flags & Fsr2 . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 )
if ( ( ContextDescription . Flags & Fsr2 . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 )
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
else if ( dispatchParams . MotionVectors . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors . Value ) ;
}
else
{
ref var motionVectors = ref dispatchParams . MotionVectors ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
}
if ( dispatchParams . Exposure . HasValue )
if ( dispatchParams . Exposure . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , dispatchParams . Exposure . Value ) ;
{
var exposure = dispatchParams . Exposure . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
}
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvDilatedReactiveMasks , Fsr2ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvDilatedReactiveMasks , Fsr2ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
@ -286,8 +304,8 @@ namespace FidelityFX
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavLockStatus , Resources . LockStatus [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavLockStatus , Resources . LockStatus [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
if ( dispatchParams . Output . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavUpscaledOutput , dispatchParams . Output . Value ) ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbFsr2 , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbFsr2 , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
@ -310,12 +328,15 @@ 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 )
{
{
if ( dispatchParams . Exposure . HasValue )
if ( dispatchParams . Exposure . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , dispatchParams . Exposure . Value ) ;
{
var exposure = dispatchParams . Exposure . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
}
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvRcasInput , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvRcasInput , Resources . InternalUpscaled [ frameIndex ] ) ;
if ( dispatchParams . Output . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavUpscaledOutput , dispatchParams . Output . Value ) ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbFsr2 , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbFsr2 , Constants , 0 , Marshal . SizeOf < Fsr2 . Fsr2Constants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbRcas , _rcasConstants , 0 , Marshal . SizeOf < Fsr2 . RcasConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbRcas , _rcasConstants , 0 , Marshal . SizeOf < Fsr2 . RcasConstants > ( ) ) ;
@ -342,14 +363,13 @@ namespace FidelityFX
public void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . GenerateReactiveDescription dispatchParams , int dispatchX , int dispatchY )
public void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr2 . GenerateReactiveDescription dispatchParams , int dispatchX , int dispatchY )
{
{
if ( dispatchParams . ColorOpaqueOnly . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvOpaqueOnly , dispatchParams . ColorOpaqueOnly . Value , 0 , RenderTextureSubElement . Color ) ;
if ( dispatchParams . ColorPreUpscale . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , dispatchParams . ColorPreUpscale . Value , 0 , RenderTextureSubElement . Color ) ;
ref var opaqueOnly = ref dispatchParams . ColorOpaqueOnly ;
ref var color = ref dispatchParams . ColorPreUpscale ;
ref var reactive = ref dispatchParams . OutReactive ;
if ( dispatchParams . OutReactive . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavAutoReactive , dispatchParams . OutReactive . Value ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvOpaqueOnly , opaqueOnly . RenderTarget , opaqueOnly . MipLevel , opaqueOnly . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavAutoReactive , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , Marshal . SizeOf < Fsr2 . GenerateReactiveConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr2ShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , Marshal . SizeOf < Fsr2 . GenerateReactiveConstants > ( ) ) ;
@ -372,22 +392,30 @@ 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 )
{
{
if ( dispatchParams . ColorOpaqueOnly . HasValue )
if ( dispatchParams . ColorOpaqueOnly . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvOpaqueOnly , dispatchParams . ColorOpaqueOnly . Value , 0 , RenderTextureSubElement . Color ) ;
if ( dispatchParams . Color . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , dispatchParams . Color . Value , 0 , RenderTextureSubElement . Color ) ;
{
var opaqueOnly = dispatchParams . ColorOpaqueOnly . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvOpaqueOnly , opaqueOnly . RenderTarget , opaqueOnly . MipLevel , opaqueOnly . SubElement ) ;
}
if ( dispatchParams . MotionVectors . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors . Value ) ;
ref var color = ref dispatchParams . Color ;
ref var motionVectors = ref dispatchParams . MotionVectors ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvPrevColorPreAlpha , Resources . PrevPreAlpha [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvPrevColorPreAlpha , Resources . PrevPreAlpha [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvPrevColorPostAlpha , Resources . PrevPostAlpha [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvPrevColorPostAlpha , Resources . PrevPostAlpha [ frameIndex ^ 1 ] ) ;
if ( dispatchParams . Reactive . HasValue )
if ( dispatchParams . Reactive . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvReactiveMask , dispatchParams . Reactive . Value ) ;
{
var reactive = dispatchParams . Reactive . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
}
if ( dispatchParams . TransparencyAndComposition . HasValue )
if ( dispatchParams . TransparencyAndComposition . HasValue )
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvTransparencyAndCompositionMask , dispatchParams . TransparencyAndComposition . Value ) ;
{
var tac = dispatchParams . TransparencyAndComposition . Value ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
}
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavAutoReactive , Resources . AutoReactive ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavAutoReactive , Resources . AutoReactive ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavAutoComposition , Resources . AutoComposition ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr2ShaderIDs . UavAutoComposition , Resources . AutoComposition ) ;