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

Savestates: Fixup #15446

Merged
merged 2 commits into from Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp
Expand Up @@ -77,6 +77,11 @@ struct avc2_settings
u8 video_stream_sharing = 0;
u32 total_video_bitrate = 0;

static bool saveable(bool is_writing) noexcept
{
return GET_SERIALIZATION_VERSION(cellSysutil) != 0;
}

avc2_settings(utils::serial& ar) noexcept
{
[[maybe_unused]] const s32 version = GET_SERIALIZATION_VERSION(cellSysutil);
Expand Down
11 changes: 11 additions & 0 deletions rpcs3/Emu/Cell/SPUCommonRecompiler.cpp
Expand Up @@ -802,6 +802,9 @@ void spu_cache::initialize(bool build_existing_cache)

compiler->init();

// Counter for error reporting
u32 logged_error = 0;

// How much every thread compiled
uint result = 0;

Expand Down Expand Up @@ -861,6 +864,14 @@ void spu_cache::initialize(bool build_existing_cache)
if (func2 != func)
{
spu_log.error("[0x%05x] SPU Analyser failed, %u vs %u", func2.entry_point, func2.data.size(), size0);

if (logged_error < 2)
{
std::string log;
compiler->dump(func, log);
spu_log.notice("[0x%05x] Function: %s", func.entry_point, log);
logged_error++;
}
}
else if (!compiler->compile(std::move(func2)))
{
Expand Down
18 changes: 16 additions & 2 deletions rpcs3/util/fixed_typemap.hpp
Expand Up @@ -73,6 +73,7 @@ namespace stx
bool(*create)(uchar* ptr, manual_typemap&, utils::serial*, std::string_view) noexcept = nullptr;
void(*thread_op)(void* ptr, thread_state) noexcept = nullptr;
void(*save)(void* ptr, utils::serial&) noexcept = nullptr;
bool(*saveable)(bool) noexcept = nullptr;
void(*destroy)(void* ptr) noexcept = nullptr;
bool is_trivial_and_nonsavable = false;
std::string_view name;
Expand Down Expand Up @@ -148,6 +149,12 @@ namespace stx
std::launder(static_cast<T*>(ptr))->save(stx::exact_t<utils::serial&>(ar));
}

template <typename T> requires requires (const T&) { T::saveable(true); }
static bool call_saveable(bool is_writing) noexcept
{
return T::saveable(is_writing);
}

template <typename T>
static typeinfo make_typeinfo()
{
Expand All @@ -167,6 +174,11 @@ namespace stx
r.save = &call_save<T>;
}

if constexpr (!!(requires (const T&) { T::saveable(true); }))
{
r.saveable = &call_saveable<T>;
}

r.is_trivial_and_nonsavable = std::is_trivially_default_constructible_v<T> && !r.save;

#ifdef _MSC_VER
Expand Down Expand Up @@ -284,13 +296,15 @@ namespace stx
continue;
}

if (type.create(data, *this, ar, type.name))
const bool saveable = !type.saveable || type.saveable(false);

if (type.create(data, *this, saveable ? ar : nullptr, type.name))
{
*m_order++ = data;
*m_info++ = &type;
m_init[id] = true;

if (ar && type.save)
if (ar && saveable && type.save)
{
serial_breathe_and_tag(*ar, type.name, false);
}
Expand Down