From 62070f11d5c8b9c55c53479c7e133d06ca676323 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 15 Jul 2025 15:26:08 -0700 Subject: [PATCH] =?UTF-8?q?GBA=20Video:=20Disable=20window=20interpolation?= =?UTF-8?q?=20at=201=C3=97=20scale=20(fixes=20#1810)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES | 1 + include/mgba/internal/gba/renderers/gl.h | 1 + src/gba/renderers/gl.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 9121261b7..5b093035b 100644 --- a/CHANGES +++ b/CHANGES @@ -59,6 +59,7 @@ Misc: - GBA Memory: Improve VRAM access stall cycle estimation - GBA SIO: Rewrite lockstep driver for improved stability - GBA Video: Add special circlular window handling in OpenGL renderer + - GBA Video: Disable window interpolation at 1× scale (fixes mgba.io/i/1810) - Libretro: Add Super Game Boy Color support (closes mgba.io/i/3188) - mGUI: Enable auto-softpatching (closes mgba.io/i/2899) - mGUI: Persist fast forwarding after closing menu (fixes mgba.io/i/2414) diff --git a/include/mgba/internal/gba/renderers/gl.h b/include/mgba/internal/gba/renderers/gl.h index 74baec41e..679df15b9 100644 --- a/include/mgba/internal/gba/renderers/gl.h +++ b/include/mgba/internal/gba/renderers/gl.h @@ -120,6 +120,7 @@ enum { GBA_GL_WIN_WIN1, GBA_GL_WIN_CIRCLE0, GBA_GL_WIN_CIRCLE1, + GBA_GL_WIN_DISABLE_INTERP, GBA_GL_FINALIZE_SCALE = 2, GBA_GL_FINALIZE_LAYERS, diff --git a/src/gba/renderers/gl.c b/src/gba/renderers/gl.c index dbff67e4e..405c97f79 100644 --- a/src/gba/renderers/gl.c +++ b/src/gba/renderers/gl.c @@ -493,6 +493,7 @@ static const struct GBAVideoGLUniform _uniformsWindow[] = { { "win1", GBA_GL_WIN_WIN1, }, { "circle0", GBA_GL_WIN_CIRCLE0, }, { "circle1", GBA_GL_WIN_CIRCLE1, }, + { "disableInterp", GBA_GL_WIN_DISABLE_INTERP, }, { 0 } }; @@ -505,6 +506,7 @@ static const char* const _renderWindow = "uniform ivec4 win1[160];\n" "uniform vec3 circle0;\n" "uniform vec3 circle1;\n" + "uniform bool disableInterp;\n" "OUT(0) out ivec4 window;\n" "bool crop(vec4 windowParams) {\n" @@ -532,7 +534,7 @@ static const char* const _renderWindow = "}\n" "vec4 interpolate(vec4 top, vec4 bottom) {\n" - " if (distance(top, bottom) > 40.) {\n" + " if (disableInterp || distance(top, bottom) > 40.) {\n" " return top;\n" " }\n" " return vec4(mix(bottom.xy, top.xy, fract(texCoord.y)), top.zw);\n" @@ -2111,6 +2113,7 @@ void GBAVideoGLRendererDrawWindow(struct GBAVideoGLRenderer* renderer, int y) { glUniform3i(uniforms[GBA_GL_WIN_FLAGS], renderer->winN[0].control, renderer->winN[1].control, renderer->winout); glUniform4iv(uniforms[GBA_GL_WIN_WIN0], GBA_VIDEO_VERTICAL_PIXELS, renderer->winNHistory[0]); glUniform4iv(uniforms[GBA_GL_WIN_WIN1], GBA_VIDEO_VERTICAL_PIXELS, renderer->winNHistory[1]); + glUniform1i(uniforms[GBA_GL_WIN_DISABLE_INTERP], renderer->scale < 2); _detectCircle(renderer, y, 0); _detectCircle(renderer, y, 1); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);