Switch: Add bilinear filtering option (closes #3111)

This commit is contained in:
Vicki Pfau 2024-01-18 02:58:50 -08:00
parent 154fe6b344
commit a0f6255a0b
2 changed files with 26 additions and 2 deletions

View File

@ -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)

View File

@ -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"),