Browse Source

(FSR3) Clear new locks buffer ahead of the frame instead of at the end of the Accumulate pass. This makes more sense with NewLocks being an aliasable (temp RT) resource, and it avoids reading and writing to the same texture in the Accumulate pass.

fsr3.1.4
Nico de Poel 9 months ago
parent
commit
ef8a19887b
  1. 3
      Runtime/FSR3/Fsr3UpscalerContext.cs
  2. 1
      Runtime/FSR3/Fsr3UpscalerPass.cs
  3. 2
      Shaders/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl
  4. 4
      Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h

3
Runtime/FSR3/Fsr3UpscalerContext.cs

@ -249,6 +249,9 @@ namespace FidelityFX.FSR3
commandBuffer.SetRenderTarget(_resources.ReconstructedPrevNearestDepth); commandBuffer.SetRenderTarget(_resources.ReconstructedPrevNearestDepth);
commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white);
commandBuffer.SetRenderTarget(Fsr3ShaderIDs.UavNewLocks);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
// Auto exposure // Auto exposure
SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount);

1
Runtime/FSR3/Fsr3UpscalerPass.cs

@ -342,6 +342,7 @@ namespace FidelityFX.FSR3
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaInstability, Fsr3ShaderIDs.UavIntermediate); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaInstability, Fsr3ShaderIDs.UavIntermediate);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvNewLocks, Fsr3ShaderIDs.UavNewLocks);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement);

2
Shaders/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl

@ -34,10 +34,10 @@
#define FSR3UPSCALER_BIND_SRV_CURRENT_LUMA 6 #define FSR3UPSCALER_BIND_SRV_CURRENT_LUMA 6
#define FSR3UPSCALER_BIND_SRV_LUMA_INSTABILITY 7 #define FSR3UPSCALER_BIND_SRV_LUMA_INSTABILITY 7
#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 8 #define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 8
#define FSR3UPSCALER_BIND_SRV_NEW_LOCKS 9
#define FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED 0 #define FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED 0
#define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 1 #define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 1
#define FSR3UPSCALER_BIND_UAV_NEW_LOCKS 2
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 #define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0

4
Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h

@ -79,7 +79,7 @@ void UpdateLockStatus(AccumulationPassCommonParams params, FFX_PARAMETER_INOUT A
// Compute this frame lock contribution // Compute this frame lock contribution
data.fLockContributionThisFrame = ffxSaturate(ffxSaturate(data.fLock - fLockThreshold) * (fLockMax - fLockThreshold)); data.fLockContributionThisFrame = ffxSaturate(ffxSaturate(data.fLock - fLockThreshold) * (fLockMax - fLockThreshold));
const FfxFloat32 fNewLockIntensity = LoadRwNewLocks(params.iPxHrPos) * (1.0f - ffxMax(params.fShadingChange * 0, params.fReactiveMask));
const FfxFloat32 fNewLockIntensity = LoadNewLocks(params.iPxHrPos) * (1.0f - ffxMax(params.fShadingChange * 0, params.fReactiveMask));
data.fLock = ffxMax(0.0f, ffxMin(data.fLock + fNewLockIntensity, fLockMax)); data.fLock = ffxMax(0.0f, ffxMin(data.fLock + fNewLockIntensity, fLockMax));
// Preparing for next frame // Preparing for next frame
@ -169,5 +169,5 @@ void Accumulate(FfxInt32x2 iPxHrPos)
#if FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING == 0 #if FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING == 0
StoreUpscaledOutput(iPxHrPos, data.fHistoryColor); StoreUpscaledOutput(iPxHrPos, data.fHistoryColor);
#endif #endif
StoreNewLocks(iPxHrPos, 0);
//StoreNewLocks(iPxHrPos, 0);
} }
Loading…
Cancel
Save