From c52a40f706f7498f38ca558a8abee2371b03c0ec Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 25 Mar 2025 12:07:08 +0100 Subject: [PATCH] Use implicit register binding when using UAVs in fragment shaders. Fixes remaining issues with reconstruct and accumulate passes on PS5 CGGC. Also disable writing to locks UAV at the end of Accumulate pass, as it doesn't actually do anything and it might cause issues with reading & writing to the same texture. --- .../ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h | 2 +- .../ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h index 1120019..73404b5 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h @@ -372,7 +372,7 @@ AccumulateOutputs Accumulate(FfxInt32x2 iPxHrPos) #if FFXM_FSR2_OPTION_APPLY_SHARPENING == 0 results.fColor = fHistoryColor; #endif - StoreNewLocks(iPxHrPos, 0); + //StoreNewLocks(iPxHrPos, 0); return results; } diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h index 1963bd8..77b235d 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h @@ -379,7 +379,7 @@ SamplerState s_LinearClamp : register(s1); // UAV declarations #if defined FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH - #if defined(SHADER_API_PSSL) + #if defined(SHADER_API_PSSL) && defined(SHADER_STAGE_FRAGMENT) RWTexture2D rw_reconstructed_previous_nearest_depth; // Need to use implicit register binding for random write targets on PS4/5 #else RWTexture2D rw_reconstructed_previous_nearest_depth : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH); @@ -401,7 +401,11 @@ SamplerState s_LinearClamp : register(s1); RWTexture2D rw_lock_input_luma : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LOCK_INPUT_LUMA); #endif #if defined FSR2_BIND_UAV_NEW_LOCKS + #if defined(SHADER_API_PSSL) && defined(SHADER_STAGE_FRAGMENT) + RWTexture2D rw_new_locks; // Need to use implicit register binding for random write targets on PS4/5 + #else RWTexture2D rw_new_locks : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_NEW_LOCKS); + #endif #endif #if defined FSR2_BIND_UAV_PREPARED_INPUT_COLOR RWTexture2D rw_prepared_input_color : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_PREPARED_INPUT_COLOR);