mirror of https://github.com/mgba-emu/mgba.git
Vita: Avoid uncached memcpy
This commit is contained in:
parent
f44846cb9a
commit
97e2cf08ab
|
@ -152,7 +152,7 @@ int main() {
|
||||||
.teardown = mPSP2Teardown,
|
.teardown = mPSP2Teardown,
|
||||||
.gameLoaded = mPSP2LoadROM,
|
.gameLoaded = mPSP2LoadROM,
|
||||||
.gameUnloaded = mPSP2UnloadROM,
|
.gameUnloaded = mPSP2UnloadROM,
|
||||||
.prepareForFrame = NULL,
|
.prepareForFrame = mPSP2Swap,
|
||||||
.drawFrame = mPSP2Draw,
|
.drawFrame = mPSP2Draw,
|
||||||
.drawScreenshot = mPSP2DrawScreenshot,
|
.drawScreenshot = mPSP2DrawScreenshot,
|
||||||
.paused = mPSP2Paused,
|
.paused = mPSP2Paused,
|
||||||
|
|
|
@ -51,8 +51,8 @@ static enum ScreenMode {
|
||||||
} screenMode;
|
} screenMode;
|
||||||
|
|
||||||
static void* outputBuffer;
|
static void* outputBuffer;
|
||||||
static vita2d_texture* tex;
|
static int currentTex;
|
||||||
static vita2d_texture* oldTex;
|
static vita2d_texture* tex[4];
|
||||||
static vita2d_texture* screenshot;
|
static vita2d_texture* screenshot;
|
||||||
static Thread audioThread;
|
static Thread audioThread;
|
||||||
static bool interframeBlending = false;
|
static bool interframeBlending = false;
|
||||||
|
@ -324,12 +324,14 @@ void mPSP2Setup(struct mGUIRunner* runner) {
|
||||||
|
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
runner->core->desiredVideoDimensions(runner->core, &width, &height);
|
runner->core->desiredVideoDimensions(runner->core, &width, &height);
|
||||||
tex = vita2d_create_empty_texture_format(256, toPow2(height), SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR);
|
tex[0] = 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);
|
tex[1] = vita2d_create_empty_texture_format(256, toPow2(height), SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR);
|
||||||
|
tex[2] = vita2d_create_empty_texture_format(256, toPow2(height), SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR);
|
||||||
|
tex[3] = vita2d_create_empty_texture_format(256, toPow2(height), SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR);
|
||||||
|
currentTex = 0;
|
||||||
screenshot = 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);
|
runner->core->setVideoBuffer(runner->core, vita2d_texture_get_datap(tex[currentTex]), 256);
|
||||||
runner->core->setVideoBuffer(runner->core, outputBuffer, 256);
|
|
||||||
runner->core->setAudioBufferSize(runner->core, PSP2_SAMPLES);
|
runner->core->setAudioBufferSize(runner->core, PSP2_SAMPLES);
|
||||||
|
|
||||||
rotation.d.sample = _sampleRotation;
|
rotation.d.sample = _sampleRotation;
|
||||||
|
@ -490,8 +492,10 @@ void mPSP2Unpaused(struct mGUIRunner* runner) {
|
||||||
void mPSP2Teardown(struct mGUIRunner* runner) {
|
void mPSP2Teardown(struct mGUIRunner* runner) {
|
||||||
UNUSED(runner);
|
UNUSED(runner);
|
||||||
CircleBufferDeinit(&rumble.history);
|
CircleBufferDeinit(&rumble.history);
|
||||||
vita2d_free_texture(tex);
|
vita2d_free_texture(tex[0]);
|
||||||
vita2d_free_texture(oldTex);
|
vita2d_free_texture(tex[1]);
|
||||||
|
vita2d_free_texture(tex[2]);
|
||||||
|
vita2d_free_texture(tex[3]);
|
||||||
vita2d_free_texture(screenshot);
|
vita2d_free_texture(screenshot);
|
||||||
mappedMemoryFree(outputBuffer, 256 * 256 * 4);
|
mappedMemoryFree(outputBuffer, 256 * 256 * 4);
|
||||||
frameLimiter = true;
|
frameLimiter = true;
|
||||||
|
@ -583,17 +587,18 @@ void _drawTex(vita2d_texture* t, unsigned width, unsigned height, bool faded, bo
|
||||||
tint);
|
tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mPSP2Swap(struct mGUIRunner* runner) {
|
||||||
|
currentTex = (currentTex + 1) & 3;
|
||||||
|
runner->core->setVideoBuffer(runner->core, vita2d_texture_get_datap(tex[currentTex]), 256);
|
||||||
|
}
|
||||||
|
|
||||||
void mPSP2Draw(struct mGUIRunner* runner, bool faded) {
|
void mPSP2Draw(struct mGUIRunner* runner, bool faded) {
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
runner->core->desiredVideoDimensions(runner->core, &width, &height);
|
runner->core->desiredVideoDimensions(runner->core, &width, &height);
|
||||||
void* texpixels = vita2d_texture_get_datap(tex);
|
|
||||||
if (interframeBlending) {
|
if (interframeBlending) {
|
||||||
void* oldTexpixels = vita2d_texture_get_datap(oldTex);
|
_drawTex(tex[(currentTex - 1) & 3], width, height, faded, false);
|
||||||
memcpy(oldTexpixels, texpixels, 256 * height * 4);
|
|
||||||
_drawTex(oldTex, width, height, faded, false);
|
|
||||||
}
|
}
|
||||||
memcpy(texpixels, outputBuffer, 256 * height * 4);
|
_drawTex(tex[currentTex], width, height, faded, interframeBlending);
|
||||||
_drawTex(tex, width, height, faded, interframeBlending);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded) {
|
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ void mPSP2UnloadROM(struct mGUIRunner* runner);
|
||||||
void mPSP2PrepareForFrame(struct mGUIRunner* runner);
|
void mPSP2PrepareForFrame(struct mGUIRunner* runner);
|
||||||
void mPSP2Paused(struct mGUIRunner* runner);
|
void mPSP2Paused(struct mGUIRunner* runner);
|
||||||
void mPSP2Unpaused(struct mGUIRunner* runner);
|
void mPSP2Unpaused(struct mGUIRunner* runner);
|
||||||
|
void mPSP2Swap(struct mGUIRunner* runner);
|
||||||
void mPSP2Draw(struct mGUIRunner* runner, bool faded);
|
void mPSP2Draw(struct mGUIRunner* runner, bool faded);
|
||||||
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const color_t* pixels, unsigned width, unsigned height, bool faded);
|
void mPSP2DrawScreenshot(struct mGUIRunner* runner, const color_t* pixels, unsigned width, unsigned height, bool faded);
|
||||||
void mPSP2IncrementScreenMode(struct mGUIRunner* runner);
|
void mPSP2IncrementScreenMode(struct mGUIRunner* runner);
|
||||||
|
|
Loading…
Reference in New Issue