@ -34,7 +34,7 @@ namespace ArmASR
/// </summary>
internal abstract class AsrPass : IDisposable
{
internal const int ShadingChangeMipLevel = 4 ; // This matches the FFXM_FSR2_SHADING_CHANGE_MIP_LEVEL define // TODO: still relevant?
internal const int ShadingChangeMipLevel = 4 ; // This matches the FFXM_FSR2_SHADING_CHANGE_MIP_LEVEL define
protected readonly Asr . ContextDescription ContextDescription ;
protected readonly AsrResources Resources ;
@ -162,6 +162,8 @@ namespace ArmASR
internal class AsrReconstructPreviousDepthPass : AsrPass
{
private readonly RenderTargetIdentifier [ ] _mrt = new RenderTargetIdentifier [ 3 ] ;
public AsrReconstructPreviousDepthPass ( Asr . ContextDescription contextDescription , AsrResources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
@ -175,8 +177,15 @@ namespace ArmASR
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputExposure , dispatchParams . Exposure ) ;
// TODO UAVs in fragment shaders? That seems like it might be a problem...
commandBuffer . SetGlobalTexture ( AsrShaderIDs . UavReconstructedPrevNearestDepth , AsrShaderIDs . UavReconstructedPrevNearestDepth ) ;
_mrt [ 0 ] = AsrShaderIDs . RtDilatedDepth ; // fDepth
_mrt [ 1 ] = Resources . DilatedMotionVectors [ frameIndex ] ; // fMotionVector
_mrt [ 2 ] = AsrShaderIDs . RtLockInputLuma ; // fLuma
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
BlitFragment ( commandBuffer , Resources . DilatedMotionVectors [ frameIndex ] ) ;
BlitFragment ( commandBuffer , _mrt ) ;
}
}
@ -204,8 +213,8 @@ namespace ArmASR
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvDilatedDepth , AsrShaderIDs . UavDilatedDepth ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
_mrt [ 0 ] = AsrShaderIDs . Uav DilatedReactiveMasks;
_mrt [ 1 ] = BuiltinRenderTextureType . None ; // TODO: Tonemapped
_mrt [ 0 ] = AsrShaderIDs . Rt DilatedReactiveMasks; // fDilatedReactiveMasks
_mrt [ 1 ] = AsrShaderIDs . RtPreparedInputColor ; // f Tonemapped
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
BlitFragment ( commandBuffer , _mrt ) ;
@ -223,6 +232,10 @@ namespace ArmASR
protected override void DoScheduleDispatch ( CommandBuffer commandBuffer , Asr . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvLockInputLuma , AsrShaderIDs . UavLockInputLuma ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavNewLocks , AsrShaderIDs . UavNewLocks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavReconstructedPrevNearestDepth , AsrShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
@ -261,19 +274,26 @@ namespace ArmASR
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvSceneLuminanceMips , Resources . SceneLuminance ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvLumaHistory , Resources . LumaHistory [ frameIndex ^ 1 ] ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvInternalTemporalReactive , Resources . InternalReactive [ frameIndex ^ 1 ] ) ;
// TODO UAVs in fragment shaders? That seems like it might be a problem...
commandBuffer . SetGlobalTexture ( AsrShaderIDs . UavNewLocks , AsrShaderIDs . UavNewLocks ) ;
if ( ContextDescription . Variant = = Asr . Variant . Quality )
{
_mrt [ 0 ] = Resources . InternalUpscaled [ frameIndex ] ; // TODO: ColorAndWeight
_mrt [ 1 ] = Resources . LockStatus [ frameIndex ] ;
_mrt [ 2 ] = Resources . LumaHistory [ frameIndex ] ;
_mrt [ 3 ] = dispatchParams . EnableSharpening ? BuiltinRenderTextureType . None : dispatchParams . Output . RenderTarget ;
_mrt [ 0 ] = Resources . InternalUpscaled [ frameIndex ] ; // fColorAndWeight
_mrt [ 1 ] = Resources . LockStatus [ frameIndex ] ; // fLockStatus
_mrt [ 2 ] = Resources . LumaHistory [ frameIndex ] ; // fLumaHistory
}
else
{
// TODO: UpscaledColor, TemporalReactive, LockStatus, Color
_mrt [ 0 ] = Resources . InternalUpscaled [ frameIndex ] ; // fUpscaledColor
_mrt [ 1 ] = Resources . InternalReactive [ frameIndex ] ; // fTemporalReactive
_mrt [ 2 ] = Resources . LockStatus [ frameIndex ] ; // fLockStatus
}
_mrt [ 3 ] = dispatchParams . EnableSharpening ? BuiltinRenderTextureType . None : dispatchParams . Output . RenderTarget ; // fColor
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
BlitFragment ( commandBuffer , _mrt ) ;
}
@ -325,6 +345,7 @@ namespace ArmASR
commandBuffer . SetComputeResourceParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvOpaqueOnly , dispatchParams . ColorOpaqueOnly ) ;
commandBuffer . SetComputeResourceParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputColor , dispatchParams . ColorPreUpscale ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , _generateReactiveConstants . stride ) ;
BlitFragment ( commandBuffer , dispatchParams . OutReactive . RenderTarget ) ;