From b014f056ed7fd73c38442795a37da232c5b02837 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Sat, 14 Dec 2024 20:25:35 +0100 Subject: [PATCH] Use a constant to determine the highest mip level that SPD can use on OpenGL Core, and ensure storing the pyramid values use the correct mip level --- .../fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h | 10 ++++++++-- .../ffx_fsr3upscaler_shading_change_pyramid.h | 12 +++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h index e8a8c49..c545579 100644 --- a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h +++ b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h @@ -47,6 +47,12 @@ FFX_STATIC const FfxInt32 LOG_LUMA = 0; FFX_STATIC const FfxInt32 LUMA = 1; FFX_STATIC const FfxInt32 DEPTH_IN_METERS = 2; +#ifdef SHADER_API_GLCORE +FFX_STATIC const FfxInt32 MAX_MIP = 4; +#else +FFX_STATIC const FfxInt32 MAX_MIP = 5; +#endif + FfxFloat32x4 SpdLoadSourceImage(FfxFloat32x2 iPxPos, FfxUInt32 slice) { //We assume linear data. if non-linear input (sRGB, ...), @@ -67,7 +73,7 @@ FfxFloat32x4 SpdLoadSourceImage(FfxFloat32x2 iPxPos, FfxUInt32 slice) FfxFloat32x4 SpdLoad(FfxInt32x2 tex, FfxUInt32 slice) { - return FfxFloat32x4(RWLoadPyramid(tex, 5), 0, 0); + return FfxFloat32x4(RWLoadPyramid(tex, MAX_MIP), 0, 0); } FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3) @@ -77,7 +83,7 @@ FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFl void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 slice) { - if (index == 5) + if (index == MAX_MIP) { StorePyramid(pix, outValue.xy, index); } diff --git a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h index 64eba40..f09e991 100644 --- a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h +++ b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_shading_change_pyramid.h @@ -47,6 +47,12 @@ FFX_STATIC const FfxInt32 DIFFERENCE = 0; FFX_STATIC const FfxInt32 SIGN_SUM = 1; FFX_STATIC const FfxInt32 MIP0_INDICATOR = 2; +#ifdef SHADER_API_GLCORE +FFX_STATIC const FfxInt32 MAX_MIP = 4; +#else +FFX_STATIC const FfxInt32 MAX_MIP = 5; +#endif + FfxFloat32x2 Sort2(FfxFloat32x2 v) { return FfxFloat32x2(ffxMin(v.x, v.y), ffxMax(v.x, v.y)); @@ -200,11 +206,7 @@ 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 + return FfxFloat32x4(RWLoadPyramid(tex, MAX_MIP), 0, 0); } FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3)