Skip to content

Commit

Permalink
Merge pull request #14034 from unknownbrackets/ge-pause
Browse files Browse the repository at this point in the history
Ge: Restore saved context when ending a list
  • Loading branch information
hrydgard authored Jan 31, 2021
2 parents 8205f9b + f2ad475 commit 95a14be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
7 changes: 3 additions & 4 deletions Core/HLE/sceGe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,11 @@ static int sceGeGetMtx(int type, u32 matrixPtr) {
}

static u32 sceGeGetCmd(int cmd) {
INFO_LOG(SCEGE, "sceGeGetCmd(%i)", cmd);
if (cmd >= 0 && cmd < (int)ARRAY_SIZE(gstate.cmdmem)) {
return gstate.cmdmem[cmd]; // Does not mask away the high bits.
} else {
return SCE_KERNEL_ERROR_INVALID_INDEX;
// Does not mask away the high bits.
return hleLogSuccessInfoX(SCEGE, gstate.cmdmem[cmd]);
}
return hleLogError(SCEGE, SCE_KERNEL_ERROR_INVALID_INDEX);
}

static int sceGeGetStack(int index, u32 stackPtr) {
Expand Down
8 changes: 6 additions & 2 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "Core/ConfigValues.h"
#include "Core/Core.h"
#include "Core/CoreParameter.h"
#include "Core/Debugger/Breakpoints.h"
#include "Core/Host.h"
#include "Core/MIPS/MIPS.h"
#include "Core/Reporting.h"
#include "GPU/Common/DrawEngineCommon.h"
#include "GPU/Common/FramebufferManagerCommon.h"
Expand Down Expand Up @@ -2146,9 +2148,10 @@ void FramebufferManagerCommon::PackFramebufferSync_(VirtualFramebuffer *vfb, int
const int dstBpp = (int)DataFormatSizeInBytes(destFormat);

const int dstByteOffset = (y * vfb->fb_stride + x) * dstBpp;
const int dstSize = (h * vfb->fb_stride + w - 1) * dstBpp;

if (!Memory::IsValidRange(fb_address + dstByteOffset, ((h - 1) * vfb->fb_stride + w) * dstBpp)) {
ERROR_LOG(G3D, "PackFramebufferSync_ would write outside of memory, ignoring");
if (!Memory::IsValidRange(fb_address + dstByteOffset, dstSize)) {
ERROR_LOG_REPORT(G3D, "PackFramebufferSync_ would write outside of memory, ignoring");
return;
}

Expand All @@ -2160,6 +2163,7 @@ void FramebufferManagerCommon::PackFramebufferSync_(VirtualFramebuffer *vfb, int

if (destPtr) {
draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "PackFramebufferSync_");
CBreakPoints::ExecMemCheck(fb_address + dstByteOffset, true, dstSize, currentMIPS->pc);
} else {
ERROR_LOG(G3D, "PackFramebufferSync_: Tried to readback to bad address %08x (stride = %d)", fb_address + dstByteOffset, vfb->fb_stride);
}
Expand Down
12 changes: 8 additions & 4 deletions GPU/GPUCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,17 +1480,21 @@ void GPUCommon::Execute_End(u32 op, u32 diff) {
default:
currentList->subIntrToken = prev & 0xFFFF;
UpdateState(GPUSTATE_DONE);
// Since we marked done, we have to restore the context now before the next list runs.
if (currentList->started && currentList->context.IsValid()) {
gstate.Restore(currentList->context);
ReapplyGfxState();
// Don't restore the context again.
currentList->started = false;
}

if (currentList->interruptsEnabled && __GeTriggerInterrupt(currentList->id, currentList->pc, startingTicks + cyclesExecuted)) {
currentList->pendingInterrupt = true;
} else {
currentList->state = PSP_GE_DL_STATE_COMPLETED;
currentList->waitTicks = startingTicks + cyclesExecuted;
busyTicks = std::max(busyTicks, currentList->waitTicks);
__GeTriggerSync(GPU_SYNC_LIST, currentList->id, currentList->waitTicks);
if (currentList->started && currentList->context.IsValid()) {
gstate.Restore(currentList->context);
ReapplyGfxState();
}
}
break;
}
Expand Down

0 comments on commit 95a14be

Please sign in to comment.