mirror of
https://github.com/citra-emu/citra.git
synced 2024-12-22 07:30:04 +00:00
Added boost serialization
This commit is contained in:
parent
f106e76132
commit
6940c99ed6
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,6 +1,6 @@
|
||||
[submodule "boost"]
|
||||
path = externals/boost
|
||||
url = https://github.com/citra-emu/ext-boost.git
|
||||
url = https://github.com/hamish-milne/ext-boost.git
|
||||
[submodule "nihstro"]
|
||||
path = externals/nihstro
|
||||
url = https://github.com/neobrain/nihstro.git
|
||||
|
@ -124,6 +124,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
||||
# System imported libraries
|
||||
# ======================
|
||||
|
||||
add_library(boost_libs INTERFACE)
|
||||
|
||||
find_package(Boost 1.66.0 QUIET)
|
||||
if (NOT Boost_FOUND)
|
||||
message(STATUS "Boost 1.66.0 or newer not found, falling back to externals")
|
||||
@ -131,7 +133,14 @@ if (NOT Boost_FOUND)
|
||||
set(BOOST_ROOT "${PROJECT_SOURCE_DIR}/externals/boost")
|
||||
set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/boost")
|
||||
set(Boost_NO_SYSTEM_PATHS OFF)
|
||||
add_definitions( -DBOOST_ALL_NO_LIB )
|
||||
find_package(Boost QUIET REQUIRED)
|
||||
|
||||
# Boost external libraries
|
||||
file(GLOB boost_serialization_SRC "externals/boost/libs/serialization/src/*.cpp")
|
||||
add_library(boost_serialization STATIC ${boost_serialization_SRC})
|
||||
target_link_libraries(boost_serialization PUBLIC Boost::boost)
|
||||
target_link_libraries(boost_libs INTERFACE boost_serialization)
|
||||
endif()
|
||||
|
||||
# Prefer the -pthread flag on Linux.
|
||||
|
2
externals/boost
vendored
2
externals/boost
vendored
@ -1 +1 @@
|
||||
Subproject commit 502437b2ae3f1da821aa7d5d5174ec356fa89269
|
||||
Subproject commit 1acb9699ac8e91654331504cf3524b26463eeee4
|
11
src/common/archives.h
Normal file
11
src/common/archives.h
Normal file
@ -0,0 +1,11 @@
|
||||
#include "boost/archive/binary_iarchive.hpp"
|
||||
#include "boost/archive/binary_oarchive.hpp"
|
||||
|
||||
#define SERIALIZE_IMPL(A) template void A::serialize<boost::archive::binary_iarchive>( \
|
||||
boost::archive::binary_iarchive & ar, \
|
||||
const unsigned int file_version \
|
||||
); \
|
||||
template void A::serialize<boost::archive::binary_oarchive>( \
|
||||
boost::archive::binary_oarchive & ar, \
|
||||
const unsigned int file_version \
|
||||
);
|
@ -465,7 +465,7 @@ endif()
|
||||
create_target_directory_groups(core)
|
||||
|
||||
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
|
||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives)
|
||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives boost_libs)
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE)
|
||||
target_link_libraries(core PRIVATE web_service)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "boost/serialization/split_member.hpp"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/memory.h"
|
||||
@ -193,6 +194,31 @@ public:
|
||||
Memory::PageTable page_table;
|
||||
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void save(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
for (int i = 0; i < page_table.pointers.size(); i++) {
|
||||
ar << memory.GetFCRAMOffset(page_table.pointers[i]);
|
||||
}
|
||||
ar & page_table.special_regions;
|
||||
ar & page_table.attributes;
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
for (int i = 0; i < page_table.pointers.size(); i++) {
|
||||
u32 offset{};
|
||||
ar >> offset;
|
||||
page_table.pointers[i] = memory.GetFCRAMPointer(offset);
|
||||
}
|
||||
ar & page_table.special_regions;
|
||||
ar & page_table.attributes;
|
||||
}
|
||||
|
||||
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||
|
||||
using VMAIter = decltype(vma_map)::iterator;
|
||||
|
||||
/// Converts a VMAHandle to a mutable VMAIter.
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include "boost/serialization/split_member.hpp"
|
||||
#include "audio_core/dsp_interface.h"
|
||||
#include "common/archives.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
@ -67,8 +69,37 @@ public:
|
||||
std::vector<PageTable*> page_table_list;
|
||||
|
||||
AudioCore::DspInterface* dsp = nullptr;
|
||||
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void save(Archive & ar, const unsigned int file_version) const
|
||||
{
|
||||
// TODO: Skip n3ds ram when not used?
|
||||
ar.save_binary(fcram.get(), Memory::FCRAM_N3DS_SIZE);
|
||||
ar.save_binary(vram.get(), Memory::VRAM_SIZE);
|
||||
ar.save_binary(n3ds_extra_ram.get(), Memory::N3DS_EXTRA_RAM_SIZE);
|
||||
// ar & cache_marker;
|
||||
// ar & page_table_list;
|
||||
// ar & current_page_table;
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar.load_binary(fcram.get(), Memory::FCRAM_N3DS_SIZE);
|
||||
ar.load_binary(vram.get(), Memory::VRAM_SIZE);
|
||||
ar.load_binary(n3ds_extra_ram.get(), Memory::N3DS_EXTRA_RAM_SIZE);
|
||||
// ar & cache_marker;
|
||||
// ar & page_table_list;
|
||||
// ar & current_page_table;
|
||||
}
|
||||
|
||||
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||
};
|
||||
|
||||
SERIALIZE_IMPL(MemorySystem::Impl)
|
||||
|
||||
MemorySystem::MemorySystem() : impl(std::make_unique<Impl>()) {}
|
||||
MemorySystem::~MemorySystem() = default;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "boost/serialization/split_member.hpp"
|
||||
#include "common/common_types.h"
|
||||
#include "core/mmio.h"
|
||||
|
||||
@ -52,6 +53,14 @@ struct SpecialRegion {
|
||||
VAddr base;
|
||||
u32 size;
|
||||
MMIORegionPointer handler;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & base;
|
||||
ar & size;
|
||||
ar & handler;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user