diff --git a/CHANGES b/CHANGES index 9585b5a8d..ce8aa3625 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,7 @@ Other fixes: - Qt: Fix LCDC background priority/enable bit being mis-mapped in I/O view - Updater: Fix updating appimage across filesystems Misc: + - Switch: Add bilinear filtering option (closes mgba.io/i/3111) - Vita: Add imc0 and xmc0 mount point support 0.10.3: (2024-01-07) diff --git a/src/platform/switch/main.c b/src/platform/switch/main.c index 1d9c3cfe6..9f5e39602 100644 --- a/src/platform/switch/main.c +++ b/src/platform/switch/main.c @@ -124,6 +124,12 @@ static enum ScreenMode { SM_MAX } screenMode = SM_PA; +static enum FilterMode { + FM_NEAREST, + FM_LINEAR, + FM_MAX +} filterMode = FM_NEAREST; + static bool eglInit() { s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (!s_display) { @@ -313,6 +319,9 @@ static void _setup(struct mGUIRunner* runner) { if (mCoreConfigGetUIntValue(&runner->config, "screenMode", &mode) && mode < SM_MAX) { screenMode = mode; } + if (mCoreConfigGetUIntValue(&runner->config, "filterMode", &mode) && mode < FM_MAX) { + filterMode = mode; + } runner->core->setAudioBufferSize(runner->core, SAMPLES); } @@ -330,6 +339,9 @@ static void _gameLoaded(struct mGUIRunner* runner) { if (mCoreConfigGetUIntValue(&runner->config, "screenMode", &mode) && mode < SM_MAX) { screenMode = mode; } + if (mCoreConfigGetUIntValue(&runner->config, "filterMode", &mode) && mode < FM_MAX) { + filterMode = mode; + } int fakeBool; if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) { @@ -382,6 +394,8 @@ static void _drawTex(struct mGUIRunner* runner, unsigned width, unsigned height, glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterMode == FM_LINEAR ? GL_LINEAR : GL_NEAREST); + glUseProgram(program); glBindVertexArray(vao); float inwidth = width; @@ -702,14 +716,12 @@ static void glInit(void) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glGenTextures(1, &oldTex); glBindTexture(GL_TEXTURE_2D, oldTex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glGenBuffers(1, &pbo); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo); @@ -964,6 +976,17 @@ int main(int argc, char* argv[]) { }, .nStates = 16 }, + { + .title = "Filtering", + .data = GUI_V_S("filterMode"), + .submenu = 0, + .state = FM_NEAREST, + .validStates = (const char*[]) { + "None", + "Bilinear", + }, + .nStates = 2 + }, { .title = "GPU-accelerated renderer", .data = GUI_V_S("hwaccelVideo"),