Skip to content

Commit

Permalink
Add skip_same_thread_save hack
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Aug 8, 2024
1 parent 466257d commit 7873631
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ emulator:
# Available:
# - skip_hw_context_destroy -- don't destroy OpenGL context during Libretro core deinit.
# May help with crashes, for example, with PPSSPP.
# - skip_same_thread_save -- skip thread lock save (used with PPSSPP).
list:
gba:
lib: mgba_libretro
Expand Down
5 changes: 4 additions & 1 deletion pkg/worker/caged/libretro/nanoarch/nanoarch.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Nanoarch struct {
Aspect bool
sdlCtx *graphics.SDL
hackSkipHwContextDestroy bool
hackSkipSameThreadSave bool
limiter func(func())
log *logger.Logger
}
Expand Down Expand Up @@ -170,6 +171,7 @@ func (n *Nanoarch) CoreLoad(meta Metadata) {

// hacks
Nan0.hackSkipHwContextDestroy = meta.HasHack("skip_hw_context_destroy")
Nan0.hackSkipSameThreadSave = meta.HasHack("skip_same_thread_save")

// reset controllers
n.retropad = InputState{}
Expand Down Expand Up @@ -478,7 +480,7 @@ const (
func SaveState() (State, error) {
data := make([]byte, uint(Nan0.serializeSize))
rez := false
if Nan0.LibCo {
if Nan0.LibCo && !Nan0.hackSkipSameThreadSave {
rez = *(*bool)(C.same_thread_with_args2(retroSerialize, C.int(CallSerialize), unsafe.Pointer(&data[0]), unsafe.Pointer(&Nan0.serializeSize)))
} else {
rez = bool(C.bridge_retro_serialize(retroSerialize, unsafe.Pointer(&data[0]), Nan0.serializeSize))
Expand Down Expand Up @@ -934,6 +936,7 @@ func deinitVideo() {
Nan0.Video.gl.enabled = false
Nan0.Video.gl.autoCtx = false
Nan0.hackSkipHwContextDestroy = false
Nan0.hackSkipSameThreadSave = false
thread.SwitchGraphics(false)
}

Expand Down

0 comments on commit 7873631

Please sign in to comment.