From b974fa5718444f8a7347e3ee880d66ce5939ba8e Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 30 Sep 2016 13:29:27 -0400 Subject: [PATCH] Add a libretro environment for serialization quirks The new environment RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS allows cores to communicate any quirks their implementation of serialization may exhibit. This is useful for distinguishing between serialization implementations that are sufficient for netplay, rewind, regular use, etc, as each of these have different requirements and it should be possible to support a "good enough" serialization without breaking frontend features. --- core.h | 2 ++ core_impl.c | 7 +++++++ libretro-common/include/libretro.h | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/core.h b/core.h index 0b80d39737..c760727b7a 100644 --- a/core.h +++ b/core.h @@ -178,6 +178,8 @@ bool core_set_environment(retro_ctx_environ_info_t *info); bool core_serialize_size(retro_ctx_size_info_t *info); +uint32_t core_serialize_quirks(void); + bool core_serialize(retro_ctx_serialize_info_t *info); bool core_unserialize(retro_ctx_serialize_info_t *info); diff --git a/core_impl.c b/core_impl.c index 683a821c57..3bae3c6bee 100644 --- a/core_impl.c +++ b/core_impl.c @@ -291,6 +291,13 @@ bool core_unserialize(retro_ctx_serialize_info_t *info) return true; } +uint32_t core_serialize_quirks(void) +{ + uint32_t ret = 0; + rarch_environment_cb(RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS, &ret); + return ret; +} + bool core_serialize(retro_ctx_serialize_info_t *info) { if (!info) diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index a4df6be470..2ba7c6a50f 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -976,6 +976,31 @@ struct retro_hw_render_context_negotiation_interface * so it will be used after SET_HW_RENDER, but before the context_reset callback. */ +#define RETRO_SERIALIZATION_QUIRK_INCOMPLETE (1 << 0) + /* Serialized state is incomplete in some way. Set if serialization is + * usable in typical end-user cases but should not be relied upon to + * implement frame-sensitive frontend features such as netplay or + * rerecording. */ +#define RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE (1 << 1) + /* The core must spend some time initializing before serialization is + * safe. */ +#define RETRO_SERIALIZATION_QUIRK_INITIALIZING (1 << 2) + /* If MUST_INITIALIZE is set, this should also be set if initialization is + * in progress. */ +#define RETRO_SERIALIZATION_QUIRK_VARIABLE_SIZE (1 << 3) + /* Serialization size may change within a session. */ +#define RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION (1 << 4) + /* Serialized state can only be loaded during the same session. */ +#define RETRO_SERIALIZATION_QUIRK_ARCHITECTURE_DEPENDENT (1 << 5) + /* Serialized state cannot be loaded on a different architecture from the + * one it was saved on. */ + +#define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44 + /* uint32_t * -- + * Sets quirk flags associated with serialization. + */ + + #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */ #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */ #define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */