Vita: Add bilinear filtering option (closes #344)

This commit is contained in:
Vicki Pfau 2022-02-20 04:26:16 -08:00
parent f72e55c3f6
commit 5f3cb2f72f
3 changed files with 34 additions and 16 deletions

View File

@ -60,6 +60,7 @@ Misc:
- Qt: Enable -b for Boot BIOS menu option (fixes mgba.io/i/2074) - Qt: Enable -b for Boot BIOS menu option (fixes mgba.io/i/2074)
- Qt: Add tile range selection to tile viewer (closes mgba.io/i/2455) - Qt: Add tile range selection to tile viewer (closes mgba.io/i/2455)
- Windows: Attach to console if present - Windows: Attach to console if present
- Vita: Add bilinear filtering option (closes mgba.io/i/344)
0.9.3: (2021-12-17) 0.9.3: (2021-12-17)
Emulation fixes: Emulation fixes:

View File

@ -171,6 +171,17 @@ int main() {
}, },
.nStates = 4 .nStates = 4
}, },
{
.title = "Screen filtering",
.data = GUI_V_S("filtering"),
.submenu = 0,
.state = 0,
.validStates = (const char*[]) {
"None",
"Bilinear",
},
.nStates = 2
},
{ {
.title = "Camera", .title = "Camera",
.data = GUI_V_S("camera"), .data = GUI_V_S("camera"),

View File

@ -56,6 +56,7 @@ static vita2d_texture* screenshot;
static Thread audioThread; static Thread audioThread;
static bool interframeBlending = false; static bool interframeBlending = false;
static bool sgbCrop = false; static bool sgbCrop = false;
static bool blurry = false;
static struct mSceRotationSource { static struct mSceRotationSource {
struct mRotationSource d; struct mRotationSource d;
@ -368,10 +369,8 @@ void mPSP2Setup(struct mGUIRunner* runner) {
if (mCoreConfigGetUIntValue(&runner->config, "camera", &mode)) { if (mCoreConfigGetUIntValue(&runner->config, "camera", &mode)) {
camera.cam = mode; camera.cam = mode;
} }
int fakeBool; mCoreConfigGetBoolValue(&runner->config, "sgb.borderCrop", &sgbCrop);
if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) { mCoreConfigGetBoolValue(&runner->config, "filtering", &blurry);
sgbCrop = fakeBool;
}
} }
void mPSP2LoadROM(struct mGUIRunner* runner) { void mPSP2LoadROM(struct mGUIRunner* runner) {
@ -400,10 +399,7 @@ void mPSP2LoadROM(struct mGUIRunner* runner) {
break; break;
} }
int fakeBool; mCoreConfigGetBoolValue(&runner->config, "interframeBlending", &interframeBlending);
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) {
interframeBlending = fakeBool;
}
// Backcompat: Old versions of mGBA use an older binding system that has different mappings for L/R // Backcompat: Old versions of mGBA use an older binding system that has different mappings for L/R
if (!sceKernelIsPSVitaTV()) { if (!sceKernelIsPSVitaTV()) {
@ -479,14 +475,9 @@ void mPSP2Unpaused(struct mGUIRunner* runner) {
} }
} }
int fakeBool; mCoreConfigGetBoolValue(&runner->config, "interframeBlending", &interframeBlending);
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) { mCoreConfigGetBoolValue(&runner->config, "sgb.borderCrop", &sgbCrop);
interframeBlending = fakeBool; mCoreConfigGetBoolValue(&runner->config, "filtering", &blurry);
}
if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) {
sgbCrop = fakeBool;
}
} }
void mPSP2Teardown(struct mGUIRunner* runner) { void mPSP2Teardown(struct mGUIRunner* runner) {
@ -577,6 +568,21 @@ void _drawTex(vita2d_texture* t, unsigned width, unsigned height, bool faded, bo
scaley = 544.0f / height; scaley = 544.0f / height;
break; break;
} }
vita2d_texture_set_filters(t, SCE_GXM_TEXTURE_FILTER_LINEAR,
blurry ? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT);
if (blurry) {
// Needed to avoid bleed from off-screen portion of texture
unsigned i;
uint32_t* texpixels = vita2d_texture_get_datap(t);
if (width < 256) {
for (i = 0; i < height; ++i) {
texpixels[i * 256 + width] = texpixels[i * 256 + width - 1];
}
}
if (height < vita2d_texture_get_height(t)) {
memcpy(&texpixels[height * 256], &texpixels[(height - 1) * 256], 1024);
}
}
vita2d_draw_texture_tint_part_scale(t, vita2d_draw_texture_tint_part_scale(t,
(960.0f - w) / 2.0f, (544.0f - h) / 2.0f, (960.0f - w) / 2.0f, (544.0f - h) / 2.0f,
0, 0, width, height, 0, 0, width, height,