From f78154d2820fe824fe119589256bd6a2fc94f6ed Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 11 Aug 2021 06:31:01 +1000 Subject: [PATCH] [client] egl: fixes to shader post-process pipeline --- client/renderers/EGL/desktop.c | 12 +++++++----- client/renderers/EGL/shader/ffx_fsr1_rcas.frag | 4 ++-- client/renderers/EGL/texture.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/client/renderers/EGL/desktop.c b/client/renderers/EGL/desktop.c index 4f2cfcac..4a3a9028 100644 --- a/client/renderers/EGL/desktop.c +++ b/client/renderers/EGL/desktop.c @@ -338,7 +338,7 @@ void egl_desktopConfigUI(EGL_Desktop * desktop) egl_textureEnableFilter(desktop->ffxFSR1Handle[1], fsr1 && desktop->upscale); } - desktop->ffxFSR1Uniform.f[0] = fsr1Sharpness; + desktop->ffxFSR1Uniform.f[0] = 2.0f - fsr1Sharpness * 2.0f; egl_shaderSetUniforms(desktop->ffxFSR1[1], &desktop->ffxFSR1Uniform, 1); invalidateTex = true; } @@ -492,6 +492,12 @@ bool egl_desktopRender(EGL_Desktop * desktop, const float x, const float y, int scaleAlgo = EGL_SCALE_NEAREST; + struct Rect finalSize; + egl_textureBind(desktop->texture); + egl_textureGetFinalSize(desktop->texture, &finalSize); + if (finalSize.x > desktop->width || finalSize.y > desktop->height) + scaleType = EGL_DESKTOP_DOWNSCALE; + switch (desktop->scaleAlgo) { case EGL_SCALE_AUTO: @@ -512,10 +518,6 @@ bool egl_desktopRender(EGL_Desktop * desktop, const float x, const float y, scaleAlgo = desktop->scaleAlgo; } - struct Rect finalSize; - egl_textureBind(desktop->texture); - egl_textureGetFinalSize(desktop->texture, &finalSize); - egl_desktopRectsMatrix((float *)desktop->matrix->data, desktop->width, desktop->height, x, y, scaleX, scaleY, rotate); egl_desktopRectsUpdate(desktop->mesh, rects, desktop->width, desktop->height); diff --git a/client/renderers/EGL/shader/ffx_fsr1_rcas.frag b/client/renderers/EGL/shader/ffx_fsr1_rcas.frag index 1efed7a8..31c9d911 100644 --- a/client/renderers/EGL/shader/ffx_fsr1_rcas.frag +++ b/client/renderers/EGL/shader/ffx_fsr1_rcas.frag @@ -26,10 +26,10 @@ void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {} void main() { vec2 inRes = vec2(uInRes[0]); - uvec2 point = uvec2(iFragCoord * inRes); + uvec2 point = uvec2(iFragCoord * (inRes + 0.5f)); uvec4 const0; - FsrRcasCon(const0, 1.0f - uSharpness); + FsrRcasCon(const0, uSharpness); FsrRcasF(fragColor.r, fragColor.g, fragColor.b, point, const0); fragColor.a = 1.0f; diff --git a/client/renderers/EGL/texture.c b/client/renderers/EGL/texture.c index d949d69f..ae141abf 100644 --- a/client/renderers/EGL/texture.c +++ b/client/renderers/EGL/texture.c @@ -265,7 +265,7 @@ static bool rbBindTexture(int index, void * value, void * udata) glActiveTexture(GL_TEXTURE0 + index); glBindTexture(GL_TEXTURE_2D, bi->tex); - glBindSampler(0, bd->sampler); + glBindSampler(index, bd->sampler); bd->dimensions[index * 2 + 0] = bi->width; bd->dimensions[index * 2 + 1] = bi->height; return true;