Browse Source

Bind new locks to the accumulate shader as a regular SRV (read-only), and clear the locks buffer ahead of time instead of at the end of the accumulate shader. This simplifies the shader binding setup, as well as being "more correct" because we're using a temporary RT for the locks buffer, meaning it makes no sense to clear it for the next frame.

asr-console
Nico de Poel 10 months ago
parent
commit
3912c66b0d
  1. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs
  2. 4
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
  3. 4
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl
  4. 1
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h
  5. 4
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reproject.h

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs

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

4
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs

@ -277,9 +277,7 @@ namespace ArmASR
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvAutoExposure, Resources.AutoExposure[frameIndex]); commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvAutoExposure, Resources.AutoExposure[frameIndex]);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvInternalTemporalReactive, Resources.InternalReactive[frameIndex ^ 1]); commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvInternalTemporalReactive, Resources.InternalReactive[frameIndex ^ 1]);
// UAV binding in fragment shader, index needs to match the register binding in HLSL
commandBuffer.SetRandomWriteTarget(4, AsrShaderIDs.UavNewLocks);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvNewLocks, AsrShaderIDs.UavNewLocks);
if (ContextDescription.Variant == Asr.Variant.Quality) if (ContextDescription.Variant == Asr.Variant.Quality)
{ {

4
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl

@ -35,8 +35,7 @@
#define FSR2_BIND_SRV_AUTO_EXPOSURE 9 #define FSR2_BIND_SRV_AUTO_EXPOSURE 9
#define FSR2_BIND_SRV_LUMA_HISTORY 10 #define FSR2_BIND_SRV_LUMA_HISTORY 10
#define FSR2_BIND_SRV_TEMPORAL_REACTIVE 11 #define FSR2_BIND_SRV_TEMPORAL_REACTIVE 11
#define FSR2_BIND_UAV_NEW_LOCKS 4
#define FSR2_BIND_SRV_NEW_LOCKS 12
#define FSR2_BIND_CB_FSR2 0 #define FSR2_BIND_CB_FSR2 0
@ -60,7 +59,6 @@
#pragma PSSL_target_output_format(target 0 FMT_FP16_ABGR) #pragma PSSL_target_output_format(target 0 FMT_FP16_ABGR)
#pragma PSSL_target_output_format(target 1 FMT_FP16_ABGR) #pragma PSSL_target_output_format(target 1 FMT_FP16_ABGR)
#pragma PSSL_target_output_format(target 2 FMT_FP16_ABGR) #pragma PSSL_target_output_format(target 2 FMT_FP16_ABGR)
#pragma PSSL_target_output_format(target 4 FMT_32_R)
#endif #endif
struct AccumulateOutputsFS struct AccumulateOutputsFS

1
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h

@ -372,7 +372,6 @@ AccumulateOutputs Accumulate(FfxInt32x2 iPxHrPos)
#if FFXM_FSR2_OPTION_APPLY_SHARPENING == 0 #if FFXM_FSR2_OPTION_APPLY_SHARPENING == 0
results.fColor = fHistoryColor; results.fColor = fHistoryColor;
#endif #endif
//StoreNewLocks(iPxHrPos, 0);
return results; return results;
} }

4
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reproject.h

@ -331,7 +331,7 @@ void ReprojectHistoryColor(const AccumulationPassCommonParams params, FFXM_PARAM
LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat32x2 fReprojectedLockStatus) LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat32x2 fReprojectedLockStatus)
{ {
LockState state = { FFXM_FALSE, FFXM_FALSE }; LockState state = { FFXM_FALSE, FFXM_FALSE };
const FfxFloat32 fNewLockIntensity = LoadRwNewLocks(params.iPxHrPos);
const FfxFloat32 fNewLockIntensity = LoadNewLocks(params.iPxHrPos);
state.NewLock = fNewLockIntensity > (127.0f / 255.0f); state.NewLock = fNewLockIntensity > (127.0f / 255.0f);
FfxFloat32 fInPlaceLockLifetime = state.NewLock ? fNewLockIntensity : 0; FfxFloat32 fInPlaceLockLifetime = state.NewLock ? fNewLockIntensity : 0;
@ -368,7 +368,7 @@ void ReprojectHistoryColor(const AccumulationPassCommonParams params, FFXM_PARAM
LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat16x2 fReprojectedLockStatus) LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat16x2 fReprojectedLockStatus)
{ {
LockState state = { FFXM_FALSE, FFXM_FALSE }; LockState state = { FFXM_FALSE, FFXM_FALSE };
const FfxFloat16 fNewLockIntensity = FfxFloat16(LoadRwNewLocks(params.iPxHrPos));
const FfxFloat16 fNewLockIntensity = FfxFloat16(LoadNewLocks(params.iPxHrPos));
state.NewLock = fNewLockIntensity > (127.0f / 255.0f); state.NewLock = fNewLockIntensity > (127.0f / 255.0f);
FfxFloat16 fInPlaceLockLifetime = state.NewLock ? fNewLockIntensity : FfxFloat16(0); FfxFloat16 fInPlaceLockLifetime = state.NewLock ? fNewLockIntensity : FfxFloat16(0);

Loading…
Cancel
Save