Browse Source

(FSR2) 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
5bb38aa76d
  1. 3
      Runtime/FSR2/Fsr2Context.cs
  2. 1
      Runtime/FSR2/Fsr2Pass.cs
  3. 1
      Runtime/FSR2/Fsr2ShaderIDs.cs
  4. 4
      Shaders/shaders/ffx_fsr2_accumulate_pass.hlsl
  5. 2
      Shaders/shaders/fsr2/ffx_fsr2_accumulate.h
  6. 2
      Shaders/shaders/fsr2/ffx_fsr2_reproject.h

3
Runtime/FSR2/Fsr2Context.cs

@ -224,6 +224,9 @@ namespace FidelityFX.FSR2
commandBuffer.SetRenderTarget(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth);
commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white);
commandBuffer.SetRenderTarget(Fsr2ShaderIDs.UavNewLocks);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
// Auto exposure
SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount);

1
Runtime/FSR2/Fsr2Pass.cs

@ -274,6 +274,7 @@ namespace FidelityFX.FSR2
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvSceneLuminanceMips, Resources.SceneLuminance);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvAutoExposure, Resources.AutoExposure[frameIndex]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvNewLocks, Fsr2ShaderIDs.UavNewLocks);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavLockStatus, Resources.LockStatus[frameIndex]);

1
Runtime/FSR2/Fsr2ShaderIDs.cs

@ -39,6 +39,7 @@ namespace FidelityFX.FSR2
public static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilatedDepth");
public static readonly int SrvInternalUpscaled = Shader.PropertyToID("r_internal_upscaled_color");
public static readonly int SrvLockStatus = Shader.PropertyToID("r_lock_status");
public static readonly int SrvNewLocks = Shader.PropertyToID("r_new_locks");
public static readonly int SrvLockInputLuma = Shader.PropertyToID("r_lock_input_luma");
public static readonly int SrvPreparedInputColor = Shader.PropertyToID("r_prepared_input_color");
public static readonly int SrvLumaHistory = Shader.PropertyToID("r_luma_history");

4
Shaders/shaders/ffx_fsr2_accumulate_pass.hlsl

@ -35,12 +35,12 @@
#define FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS 8
#define FSR2_BIND_SRV_AUTO_EXPOSURE 9
#define FSR2_BIND_SRV_LUMA_HISTORY 10
#define FSR2_BIND_SRV_NEW_LOCKS 11
#define FSR2_BIND_UAV_INTERNAL_UPSCALED 0
#define FSR2_BIND_UAV_LOCK_STATUS 1
#define FSR2_BIND_UAV_UPSCALED_OUTPUT 2
#define FSR2_BIND_UAV_NEW_LOCKS 3
#define FSR2_BIND_UAV_LUMA_HISTORY 4
#define FSR2_BIND_UAV_LUMA_HISTORY 3
#define FSR2_BIND_CB_FSR2 0

2
Shaders/shaders/fsr2/ffx_fsr2_accumulate.h

@ -289,7 +289,7 @@ void Accumulate(FfxInt32x2 iPxHrPos)
#if FFX_FSR2_OPTION_APPLY_SHARPENING == 0
WriteUpscaledOutput(iPxHrPos, fHistoryColor);
#endif
StoreNewLocks(iPxHrPos, 0);
//StoreNewLocks(iPxHrPos, 0);
}
#endif // FFX_FSR2_ACCUMULATE_H

2
Shaders/shaders/fsr2/ffx_fsr2_reproject.h

@ -120,7 +120,7 @@ void ReprojectHistoryColor(const AccumulationPassCommonParams params, FFX_PARAME
LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, FFX_PARAMETER_OUT FfxFloat32x2 fReprojectedLockStatus)
{
LockState state = { FFX_FALSE, FFX_FALSE };
const FfxFloat32 fNewLockIntensity = LoadRwNewLocks(params.iPxHrPos);
const FfxFloat32 fNewLockIntensity = LoadNewLocks(params.iPxHrPos);
state.NewLock = fNewLockIntensity > (127.0f / 255.0f);
FfxFloat32 fInPlaceLockLifetime = state.NewLock ? fNewLockIntensity : 0;

Loading…
Cancel
Save