From f8f5f9077dd95ecd67150bd73708d309ad9bbd87 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Sat, 14 Dec 2024 18:52:29 +0100 Subject: [PATCH] Reduced number of SPD mip levels used by luma pyramid and shading change pyramid passes by one for OpenGL Core, to ensure they stay within the limit of 8 UAV bindings. --- .../shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl | 4 ++++ .../ffx_fsr3upscaler_shading_change_pyramid_pass.hlsl | 2 ++ .../fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h | 10 +++++++++- .../ffx_fsr3upscaler_shading_change_pyramid.h | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl b/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl index 37fa1b7..0d6b67d 100644 --- a/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl +++ b/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl @@ -30,8 +30,12 @@ #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_2 4 #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_3 5 #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_4 6 +#ifdef SHADER_API_GLCORE +#define FSR3UPSCALER_BIND_UAV_FARTHEST_DEPTH_MIP1 7 +#else #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_5 7 #define FSR3UPSCALER_BIND_UAV_FARTHEST_DEPTH_MIP1 8 +#endif #define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 diff --git a/Shaders/shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.hlsl b/Shaders/shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.hlsl index 5403792..fe85c3e 100644 --- a/Shaders/shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.hlsl +++ b/Shaders/shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.hlsl @@ -32,7 +32,9 @@ #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_2 3 #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_3 4 #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_4 5 +#ifndef SHADER_API_GLCORE #define FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_5 6 +#endif #define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 diff --git a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h index e6f661c..2b2811e 100644 --- a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h +++ b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h @@ -929,14 +929,18 @@ FfxFloat32x4 FrameInfo() defined(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_2) && \ defined(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_3) && \ defined(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_4) && \ - defined(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_5) + (defined(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_5) || defined(SHADER_API_GLCORE)) RWTexture2D rw_spd_mip0 : FFX_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_0); RWTexture2D rw_spd_mip1 : FFX_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_1); RWTexture2D rw_spd_mip2 : FFX_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_2); RWTexture2D rw_spd_mip3 : FFX_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_3); +#ifdef SHADER_API_GLCORE +globallycoherent RWTexture2D rw_spd_mip4 : FFX_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_4); +#else RWTexture2D rw_spd_mip4 : FFX_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_4); globallycoherent RWTexture2D rw_spd_mip5 : FFX_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_MIPS_LEVEL_5); +#endif FfxFloat32x2 RWLoadPyramid(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 index) { @@ -950,7 +954,9 @@ FfxFloat32x2 RWLoadPyramid(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN LOAD(2); LOAD(3); LOAD(4); +#ifndef SHADER_API_GLCORE LOAD(5); +#endif return 0; @@ -970,7 +976,9 @@ void StorePyramid(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat3 STORE(2); STORE(3); STORE(4); +#ifndef SHADER_API_GLCORE STORE(5); +#endif #undef STORE } diff --git a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h index 651c5b3..64eba40 100644 --- a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h +++ b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h @@ -200,7 +200,11 @@ FfxFloat32x4 SpdLoadSourceImage(FfxFloat32x2 iPxPos, FfxUInt32 slice) FfxFloat32x4 SpdLoad(FfxInt32x2 tex, FfxUInt32 slice) { +#ifdef SHADER_API_GLCORE + return FfxFloat32x4(RWLoadPyramid(tex, 4), 0, 0); +#else return FfxFloat32x4(RWLoadPyramid(tex, 5), 0, 0); +#endif } FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3)