From 558e710e170030e1e9bc8f0105f571b44a43bb79 Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Fri, 3 Jan 2020 14:00:10 +0000 Subject: [PATCH] Finished archives; remove pod.h --- TODO | 17 +++++++++++------ src/common/pod.h | 17 ----------------- src/core/file_sys/archive_backend.h | 4 +++- src/core/file_sys/archive_ncch.cpp | 1 - src/core/file_sys/archive_ncch.h | 8 -------- src/core/file_sys/archive_selfncch.cpp | 3 +++ src/core/file_sys/archive_selfncch.h | 6 +++++- src/core/file_sys/delay_generator.cpp | 3 +++ src/core/file_sys/delay_generator.h | 8 ++++++++ src/core/file_sys/file_backend.h | 7 +------ src/core/hle/result.h | 9 +++++++-- src/core/hw/gpu.h | 10 ++++++++-- src/core/hw/lcd.h | 12 ++++++++++-- src/video_core/shader/shader.h | 15 +++++++++++++-- 14 files changed, 72 insertions(+), 48 deletions(-) delete mode 100644 src/common/pod.h diff --git a/TODO b/TODO index c1f5e49cd..bc4003d44 100644 --- a/TODO +++ b/TODO @@ -9,10 +9,11 @@ ✔ Fix or ignore inverse map @done(19-12-23 12:46) ✘ App loader @cancelled(20-01-01 22:59) No relevant state -☐ Archive manager @started(20-01-01 23:03) - ☐ NCCH @started(20-01-02 22:50) +✔ Archive manager @started(20-01-01 23:03) @done(20-01-03 13:23) @lasted(1d14h20m40s) + 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) - ☐ Self + ✔ Self @done(20-01-03 12:35) ✔ SaveData @started(20-01-02 23:03) @done(20-01-02 23:27) @lasted(25m) ✔ Normal @done(20-01-02 23:03) ✔ Ext @done(20-01-02 23:26) @@ -22,8 +23,12 @@ ✔ SDMC @done(20-01-02 23:34) ✔ Normal @done(20-01-02 23:34) ✔ Write-only @done(20-01-02 23:34) - ☐ File refs - ☐ Replace delay generator with virtual fns + ✘ IVFC @cancelled(20-01-03 13:22) + 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 ✘ MMIO @cancelled(20-01-01 01:06) Seems that this whole subsystem is only used in tests @@ -35,7 +40,7 @@ For now, let the settings just be whatever they are ✘ Telemetry session @cancelled(20-01-01 01:12) 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 ✔ Fix CI @done(19-12-31 21:32) ✔ HW @done(19-08-13 15:41) diff --git a/src/common/pod.h b/src/common/pod.h deleted file mode 100644 index bb7095417..000000000 --- a/src/common/pod.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "boost/serialization/split_member.hpp" - -#define SERIALIZE_AS_POD \ -private: \ - friend class boost::serialization::access; \ - template \ - void save(Archive& ar, const unsigned int file_version) const { \ - ar.save_binary(this, sizeof(*this)); \ - } \ - template \ - void load(Archive& ar, const unsigned int file_version) { \ - ar.load_binary(this, sizeof(*this)); \ - } \ - template \ - void serialize(Archive& ar, const unsigned int file_version) { \ - boost::serialization::split_member(ar, *this, file_version); \ - } diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h index 05aa877a3..756613a30 100644 --- a/src/core/file_sys/archive_backend.h +++ b/src/core/file_sys/archive_backend.h @@ -172,7 +172,9 @@ protected: private: template - void serialize(Archive& ar, const unsigned int) {} + void serialize(Archive& ar, const unsigned int) { + ar& delay_generator; + } friend class boost::serialization::access; }; diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cpp index 789547f0e..636bb81ed 100644 --- a/src/core/file_sys/archive_ncch.cpp +++ b/src/core/file_sys/archive_ncch.cpp @@ -30,7 +30,6 @@ // FileSys namespace SERIALIZE_EXPORT_IMPL(FileSys::NCCHArchive) -SERIALIZE_EXPORT_IMPL(FileSys::NCCHFile) SERIALIZE_EXPORT_IMPL(FileSys::ArchiveFactory_NCCH) namespace FileSys { diff --git a/src/core/file_sys/archive_ncch.h b/src/core/file_sys/archive_ncch.h index 52ae827c3..0a3f95b5c 100644 --- a/src/core/file_sys/archive_ncch.h +++ b/src/core/file_sys/archive_ncch.h @@ -98,13 +98,6 @@ private: NCCHFile() = default; // NOTE: If the public ctor has behaviour, need to replace this with // *_construct_data std::vector file_buffer; // TODO: Replace with file ref for serialization - - template - void serialize(Archive& ar, const unsigned int) { - ar& boost::serialization::base_object(*this); - ar& file_buffer; - } - friend class boost::serialization::access; }; /// File system interface to the NCCH archive @@ -130,5 +123,4 @@ private: } // namespace FileSys BOOST_CLASS_EXPORT_KEY(FileSys::NCCHArchive) -BOOST_CLASS_EXPORT_KEY(FileSys::NCCHFile) BOOST_CLASS_EXPORT_KEY(FileSys::ArchiveFactory_NCCH) diff --git a/src/core/file_sys/archive_selfncch.cpp b/src/core/file_sys/archive_selfncch.cpp index 0f8dd8065..214ad7c08 100644 --- a/src/core/file_sys/archive_selfncch.cpp +++ b/src/core/file_sys/archive_selfncch.cpp @@ -4,6 +4,7 @@ #include #include +#include "common/archives.h" #include "common/common_types.h" #include "common/logging/log.h" #include "common/swap.h" @@ -16,6 +17,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// // FileSys namespace +SERIALIZE_EXPORT_IMPL(FileSys::ArchiveFactory_SelfNCCH) + namespace FileSys { enum class SelfNCCHFilePathType : u32 { diff --git a/src/core/file_sys/archive_selfncch.h b/src/core/file_sys/archive_selfncch.h index 779e7e75a..de7fd75e0 100644 --- a/src/core/file_sys/archive_selfncch.h +++ b/src/core/file_sys/archive_selfncch.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "common/common_types.h" #include "core/file_sys/archive_backend.h" #include "core/hle/result.h" @@ -44,7 +45,10 @@ public: private: /// Mapping of ProgramId -> NCCHData - std::unordered_map ncch_data; + std::unordered_map + ncch_data; // TODO: Remove this, or actually set the values here }; } // namespace FileSys + +BOOST_CLASS_EXPORT_KEY(FileSys::ArchiveFactory_SelfNCCH) diff --git a/src/core/file_sys/delay_generator.cpp b/src/core/file_sys/delay_generator.cpp index 04f877f83..137e63d69 100644 --- a/src/core/file_sys/delay_generator.cpp +++ b/src/core/file_sys/delay_generator.cpp @@ -3,8 +3,11 @@ // Refer to the license.txt file included. #include +#include "common/archives.h" #include "core/file_sys/delay_generator.h" +SERIALIZE_EXPORT_IMPL(FileSys::DefaultDelayGenerator) + namespace FileSys { DelayGenerator::~DelayGenerator() = default; diff --git a/src/core/file_sys/delay_generator.h b/src/core/file_sys/delay_generator.h index d530f2ee2..8fa92ac41 100644 --- a/src/core/file_sys/delay_generator.h +++ b/src/core/file_sys/delay_generator.h @@ -5,6 +5,8 @@ #pragma once #include +#include +#include #include "common/common_types.h" namespace FileSys { @@ -16,6 +18,10 @@ public: virtual u64 GetOpenDelayNs() = 0; // TODO (B3N30): Add getter for all other file/directory io operations +private: + template + void serialize(Archive& ar, const unsigned int) {} + friend class boost::serialization::access; }; class DefaultDelayGenerator : public DelayGenerator { @@ -25,3 +31,5 @@ public: }; } // namespace FileSys + +BOOST_CLASS_EXPORT_KEY(FileSys::DefaultDelayGenerator); diff --git a/src/core/file_sys/file_backend.h b/src/core/file_sys/file_backend.h index 03dff156d..c865c98e8 100644 --- a/src/core/file_sys/file_backend.h +++ b/src/core/file_sys/file_backend.h @@ -89,12 +89,7 @@ public: virtual void Flush() const = 0; protected: - std::unique_ptr delay_generator; // TODO: replace with virtual Get*DelayNs - -private: - template - void serialize(Archive& ar, const unsigned int) {} - friend class boost::serialization::access; + std::unique_ptr delay_generator; }; } // namespace FileSys diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 4168ce36c..40a71e369 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -6,11 +6,11 @@ #include #include +#include #include "common/assert.h" #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" -#include "common/pod.h" // 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; } - SERIALIZE_AS_POD +private: + template + void serialize(Archive& ar, const unsigned int) { + ar& raw; + } + friend class boost::serialization::access; }; constexpr bool operator==(const ResultCode& a, const ResultCode& b) { diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 980b48cd7..fcf7a3137 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -6,11 +6,12 @@ #include #include +#include +#include #include "common/assert.h" #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" -#include "common/pod.h" namespace Memory { class MemorySystem; @@ -298,7 +299,12 @@ private: return register_value * 8; } - SERIALIZE_AS_POD + template + 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::value, "Structure does not use standard layout"); diff --git a/src/core/hw/lcd.h b/src/core/hw/lcd.h index ecc9ecea4..9667c7c4c 100644 --- a/src/core/hw/lcd.h +++ b/src/core/hw/lcd.h @@ -6,10 +6,10 @@ #include #include +#include #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" -#include "common/pod.h" #define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32)) @@ -52,7 +52,15 @@ struct Regs { return content[index]; } - SERIALIZE_AS_POD +private: + template + 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::value, "Structure does not use standard layout"); diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index a6e42b3bf..6a5a33419 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -15,7 +16,6 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "common/hash.h" -#include "common/pod.h" #include "common/vector_math.h" #include "video_core/pica_types.h" #include "video_core/regs_rasterizer.h" @@ -65,7 +65,18 @@ struct OutputVertex { static OutputVertex FromAttributeBuffer(const RasterizerRegs& regs, const AttributeBuffer& output); - SERIALIZE_AS_POD +private: + template + 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) \ static_assert(offsetof(OutputVertex, var) == pos * sizeof(float24), "Semantic at wrong " \