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: Add tile range selection to tile viewer (closes mgba.io/i/2455)
- Windows: Attach to console if present
- Vita: Add bilinear filtering option (closes mgba.io/i/344)
0.9.3: (2021-12-17)
Emulation fixes:

View File

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

View File

@ -56,6 +56,7 @@ static vita2d_texture* screenshot;
static Thread audioThread;
static bool interframeBlending = false;
static bool sgbCrop = false;
static bool blurry = false;
static struct mSceRotationSource {
struct mRotationSource d;
@ -368,10 +369,8 @@ void mPSP2Setup(struct mGUIRunner* runner) {
if (mCoreConfigGetUIntValue(&runner->config, "camera", &mode)) {
camera.cam = mode;
}
int fakeBool;
if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) {
sgbCrop = fakeBool;
}
mCoreConfigGetBoolValue(&runner->config, "sgb.borderCrop", &sgbCrop);
mCoreConfigGetBoolValue(&runner->config, "filtering", &blurry);
}
void mPSP2LoadROM(struct mGUIRunner* runner) {
@ -400,10 +399,7 @@ void mPSP2LoadROM(struct mGUIRunner* runner) {
break;
}
int fakeBool;
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) {
interframeBlending = fakeBool;
}
mCoreConfigGetBoolValue(&runner->config, "interframeBlending", &interframeBlending);
// Backcompat: Old versions of mGBA use an older binding system that has different mappings for L/R
if (!sceKernelIsPSVitaTV()) {
@ -479,14 +475,9 @@ void mPSP2Unpaused(struct mGUIRunner* runner) {
}
}
int fakeBool;
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) {
interframeBlending = fakeBool;
}
if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) {
sgbCrop = fakeBool;
}
mCoreConfigGetBoolValue(&runner->config, "interframeBlending", &interframeBlending);
mCoreConfigGetBoolValue(&runner->config, "sgb.borderCrop", &sgbCrop);
mCoreConfigGetBoolValue(&runner->config, "filtering", &blurry);
}
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;
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,
(960.0f - w) / 2.0f, (544.0f - h) / 2.0f,
0, 0, width, height,