Vita: Interframe blending
Vicki Pfau vi@endrift.com
Wed, 29 May 2019 13:50:59 -0700
1 files changed,
33 insertions(+),
5 deletions(-)
jump to
M
src/platform/psp2/psp2-context.c
→
src/platform/psp2/psp2-context.c
@@ -52,8 +52,10 @@ } screenMode;
static void* outputBuffer; static vita2d_texture* tex; +static vita2d_texture* oldTex; static vita2d_texture* screenshot; static Thread audioThread; +static bool interframeBlending = false; static struct mSceRotationSource { struct mRotationSource d;@@ -322,6 +324,7 @@
unsigned width, height; runner->core->desiredVideoDimensions(runner->core, &width, &height); tex = vita2d_create_empty_texture_format(256, toPow2(height), SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR); + oldTex = vita2d_create_empty_texture_format(256, toPow2(height), SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR); screenshot = vita2d_create_empty_texture_format(256, toPow2(height), SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR); outputBuffer = anonymousMemoryMap(256 * toPow2(height) * 4);@@ -389,6 +392,10 @@ #endif
default: break; } + + int fakeBool; + mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool); + interframeBlending = fakeBool; MutexInit(&audioContext.mutex); ConditionInit(&audioContext.cond);@@ -451,18 +458,23 @@ _resetCamera(&camera);
} } } + + int fakeBool; + mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool); + interframeBlending = fakeBool; } void mPSP2Teardown(struct mGUIRunner* runner) { UNUSED(runner); CircleBufferDeinit(&rumble.history); vita2d_free_texture(tex); + vita2d_free_texture(oldTex); vita2d_free_texture(screenshot); mappedMemoryFree(outputBuffer, 256 * 256 * 4); frameLimiter = true; } -void _drawTex(vita2d_texture* t, unsigned width, unsigned height, bool faded) { +void _drawTex(vita2d_texture* t, unsigned width, unsigned height, bool faded, bool interframe) { unsigned w = width; unsigned h = height; // Get greatest common divisor@@ -477,10 +489,21 @@ int aspecth = height / gcd;
float scalex; float scaley; + unsigned tint = 0x1FFFFFFF; + if (!faded) { + if (interframe) { + tint |= 0x60000000; + } else { + tint |= 0xE0000000; + } + } else if (!interframe) { + tint |= 0x20000000; + } + switch (screenMode) { case SM_BACKDROP: default: - vita2d_draw_texture_tint(backdrop, 0, 0, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); + vita2d_draw_texture_tint(backdrop, 0, 0, tint); // Fall through case SM_PLAIN: w = 960 / width;@@ -520,15 +543,20 @@ vita2d_draw_texture_tint_part_scale(t,
(960.0f - w) / 2.0f, (544.0f - h) / 2.0f, 0, 0, width, height, scalex, scaley, - (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); + tint); } void mPSP2Draw(struct mGUIRunner* runner, bool faded) { unsigned width, height; runner->core->desiredVideoDimensions(runner->core, &width, &height); void* texpixels = vita2d_texture_get_datap(tex); + if (interframeBlending) { + void* oldTexpixels = vita2d_texture_get_datap(oldTex); + memcpy(oldTexpixels, texpixels, 256 * height * 4); + _drawTex(oldTex, width, height, faded, false); + } memcpy(texpixels, outputBuffer, 256 * height * 4); - _drawTex(tex, width, height, faded); + _drawTex(tex, width, height, faded, interframeBlending); } void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded) {@@ -538,7 +566,7 @@ unsigned y;
for (y = 0; y < height; ++y) { memcpy(&texpixels[256 * y], &pixels[width * y], width * 4); } - _drawTex(screenshot, width, height, faded); + _drawTex(screenshot, width, height, faded, false); } void mPSP2IncrementScreenMode(struct mGUIRunner* runner) {