@ -107,14 +107,15 @@ namespace FidelityFX
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 , Fsr3ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavDilatedMotionVectors , Resources . DilatedVelocity ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavDilatedDepth , Resources . DilatedDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavReconstructedPrevNearestDepth , Resources . ReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavCurrentLuma , Resources . Luma [ frameIndex ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
@ -136,13 +137,17 @@ namespace FidelityFX
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 , Fsr3ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvCurrentLuma , Resources . Luma [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvFarthestDepth , Fsr3ShaderIDs . UavFarthestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdAtomicCount , Resources . SpdAtomicCounter ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavExposureMipLumaChange , Resources . SceneLuminance , ShadingChangeMipLevel ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavExposureMip5 , Resources . SceneLuminance , 5 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavFrameInfo , Resources . FrameInfo ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip0 , Resources . SpdMips , 0 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip1 , Resources . SpdMips , 1 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip2 , Resources . SpdMips , 2 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip3 , Resources . SpdMips , 3 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip4 , Resources . SpdMips , 4 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip5 , Resources . SpdMips , 5 ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbSpd , _spdConstants , 0 , Marshal . SizeOf < Fsr3Upscaler . SpdConstants > ( ) ) ;
@ -165,7 +170,27 @@ namespace FidelityFX
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
throw new NotImplementedException ( ) ;
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvCurrentLuma , Resources . Luma [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvPreviousLuma , Resources . Luma [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedVelocity ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
// TODO: possibly the atomic counter might have to get cleared in-between passes. Check on MacOS whether we have issues with this or not.
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdAtomicCount , Resources . SpdAtomicCounter ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip0 , Resources . SpdMips , 0 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip1 , Resources . SpdMips , 1 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip2 , Resources . SpdMips , 2 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip3 , Resources . SpdMips , 3 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip4 , Resources . SpdMips , 4 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavSpdMip5 , Resources . SpdMips , 5 ) ;
// TODO: this seems odd to me, overwriting SpdMips before the result of the previous pass is used. Maybe it reads & writes in the above shader? Need to check.
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbSpd , _spdConstants , 0 , Marshal . SizeOf < Fsr3Upscaler . SpdConstants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
@ -179,7 +204,11 @@ namespace FidelityFX
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
throw new NotImplementedException ( ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvSpdMips , Resources . SpdMips ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
}
}
@ -193,24 +222,21 @@ namespace FidelityFX
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 ;
ref var reactive = ref dispatchParams . Reactive ;
ref var tac = ref dispatchParams . TransparencyAndComposition ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvReconstructedPrevNearestDepth , Resources . ReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedVelocity ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedDepth , Fsr3ShaderIDs . UavDilatedDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvAccumulation , Resources . Accumulation [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvShadingChange , Fsr3ShaderIDs . UavShadingChange ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvCurrentLuma , Resources . Luma [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvReconstructedPrevNearestDepth , Fsr3ShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedDepth , Fsr3ShaderIDs . UavDilatedDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavAccumulation , Resources . Accumulation [ frameIndex ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
@ -228,7 +254,18 @@ namespace FidelityFX
public override void ScheduleDispatch ( CommandBuffer commandBuffer , Fsr3Upscaler . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvLockInputLuma , Fsr3ShaderIDs . UavLockInputLuma ) ;
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedReactiveMasks , Fsr3ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedVelocity ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvFrameInfo , Resources . FrameInfo ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvLumaHistory , Resources . LumaHistory [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvFarthestDepthMip1 , Fsr3ShaderIDs . UavFarthestDepthMip1 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvCurrentLuma , Resources . Luma [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
@ -266,9 +303,15 @@ namespace FidelityFX
commandBuffer . DisableShaderKeyword ( SharpeningKeyword ) ;
#endif
ref var color = ref dispatchParams . Color ;
ref var exposure = ref dispatchParams . Exposure ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
if ( ( ContextDescription . Flags & Fsr3Upscaler . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 )
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedMotionVectors , Resources . DilatedVelocity ) ;
}
else
{
@ -276,24 +319,14 @@ namespace FidelityFX
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
}
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvDilatedReactiveMasks , Fsr3ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvLockStatus , Resources . LockStatus [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvPreparedInputColor , Fsr3ShaderIDs . UavPreparedInputColor ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvLanczosLut , Resources . LanczosLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvUpscaleMaximumBiasLut , Resources . MaximumBiasLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvSceneLuminanceMips , Resources . SceneLuminance ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvLumaHistory , Resources . LumaHistory [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavInternalUpscaled , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavLockStatus , Resources . LockStatus [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvFarthestDepthMip1 , Fsr3ShaderIDs . UavFarthestDepthMip1 ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvCurrentLuma , Resources . Luma [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvLumaInstability , Fsr3ShaderIDs . UavLumaInstability ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavInternalUpscaled , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
@ -356,6 +389,7 @@ namespace FidelityFX
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , Fsr3ShaderIDs . UavAutoReactive , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbFsr3Upscaler , Constants , 0 , Marshal . SizeOf < Fsr3Upscaler . UpscalerConstants > ( ) ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , Fsr3ShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , Marshal . SizeOf < Fsr3Upscaler . GenerateReactiveConstants > ( ) ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;