Fix issues with savestates and non-buffered rendering

This commit is contained in:
Henrik Rydgård 2024-10-17 21:09:04 +02:00
parent 858f37b8fc
commit b43abd2015
4 changed files with 17 additions and 8 deletions

View File

@ -913,25 +913,26 @@ namespace SaveState
return Status::SUCCESS;
}
void Process()
{
// NOTE: This can cause ending of the current renderpass, due to the readback needed for the screenshot.
bool Process() {
rewindStates.Process();
if (!needsProcess)
return;
return false;
needsProcess = false;
if (!__KernelIsRunning())
{
ERROR_LOG(Log::SaveState, "Savestate failure: Unable to load without kernel, this should never happen.");
return;
return false;
}
std::vector<Operation> operations = Flush();
SaveStart state;
for (size_t i = 0, n = operations.size(); i < n; ++i)
{
bool readbackImage = false;
for (size_t i = 0, n = operations.size(); i < n; ++i) {
Operation &op = operations[i];
CChunkFileReader::Error result;
Status callbackResult;
@ -1068,6 +1069,7 @@ namespace SaveState
} else {
screenshotFailures = 0;
}
readbackImage = true;
break;
}
default:
@ -1083,6 +1085,8 @@ namespace SaveState
// Avoid triggering frame skipping due to slowdown
__DisplaySetWasPaused();
}
return readbackImage;
}
void NotifySaveData() {

View File

@ -104,7 +104,7 @@ namespace SaveState
bool IsOldVersion();
// Check if there's any save stating needing to be done. Normally called once per frame.
void Process();
bool Process();
// Notify save state code that new save data has been written.
void NotifySaveData();

View File

@ -623,7 +623,6 @@ void PSP_RunLoopWhileState() {
}
void PSP_RunLoopUntil(u64 globalticks) {
SaveState::Process();
if (coreState == CORE_POWERDOWN || coreState == CORE_BOOT_ERROR || coreState == CORE_RUNTIME_ERROR) {
return;
} else if (coreState == CORE_STEPPING) {

View File

@ -1445,6 +1445,12 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
uint32_t clearColor = 0;
if (!blockedExecution) {
PSP_BeginHostFrame();
if (SaveState::Process()) {
// We might have lost the framebuffer bind if we had one, due to a readback.
if (framebufferBound) {
draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, clearColor }, "EmuScreen_SavestateRebind");
}
}
PSP_RunLoopWhileState();
flags |= ScreenRenderFlags::HANDLED_THROTTLING;