Skip to content

Commit 5b6c93a

Browse files
authored
Incremental statestream checkpoints for replays (#18213)
1 parent 7c30935 commit 5b6c93a

27 files changed

Lines changed: 2269 additions & 1053 deletions

.dir-locals.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
;;; See Info node `(emacs) Directory Variables' for more information.
33

44
(
5-
(c-mode . ((c-basic-offset . 3)
5+
(c-mode . ((standard-indent . 3)
6+
(c-basic-offset . 3)
67
(c-file-offsets . ((arglist-intro . ++)
7-
(arglist-cont-nonempty . ++)))
8+
(arglist-cont-nonempty . ++)
9+
(block-close . 0)
10+
(block-open . 0)))
811
(eval . (setq-local c-cleanup-list
912
(cl-set-difference c-cleanup-list
1013
'(brace-else-brace

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
- INPUT: Reset and close content hotkeys now require confirmation, similar to quit
3232
- INPUT/ANDROID: Favor mouse coordinates for lightgun
3333
- INPUT/UDEV: Fix lost terminal settings after restart from menu
34+
- INPUT/BSV/REPLAY: Bumped replay format version to 2. Old replays will still play back fine.
35+
- INPUT/BSV/REPLAY: Add option to skip deserializing checkpoints from replay files (it introduces jank in some emulators).
36+
- INPUT/BSV/REPLAY: Add checkpoint and initial savestate compression, following the `savestate_file_compression` config boolean. Use zstd if available, or fall back to zlib.
37+
- INPUT/BSV/REPLAY: Add incremental checkpoints based on statestreams (depending on `HAVE_STATESTREAM` compile time flag). As an example, 60 `pcsx_rearmed` savestates would take 267MB uncompressed; with incremental encoding this is reduced to 77MB. Compressing the result can reduce the size to just 4MB.
38+
- INPUT/BSV/REPLAY: Checkpoint compression and encoding can be combined. For example, 60 `pcsx_rearmed` checkpoints can take up just 15MB if each state is incremental and compressed. This is not as optimal as using incremental states without save state compression followed by offline compression, but is a good compromise in many use cases.
3439
- INTL: Add Irish Gaelic to selectable languages
3540
- IOS: Fix crash on iOS9 when fetching refresh rate
3641
- LINUX: Add full complement of key/value pairs to desktop entry

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
HAVE_FILE_LOGGER=1
2+
HAVE_STATESTREAM?=1
23
NEED_CXX_LINKER?=0
34
NEED_GOLD_LINKER?=0
45
MISSING_DECLS =0

Makefile.common

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ ifeq ($(HAVE_SAPI), 1)
2525
LIBS += sapi.dll
2626
endif
2727

28+
ifeq ($(HAVE_STATESTREAM), 1)
29+
DEF_FLAGS += -DHAVE_STATESTREAM
30+
endif
31+
2832
ifeq ($(HAVE_GL_CONTEXT),)
2933
HAVE_GL_CONTEXT = 0
3034
HAVE_GL_MODERN = 0
@@ -451,6 +455,8 @@ endif
451455

452456
ifeq ($(HAVE_BSV_MOVIE), 1)
453457
DEFINES += -DHAVE_BSV_MOVIE
458+
OBJ += input/bsv/bsvmovie.o \
459+
input/bsv/uint32s_index.o
454460
endif
455461

456462
ifeq ($(HAVE_RUNAHEAD), 1)

Makefile.emscripten

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ OBJ :=
1414
DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN -DEMSCRIPTEN
1515
DEFINES += -DHAVE_FILTERS_BUILTIN -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORE_INFO
1616

17+
HAVE_STATESTREAM ?= 1
1718
HAVE_PATCH = 1
1819
HAVE_DSP_FILTER = 1
1920
HAVE_VIDEO_FILTER = 1

config.def.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,11 @@
14071407
/* Specifies how often checkpoints will be saved to replay files during recording.
14081408
* > Setting value to zero disables recording checkpoints. */
14091409
#define DEFAULT_REPLAY_CHECKPOINT_INTERVAL 0
1410+
/* Specifies whether checkpoints in replay files should be loaded
1411+
* during playback. This can be helpful for cores that are not
1412+
* deterministic but in some cores produces janky results depending on
1413+
* when inputs are processed. */
1414+
#define DEFAULT_REPLAY_CHECKPOINT_DESERIALIZE true
14101415

14111416
/* Automatically saves a savestate at the end of RetroArch's lifetime.
14121417
* The path is $SRAM_PATH.auto.

configuration.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,6 +2247,9 @@ static struct config_bool_setting *populate_settings_bool(
22472247
SETTING_BOOL("network_remote_enable", &settings->bools.network_remote_enable, false, false /* TODO */, false);
22482248
#endif
22492249
#endif
2250+
#ifdef HAVE_BSV_MOVIE
2251+
SETTING_BOOL("replay_checkpoint_deserialize", &settings->bools.replay_checkpoint_deserialize, true, DEFAULT_REPLAY_CHECKPOINT_DESERIALIZE, false);
2252+
#endif
22502253

22512254
#ifdef ANDROID
22522255
SETTING_BOOL("android_input_disconnect_workaround", &settings->bools.android_input_disconnect_workaround, true, false, false);

configuration.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,10 @@ typedef struct settings
11081108
bool ai_service_pause;
11091109

11101110
bool gamemode_enable;
1111+
#ifdef HAVE_BSV_MOVIE
1112+
bool replay_checkpoint_deserialize;
1113+
#endif
1114+
11111115
#ifdef _3DS
11121116
bool new3ds_speedup_enable;
11131117
bool bottom_font_enable;

griffin/griffin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ INPUT
604604
============================================================ */
605605

606606
#include "../input/input_driver.c"
607+
#ifdef HAVE_BSV_MOVIE
608+
#include "../input/bsv/bsvmovie.c"
609+
#include "../input/bsv/uint32s_index.c"
610+
#endif
607611
#include "../input/input_keymaps.c"
608612
#include "../tasks/task_autodetect.c"
609613
#include "../input/input_autodetect_builtin.c"

0 commit comments

Comments
 (0)