Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Band-Aid for libretro Savestate load #11990

Merged
merged 1 commit into from
Apr 24, 2019
Merged

Band-Aid for libretro Savestate load #11990

merged 1 commit into from
Apr 24, 2019

Conversation

m4xw
Copy link
Contributor

@m4xw m4xw commented Apr 23, 2019

Proper would be using PPSSPP's Queue.
This will need frontend extensions to do it sanely.
Fixes #11429 (mitigate for now)

libretro/libretro.cpp Outdated Show resolved Hide resolved
Proper would be using PPSSPP's Queue.
This will need frontend extensions to do it sanely.
Fixes hrydgard#11429 (mitigate for now)
@unknownbrackets
Copy link
Collaborator

Hmm looking at this again, I'd suggest using Core_EnableStepping. That would work on all backends. Stepping is in other words debugging, and while debugging the CPU is paused regardless of thread behavior.

Example:

static serializeWasStepping = false;

size_t retro_serialize_size(void) {
	serializeWasStepping = Core_IsStepping();
	Core_EnableStepping(true);
	// If we're on the CPU thread actually, this may just stall for 16ms...
	Core_WaitInactive(16);

	// Intentionally leaving in stepping.
	// TODO: Not sure if 0x800000 alignment is necessary (that's 8MB.)
	return CChunkFileReader::MeasurePtr(state);
}

bool retro_serialize(void *data, size_t size) {
	if (Core_IsActive()) {
		ERROR_LOG(SYSTEM, "retro_serialize_size() must be called before retro_serialize()");
		return false;
	}
	if (size < CChunkFileReader::MeasurePtr(state)) {
		ERROR_LOG(SYSTEM, "retro_serialize() called with too small a size");
		return false;
	}

	bool retVal = CChunkFileReader::SavePtr(...);

	if (!serializeWasStepping) {
		Core_EnableStepping(false);
		// No need to wait for active, it'll resume on its own.
	}

	return retVal;
}

That said, probably doing this thread pausing stuff will work too, at least for GL. Would have to save the std::thread id or something and compare to know if Core_WaitInactive needs to be called, I suppose.

-[Unknown]

@hrydgard
Copy link
Owner

Merging as-is because the workaround apparently is highly in demand - @m4xw has promised to try and switch to EnableStepping later.

@hrydgard hrydgard merged commit d15a6cf into hrydgard:master Apr 24, 2019
@orbea
Copy link
Contributor

orbea commented Apr 24, 2019

@m4xw Thanks a lot for taking time to work on ppsspp issues!

@NeoNight1986
Copy link

I am pretty confused, what do I need to do to fix the safe state freezing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RetroArch crashes when loading PPSSPP savestates
5 participants