Finished archives; remove pod.h

This commit is contained in:
Hamish Milne 2020-01-03 14:00:10 +00:00 committed by zhupengfei
parent 2bf5b46460
commit 558e710e17
14 changed files with 72 additions and 48 deletions

17
TODO
View File

@ -9,10 +9,11 @@
✔ Fix or ignore inverse map @done(19-12-23 12:46) ✔ Fix or ignore inverse map @done(19-12-23 12:46)
✘ App loader @cancelled(20-01-01 22:59) ✘ App loader @cancelled(20-01-01 22:59)
No relevant state No relevant state
☐ Archive manager @started(20-01-01 23:03) ✔ Archive manager @started(20-01-01 23:03) @done(20-01-03 13:23) @lasted(1d14h20m40s)
☐ NCCH @started(20-01-02 22:50) NB that 'FileBackend' classes are not persistent
✔ NCCH @started(20-01-02 22:50) @done(20-01-03 12:35) @lasted(13h45m50s)
✔ Normal @done(20-01-02 22:50) ✔ Normal @done(20-01-02 22:50)
☐ Self ✔ Self @done(20-01-03 12:35)
✔ SaveData @started(20-01-02 23:03) @done(20-01-02 23:27) @lasted(25m) ✔ SaveData @started(20-01-02 23:03) @done(20-01-02 23:27) @lasted(25m)
✔ Normal @done(20-01-02 23:03) ✔ Normal @done(20-01-02 23:03)
✔ Ext @done(20-01-02 23:26) ✔ Ext @done(20-01-02 23:26)
@ -22,8 +23,12 @@
✔ SDMC @done(20-01-02 23:34) ✔ SDMC @done(20-01-02 23:34)
✔ Normal @done(20-01-02 23:34) ✔ Normal @done(20-01-02 23:34)
✔ Write-only @done(20-01-02 23:34) ✔ Write-only @done(20-01-02 23:34)
☐ File refs ✘ IVFC @cancelled(20-01-03 13:22)
☐ Replace delay generator with virtual fns Seems IVFCArchive is never used.. which is good because it has a file reference!
✘ File refs @cancelled(20-01-03 13:22)
Not needed as nothing serializes file buffers
✘ Replace delay generator with virtual fns @cancelled(20-01-03 13:16)
While they have no state, the extra refactoring here is unneeded
☐ Custom texture cache ☐ Custom texture cache
✘ MMIO @cancelled(20-01-01 01:06) ✘ MMIO @cancelled(20-01-01 01:06)
Seems that this whole subsystem is only used in tests Seems that this whole subsystem is only used in tests
@ -35,7 +40,7 @@
For now, let the settings just be whatever they are For now, let the settings just be whatever they are
✘ Telemetry session @cancelled(20-01-01 01:12) ✘ Telemetry session @cancelled(20-01-01 01:12)
Doesn't need to be serialized here Doesn't need to be serialized here
Replace SERIALIZE_AS_POD with BOOST_IS_BITWISE_SERIALIZABLE Replace SERIALIZE_AS_POD with BOOST_IS_BITWISE_SERIALIZABLE @started(20-01-03 13:47) @done(20-01-03 13:58) @lasted(11m22s)
☐ Review constructor/initialization code ☐ Review constructor/initialization code
✔ Fix CI @done(19-12-31 21:32) ✔ Fix CI @done(19-12-31 21:32)
✔ HW @done(19-08-13 15:41) ✔ HW @done(19-08-13 15:41)

View File

@ -1,17 +0,0 @@
#include "boost/serialization/split_member.hpp"
#define SERIALIZE_AS_POD \
private: \
friend class boost::serialization::access; \
template <typename Archive> \
void save(Archive& ar, const unsigned int file_version) const { \
ar.save_binary(this, sizeof(*this)); \
} \
template <typename Archive> \
void load(Archive& ar, const unsigned int file_version) { \
ar.load_binary(this, sizeof(*this)); \
} \
template <class Archive> \
void serialize(Archive& ar, const unsigned int file_version) { \
boost::serialization::split_member(ar, *this, file_version); \
}

View File

@ -172,7 +172,9 @@ protected:
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) {} void serialize(Archive& ar, const unsigned int) {
ar& delay_generator;
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };

View File

@ -30,7 +30,6 @@
// FileSys namespace // FileSys namespace
SERIALIZE_EXPORT_IMPL(FileSys::NCCHArchive) SERIALIZE_EXPORT_IMPL(FileSys::NCCHArchive)
SERIALIZE_EXPORT_IMPL(FileSys::NCCHFile)
SERIALIZE_EXPORT_IMPL(FileSys::ArchiveFactory_NCCH) SERIALIZE_EXPORT_IMPL(FileSys::ArchiveFactory_NCCH)
namespace FileSys { namespace FileSys {

View File

@ -98,13 +98,6 @@ private:
NCCHFile() = default; // NOTE: If the public ctor has behaviour, need to replace this with NCCHFile() = default; // NOTE: If the public ctor has behaviour, need to replace this with
// *_construct_data // *_construct_data
std::vector<u8> file_buffer; // TODO: Replace with file ref for serialization std::vector<u8> file_buffer; // TODO: Replace with file ref for serialization
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<FileBackend>(*this);
ar& file_buffer;
}
friend class boost::serialization::access;
}; };
/// File system interface to the NCCH archive /// File system interface to the NCCH archive
@ -130,5 +123,4 @@ private:
} // namespace FileSys } // namespace FileSys
BOOST_CLASS_EXPORT_KEY(FileSys::NCCHArchive) BOOST_CLASS_EXPORT_KEY(FileSys::NCCHArchive)
BOOST_CLASS_EXPORT_KEY(FileSys::NCCHFile)
BOOST_CLASS_EXPORT_KEY(FileSys::ArchiveFactory_NCCH) BOOST_CLASS_EXPORT_KEY(FileSys::ArchiveFactory_NCCH)

View File

@ -4,6 +4,7 @@
#include <array> #include <array>
#include <cinttypes> #include <cinttypes>
#include "common/archives.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/swap.h" #include "common/swap.h"
@ -16,6 +17,8 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// FileSys namespace // FileSys namespace
SERIALIZE_EXPORT_IMPL(FileSys::ArchiveFactory_SelfNCCH)
namespace FileSys { namespace FileSys {
enum class SelfNCCHFilePathType : u32 { enum class SelfNCCHFilePathType : u32 {

View File

@ -8,6 +8,7 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <boost/serialization/export.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/file_sys/archive_backend.h" #include "core/file_sys/archive_backend.h"
#include "core/hle/result.h" #include "core/hle/result.h"
@ -44,7 +45,10 @@ public:
private: private:
/// Mapping of ProgramId -> NCCHData /// Mapping of ProgramId -> NCCHData
std::unordered_map<u64, NCCHData> ncch_data; std::unordered_map<u64, NCCHData>
ncch_data; // TODO: Remove this, or actually set the values here
}; };
} // namespace FileSys } // namespace FileSys
BOOST_CLASS_EXPORT_KEY(FileSys::ArchiveFactory_SelfNCCH)

View File

@ -3,8 +3,11 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include "common/archives.h"
#include "core/file_sys/delay_generator.h" #include "core/file_sys/delay_generator.h"
SERIALIZE_EXPORT_IMPL(FileSys::DefaultDelayGenerator)
namespace FileSys { namespace FileSys {
DelayGenerator::~DelayGenerator() = default; DelayGenerator::~DelayGenerator() = default;

View File

@ -5,6 +5,8 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
#include <boost/serialization/access.hpp>
#include <boost/serialization/export.hpp>
#include "common/common_types.h" #include "common/common_types.h"
namespace FileSys { namespace FileSys {
@ -16,6 +18,10 @@ public:
virtual u64 GetOpenDelayNs() = 0; virtual u64 GetOpenDelayNs() = 0;
// TODO (B3N30): Add getter for all other file/directory io operations // TODO (B3N30): Add getter for all other file/directory io operations
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
friend class boost::serialization::access;
}; };
class DefaultDelayGenerator : public DelayGenerator { class DefaultDelayGenerator : public DelayGenerator {
@ -25,3 +31,5 @@ public:
}; };
} // namespace FileSys } // namespace FileSys
BOOST_CLASS_EXPORT_KEY(FileSys::DefaultDelayGenerator);

View File

@ -89,12 +89,7 @@ public:
virtual void Flush() const = 0; virtual void Flush() const = 0;
protected: protected:
std::unique_ptr<DelayGenerator> delay_generator; // TODO: replace with virtual Get*DelayNs std::unique_ptr<DelayGenerator> delay_generator;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
friend class boost::serialization::access;
}; };
} // namespace FileSys } // namespace FileSys

View File

@ -6,11 +6,11 @@
#include <new> #include <new>
#include <utility> #include <utility>
#include <boost/serialization/access.hpp>
#include "common/assert.h" #include "common/assert.h"
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/pod.h"
// All the constants in this file come from http://3dbrew.org/wiki/Error_codes // All the constants in this file come from http://3dbrew.org/wiki/Error_codes
@ -227,7 +227,12 @@ union ResultCode {
return is_error.ExtractValue(raw) == 1; return is_error.ExtractValue(raw) == 1;
} }
SERIALIZE_AS_POD private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& raw;
}
friend class boost::serialization::access;
}; };
constexpr bool operator==(const ResultCode& a, const ResultCode& b) { constexpr bool operator==(const ResultCode& a, const ResultCode& b) {

View File

@ -6,11 +6,12 @@
#include <cstddef> #include <cstddef>
#include <type_traits> #include <type_traits>
#include <boost/serialization/access.hpp>
#include <boost/serialization/binary_object.hpp>
#include "common/assert.h" #include "common/assert.h"
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/pod.h"
namespace Memory { namespace Memory {
class MemorySystem; class MemorySystem;
@ -298,7 +299,12 @@ private:
return register_value * 8; return register_value * 8;
} }
SERIALIZE_AS_POD template <class Archive>
void serialize(Archive& ar, const unsigned int) {
auto obj = boost::serialization::binary_object(this, sizeof(Regs));
ar& obj;
}
friend class boost::serialization::access;
}; };
static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout"); static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout");

View File

@ -6,10 +6,10 @@
#include <cstddef> #include <cstddef>
#include <type_traits> #include <type_traits>
#include <boost/serialization/access.hpp>
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/pod.h"
#define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32)) #define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32))
@ -52,7 +52,15 @@ struct Regs {
return content[index]; return content[index];
} }
SERIALIZE_AS_POD private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& color_fill_top.raw;
ar& backlight_top;
ar& color_fill_bottom.raw;
ar& backlight_bottom;
}
friend class boost::serialization::access;
}; };
static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout"); static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout");

View File

@ -8,6 +8,7 @@
#include <cstddef> #include <cstddef>
#include <functional> #include <functional>
#include <type_traits> #include <type_traits>
#include <boost/serialization/access.hpp>
#include <boost/serialization/array.hpp> #include <boost/serialization/array.hpp>
#include <boost/serialization/base_object.hpp> #include <boost/serialization/base_object.hpp>
#include <nihstro/shader_bytecode.h> #include <nihstro/shader_bytecode.h>
@ -15,7 +16,6 @@
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/hash.h" #include "common/hash.h"
#include "common/pod.h"
#include "common/vector_math.h" #include "common/vector_math.h"
#include "video_core/pica_types.h" #include "video_core/pica_types.h"
#include "video_core/regs_rasterizer.h" #include "video_core/regs_rasterizer.h"
@ -65,7 +65,18 @@ struct OutputVertex {
static OutputVertex FromAttributeBuffer(const RasterizerRegs& regs, static OutputVertex FromAttributeBuffer(const RasterizerRegs& regs,
const AttributeBuffer& output); const AttributeBuffer& output);
SERIALIZE_AS_POD private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& pos;
ar& quat;
ar& tc0;
ar& tc1;
ar& tc0_w;
ar& view;
ar& tc2;
}
friend class boost::serialization::access;
}; };
#define ASSERT_POS(var, pos) \ #define ASSERT_POS(var, pos) \
static_assert(offsetof(OutputVertex, var) == pos * sizeof(float24), "Semantic at wrong " \ static_assert(offsetof(OutputVertex, var) == pos * sizeof(float24), "Semantic at wrong " \