Added shader state; WIP kernel objects

This commit is contained in:
Hamish Milne 2019-08-11 00:20:09 +01:00 committed by zhupengfei
parent 45788b9c82
commit f79c9668a3
33 changed files with 576 additions and 68 deletions

2
externals/boost vendored

@ -1 +1 @@
Subproject commit d2a5baa1ad701671a7ef547ef71cb0f0c80ce2cf
Subproject commit 48130d387975d17aed1b34ef75c21020f2d710a8

View file

@ -90,6 +90,8 @@ add_library(common STATIC
scm_rev.cpp
scm_rev.h
scope_exit.h
serialization/atomic.h
serialization/boost_vector.hpp
string_util.cpp
string_util.h
swap.h

View file

@ -0,0 +1,28 @@
#pragma once
#include <atomic>
#include <boost/serialization/split_free.hpp>
namespace boost::serialization
{
template <class Archive, class T>
void serialize(Archive& ar, std::atomic<T>& value, const unsigned int file_version)
{
boost::serialization::split_free(ar, value, file_version);
}
template <class Archive, class T>
void save(Archive& ar, const std::atomic<T>& value, const unsigned int file_version)
{
ar << value.load();
}
template <class Archive, class T>
void load(Archive& ar, std::atomic<T>& value, const unsigned int file_version)
{
T tmp;
ar >> tmp;
value.store(tmp);
}
} // namespace boost::serialization

View file

@ -0,0 +1,189 @@
#ifndef BOOST_SERIALIZATION_BOOST_VECTOR_HPP
#define BOOST_SERIALIZATION_BOOST_VECTOR_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// boost_vector.hpp: serialization for boost vector templates
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// fast array serialization (C) Copyright 2005 Matthias Troyer
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/container/vector.hpp>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/archive/detail/basic_iarchive.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/serialization/item_version_type.hpp>
#include <boost/serialization/collections_save_imp.hpp>
#include <boost/serialization/collections_load_imp.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/array_wrapper.hpp>
#include <boost/mpl/bool_fwd.hpp>
#include <boost/mpl/if.hpp>
// default is being compatible with version 1.34.1 files, not 1.35 files
#ifndef BOOST_SERIALIZATION_VECTOR_VERSIONED
#define BOOST_SERIALIZATION_VECTOR_VERSIONED(V) (V==4 || V==5)
#endif
namespace boost {
namespace serialization {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// vector< T >
// the default versions
template<class Archive, class U, class Allocator>
inline void save(
Archive & ar,
const boost::container::vector<U, Allocator> &t,
const unsigned int /* file_version */,
mpl::false_
){
boost::serialization::stl::save_collection<Archive, boost::container::vector<U, Allocator> >(
ar, t
);
}
template<class Archive, class U, class Allocator>
inline void load(
Archive & ar,
boost::container::vector<U, Allocator> &t,
const unsigned int /* file_version */,
mpl::false_
){
const boost::archive::library_version_type library_version(
ar.get_library_version()
);
// retrieve number of elements
item_version_type item_version(0);
collection_size_type count;
ar >> BOOST_SERIALIZATION_NVP(count);
if(boost::archive::library_version_type(3) < library_version){
ar >> BOOST_SERIALIZATION_NVP(item_version);
}
t.reserve(count);
stl::collection_load_impl(ar, t, count, item_version);
}
// the optimized versions
template<class Archive, class U, class Allocator>
inline void save(
Archive & ar,
const boost::container::vector<U, Allocator> &t,
const unsigned int /* file_version */,
mpl::true_
){
const collection_size_type count(t.size());
ar << BOOST_SERIALIZATION_NVP(count);
if (!t.empty())
// explict template arguments to pass intel C++ compiler
ar << serialization::make_array<const U, collection_size_type>(
static_cast<const U *>(&t[0]),
count
);
}
template<class Archive, class U, class Allocator>
inline void load(
Archive & ar,
boost::container::vector<U, Allocator> &t,
const unsigned int /* file_version */,
mpl::true_
){
collection_size_type count(t.size());
ar >> BOOST_SERIALIZATION_NVP(count);
t.resize(count);
unsigned int item_version=0;
if(BOOST_SERIALIZATION_VECTOR_VERSIONED(ar.get_library_version())) {
ar >> BOOST_SERIALIZATION_NVP(item_version);
}
if (!t.empty())
// explict template arguments to pass intel C++ compiler
ar >> serialization::make_array<U, collection_size_type>(
static_cast<U *>(&t[0]),
count
);
}
// dispatch to either default or optimized versions
template<class Archive, class U, class Allocator>
inline void save(
Archive & ar,
const boost::container::vector<U, Allocator> &t,
const unsigned int file_version
){
typedef typename
boost::serialization::use_array_optimization<Archive>::template apply<
typename remove_const<U>::type
>::type use_optimized;
save(ar,t,file_version, use_optimized());
}
template<class Archive, class U, class Allocator>
inline void load(
Archive & ar,
boost::container::vector<U, Allocator> &t,
const unsigned int file_version
){
#ifdef BOOST_SERIALIZATION_VECTOR_135_HPP
if (ar.get_library_version()==boost::archive::library_version_type(5))
{
load(ar,t,file_version, boost::is_arithmetic<U>());
return;
}
#endif
typedef typename
boost::serialization::use_array_optimization<Archive>::template apply<
typename remove_const<U>::type
>::type use_optimized;
load(ar,t,file_version, use_optimized());
}
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<class Archive, class U, class Allocator>
inline void serialize(
Archive & ar,
boost::container::vector<U, Allocator> & t,
const unsigned int file_version
){
boost::serialization::split_free(ar, t, file_version);
}
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<class Archive, class Allocator>
inline void serialize(
Archive & ar,
boost::container::vector<bool, Allocator> & t,
const unsigned int file_version
){
boost::serialization::split_free(ar, t, file_version);
}
} // serialization
} // namespace boost
#include <boost/serialization/collection_traits.hpp>
BOOST_SERIALIZATION_COLLECTION_TRAITS(boost::container::vector)
#endif // BOOST_SERIALIZATION_VECTOR_HPP

View file

@ -5,7 +5,6 @@
#include <memory>
#include <utility>
#include "boost/serialization/array.hpp"
#include "boost/serialization/unique_ptr.hpp"
#include "audio_core/dsp_interface.h"
#include "audio_core/hle/hle.h"
#include "audio_core/lle/lle.h"
@ -205,6 +204,7 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo
kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing,
[this] { PrepareReschedule(); }, system_mode);
Kernel::g_kernel = kernel.get();
if (Settings::values.use_cpu_jit) {
#ifdef ARCHITECTURE_x86_64
@ -368,6 +368,7 @@ void System::Shutdown() {
service_manager.reset();
dsp_core.reset();
cpu_core.reset();
Kernel::g_kernel = nullptr;
kernel.reset();
timing.reset();
app_loader.reset();
@ -400,7 +401,8 @@ void System::serialize(Archive & ar, const unsigned int file_version)
ar & GPU::g_regs;
ar & LCD::g_regs;
ar & dsp_core->GetDspMemory();
ar & memory;
ar & *memory.get();
ar & *kernel.get();
}
void System::Save(std::ostream &stream) const

View file

@ -13,9 +13,6 @@
namespace Kernel {
ClientPort::ClientPort(KernelSystem& kernel) : Object(kernel), kernel(kernel) {}
ClientPort::~ClientPort() = default;
ResultVal<std::shared_ptr<ClientSession>> ClientPort::Connect() {
// Note: Threads do not wait for the server endpoint to call
// AcceptSession before returning from this call.
@ -26,7 +23,7 @@ ResultVal<std::shared_ptr<ClientSession>> ClientPort::Connect() {
active_sessions++;
// Create a new session pair, let the created sessions inherit the parent port's HLE handler.
auto [server, client] = kernel.CreateSessionPair(server_port->GetName(), SharedFrom(this));
auto [server, client] = g_kernel->CreateSessionPair(server_port->GetName(), SharedFrom(this));
if (server_port->hle_handler)
server_port->hle_handler->ClientConnected(server);

View file

@ -17,8 +17,6 @@ class ClientSession;
class ClientPort final : public Object {
public:
explicit ClientPort(KernelSystem& kernel);
~ClientPort() override;
friend class ServerPort;
std::string GetTypeName() const override {
@ -52,13 +50,25 @@ public:
void ConnectionClosed();
private:
KernelSystem& kernel;
std::shared_ptr<ServerPort> server_port; ///< ServerPort associated with this client port.
u32 max_sessions = 0; ///< Maximum number of simultaneous sessions the port can have
u32 active_sessions = 0; ///< Number of currently open sessions to this port
std::string name; ///< Name of client port (optional)
friend class KernelSystem;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<Object>(*this);
ar & server_port;
ar & max_sessions;
ar & active_sessions;
ar & name;
}
};
} // namespace Kernel

View file

@ -49,6 +49,16 @@ private:
std::string name; ///< Name of event (optional)
friend class KernelSystem;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<WaitObject>(*this);
ar & reset_type;
ar & signaled;
ar & name;
}
};
} // namespace Kernel

View file

@ -7,6 +7,8 @@
#include <array>
#include <cstddef>
#include <memory>
#include <boost/serialization/array.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
#include "core/hle/result.h"
@ -116,6 +118,16 @@ private:
u16 next_free_slot;
KernelSystem& kernel;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & objects;
ar & generations;
ar & next_generation;
ar & next_free_slot;
}
};
} // namespace Kernel

View file

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "common/serialization/atomic.h"
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/config_mem.h"
#include "core/hle/kernel/handle_table.h"
@ -16,6 +18,8 @@
namespace Kernel {
KernelSystem* g_kernel;
/// Initialize the kernel
KernelSystem::KernelSystem(Memory::MemorySystem& memory, Core::Timing& timing,
std::function<void()> prepare_reschedule_callback, u32 system_mode)
@ -101,4 +105,23 @@ void KernelSystem::AddNamedPort(std::string name, std::shared_ptr<ClientPort> po
named_ports.emplace(std::move(name), std::move(port));
}
template <class Archive>
void KernelSystem::serialize(Archive& ar, const unsigned int file_version)
{
ar & named_ports;
// TODO: CPU
// NB: subsystem references and prepare_reschedule_callback are constant
ar & *resource_limits.get();
ar & next_object_id;
//ar & *timer_manager.get();
ar & next_process_id;
ar & process_list;
ar & current_process;
// ar & *thread_manager.get();
//ar & *config_mem_handler.get();
//ar & *shared_page_handler.get();
}
SERIALIZE_IMPL(KernelSystem)
} // namespace Kernel

View file

@ -11,6 +11,9 @@
#include <string>
#include <unordered_map>
#include <vector>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unordered_map.hpp>
#include <boost/serialization/vector.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/memory.h"
#include "core/hle/result.h"
@ -283,6 +286,12 @@ private:
std::unique_ptr<SharedPage::Handler> shared_page_handler;
std::unique_ptr<IPCDebugger::Recorder> ipc_recorder;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version);
};
extern KernelSystem* g_kernel;
} // namespace Kernel

View file

@ -60,6 +60,17 @@ struct MemoryRegionInfo {
* @param size the size of the region to free.
*/
void Free(u32 offset, u32 size);
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & base;
ar & size;
ar & used;
// TODO: boost icl / free_blocks
}
};
} // namespace Kernel

View file

@ -58,6 +58,18 @@ public:
private:
KernelSystem& kernel;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<WaitObject>(*this);
ar & lock_count;
ar & priority;
ar & name;
ar & holding_thread;
ar & kernel; // TODO: Check that this works!
}
};
/**

View file

@ -8,7 +8,17 @@
namespace Kernel {
Object::Object(KernelSystem& kernel) : object_id{kernel.GenerateObjectID()} {}
// TODO: Remove this
Object::Object(KernelSystem& kernel)
{
}
Object::Object() = default;
void Object::Init(KernelSystem& kernel)
{
object_id = kernel.GenerateObjectID();
}
Object::~Object() = default;

View file

@ -7,6 +7,7 @@
#include <atomic>
#include <memory>
#include <string>
#include <boost/serialization/access.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/kernel.h"
@ -41,8 +42,11 @@ enum {
class Object : NonCopyable, public std::enable_shared_from_this<Object> {
public:
explicit Object(KernelSystem& kernel);
Object();
virtual ~Object();
virtual void Init(KernelSystem& kernel);
/// Returns a unique identifier for the object. For debugging purposes only.
u32 GetObjectId() const {
return object_id.load(std::memory_order_relaxed);
@ -64,6 +68,13 @@ public:
private:
std::atomic<u32> object_id;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & object_id;
}
};
template <typename T>

View file

@ -18,7 +18,8 @@
namespace Kernel {
std::shared_ptr<CodeSet> KernelSystem::CreateCodeSet(std::string name, u64 program_id) {
auto codeset{std::make_shared<CodeSet>(*this)};
auto codeset{std::make_shared<CodeSet>()};
codeset->Init(*this);
codeset->name = std::move(name);
codeset->program_id = program_id;
@ -26,11 +27,9 @@ std::shared_ptr<CodeSet> KernelSystem::CreateCodeSet(std::string name, u64 progr
return codeset;
}
CodeSet::CodeSet(KernelSystem& kernel) : Object(kernel) {}
CodeSet::~CodeSet() {}
std::shared_ptr<Process> KernelSystem::CreateProcess(std::shared_ptr<CodeSet> code_set) {
auto process{std::make_shared<Process>(*this)};
auto process{std::make_shared<Process>()};
process->Init(*this);
process->codeset = std::move(code_set);
process->flags.raw = 0;
@ -401,9 +400,8 @@ ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission pe
return RESULT_SUCCESS;
}
Kernel::Process::Process(KernelSystem& kernel)
: Object(kernel), handle_table(kernel), vm_manager(kernel.memory), kernel(kernel) {
Kernel::Process::Process() : kernel(*g_kernel), handle_table(*g_kernel), vm_manager(g_kernel->memory)
{
kernel.memory.RegisterPageTable(&vm_manager.page_table);
}
Kernel::Process::~Process() {

View file

@ -11,8 +11,13 @@
#include <string>
#include <vector>
#include <boost/container/static_vector.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/bitset.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/vector.hpp>
#include "common/bit_field.h"
#include "common/common_types.h"
#include "common/serialization/boost_vector.hpp"
#include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/vm_manager.h"
@ -25,6 +30,17 @@ struct AddressMapping {
u32 size;
bool read_only;
bool unk_flag;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & address;
ar & size;
ar & read_only;
ar & unk_flag;
}
};
union ProcessFlags {
@ -52,13 +68,20 @@ struct MemoryRegionInfo;
class CodeSet final : public Object {
public:
explicit CodeSet(KernelSystem& kernel);
~CodeSet() override;
struct Segment {
std::size_t offset = 0;
VAddr addr = 0;
u32 size = 0;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & offset;
ar & addr;
ar & size;
}
};
std::string GetTypeName() const override {
@ -106,11 +129,24 @@ public:
std::string name;
/// Title ID corresponding to the process
u64 program_id;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<Object>(*this);
// TODO: memory reference
ar & segments;
ar & entrypoint;
ar & name;
ar & program_id;
}
};
class Process final : public Object {
public:
explicit Process(Kernel::KernelSystem& kernel);
explicit Process();
~Process() override;
std::string GetTypeName() const override {
@ -195,5 +231,26 @@ public:
private:
KernelSystem& kernel;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<Object>(*this);
ar & handle_table;
ar & codeset;
ar & resource_limit;
ar & svc_access_mask;
ar & handle_table_size;
ar & (boost::container::vector<AddressMapping, boost::container::dtl::static_storage_allocator<AddressMapping, 8> >&)address_mappings;
ar & flags.raw;
ar & kernel_version;
ar & ideal_processor;
ar & process_id;
ar & vm_manager;
ar & memory_used;
ar & memory_region;
ar & tls_slots;
}
};
} // namespace Kernel

View file

@ -9,11 +9,9 @@
namespace Kernel {
ResourceLimit::ResourceLimit(KernelSystem& kernel) : Object(kernel) {}
ResourceLimit::~ResourceLimit() {}
std::shared_ptr<ResourceLimit> ResourceLimit::Create(KernelSystem& kernel, std::string name) {
auto resource_limit{std::make_shared<ResourceLimit>(kernel)};
auto resource_limit{std::make_shared<ResourceLimit>()};
resource_limit->Init(kernel);
resource_limit->name = std::move(name);
return resource_limit;

View file

@ -6,6 +6,8 @@
#include <array>
#include <memory>
#include <boost/serialization/array.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
@ -33,8 +35,6 @@ enum ResourceTypes {
class ResourceLimit final : public Object {
public:
explicit ResourceLimit(KernelSystem& kernel);
~ResourceLimit() override;
/**
* Creates a resource limit object.
@ -110,6 +110,35 @@ public:
/// Current CPU time that the processes in this category are utilizing
s32 current_cpu_time = 0;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<Object>(*this);
// NB most of these aren't used at all currently, but we're adding them here for forwards compatibility
ar & name;
ar & max_priority;
ar & max_commit;
ar & max_threads;
ar & max_events;
ar & max_mutexes;
ar & max_semaphores;
ar & max_timers;
ar & max_shared_mems;
ar & max_address_arbiters;
ar & max_cpu_time;
ar & current_commit;
ar & current_threads;
ar & current_events;
ar & current_mutexes;
ar & current_semaphores;
ar & current_timers;
ar & current_shared_mems;
ar & current_address_arbiters;
ar & current_cpu_time;
}
};
class ResourceLimitList {
@ -126,6 +155,13 @@ public:
private:
std::array<std::shared_ptr<ResourceLimit>, 4> resource_limits;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & resource_limits;
}
};
} // namespace Kernel

View file

@ -43,6 +43,17 @@ public:
* @return The number of free slots the semaphore had before this call
*/
ResultVal<s32> Release(s32 release_count);
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<WaitObject>(*this);
ar & max_count;
ar & available_count;
ar & name;
}
};
} // namespace Kernel

View file

@ -13,9 +13,6 @@
namespace Kernel {
ServerPort::ServerPort(KernelSystem& kernel) : WaitObject(kernel) {}
ServerPort::~ServerPort() {}
ResultVal<std::shared_ptr<ServerSession>> ServerPort::Accept() {
if (pending_sessions.empty()) {
return ERR_NO_PENDING_SESSIONS;
@ -36,8 +33,10 @@ void ServerPort::Acquire(Thread* thread) {
}
KernelSystem::PortPair KernelSystem::CreatePortPair(u32 max_sessions, std::string name) {
auto server_port{std::make_shared<ServerPort>(*this)};
auto client_port{std::make_shared<ClientPort>(*this)};
auto server_port{std::make_shared<ServerPort>()};
server_port->Init(*this);
auto client_port{std::make_shared<ClientPort>()};
client_port->Init(*this);
server_port->name = name + "_Server";
client_port->name = name + "_Client";

View file

@ -20,8 +20,6 @@ class SessionRequestHandler;
class ServerPort final : public WaitObject {
public:
explicit ServerPort(KernelSystem& kernel);
~ServerPort() override;
std::string GetTypeName() const override {
return "ServerPort";

View file

@ -13,7 +13,7 @@
namespace Kernel {
ServerSession::ServerSession(KernelSystem& kernel) : WaitObject(kernel), kernel(kernel) {}
ServerSession::ServerSession() : kernel(*g_kernel) {}
ServerSession::~ServerSession() {
// This destructor will be called automatically when the last ServerSession handle is closed by
// the emulated application.
@ -30,7 +30,8 @@ ServerSession::~ServerSession() {
ResultVal<std::shared_ptr<ServerSession>> ServerSession::Create(KernelSystem& kernel,
std::string name) {
auto server_session{std::make_shared<ServerSession>(kernel)};
auto server_session{std::make_shared<ServerSession>()};
server_session->Init(kernel);
server_session->name = std::move(name);
server_session->parent = nullptr;

View file

@ -38,7 +38,7 @@ class Thread;
class ServerSession final : public WaitObject {
public:
~ServerSession() override;
explicit ServerSession(KernelSystem& kernel);
explicit ServerSession();
std::string GetName() const override {
return name;

View file

@ -37,9 +37,9 @@ u32 ThreadManager::NewThreadId() {
return next_thread_id++;
}
Thread::Thread(KernelSystem& kernel)
: WaitObject(kernel), context(kernel.GetThreadManager().NewContext()),
thread_manager(kernel.GetThreadManager()) {}
Thread::Thread()
: context(g_kernel->GetThreadManager().NewContext()),
thread_manager(g_kernel->GetThreadManager()) {}
Thread::~Thread() {}
Thread* ThreadManager::GetCurrentThread() const {
@ -309,7 +309,8 @@ ResultVal<std::shared_ptr<Thread>> KernelSystem::CreateThread(std::string name,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
}
auto thread{std::make_shared<Thread>(*this)};
auto thread{std::make_shared<Thread>()};
thread->Init(*this);
thread_manager->thread_list.push_back(thread);
thread_manager->ready_queue.prepare(priority);

View file

@ -149,7 +149,7 @@ private:
class Thread final : public WaitObject {
public:
explicit Thread(KernelSystem&);
explicit Thread();
~Thread() override;
std::string GetName() const override {

View file

@ -8,7 +8,8 @@
#include <memory>
#include <utility>
#include <vector>
#include "boost/serialization/split_member.hpp"
#include <boost/serialization/map.hpp>
#include <boost/serialization/split_member.hpp>
#include "common/common_types.h"
#include "core/hle/result.h"
#include "core/memory.h"
@ -81,6 +82,21 @@ struct VirtualMemoryArea {
/// Tests if this area can be merged to the right with `next`.
bool CanBeMergedWith(const VirtualMemoryArea& next) const;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & base;
ar & size;
ar & type;
ar & permissions;
ar & meminfo_state;
// TODO: backing memory ref
ar & paddr;
ar & mmio_handler;
}
};
/**
@ -195,9 +211,10 @@ public:
private:
friend class boost::serialization::access;
template<class Archive>
void save(Archive & ar, const unsigned int file_version)
template <class Archive>
void save(Archive& ar, const unsigned int file_version) const
{
ar & vma_map;
for (int i = 0; i < page_table.pointers.size(); i++) {
ar << memory.GetFCRAMOffset(page_table.pointers[i]);
}
@ -205,9 +222,10 @@ private:
ar & page_table.attributes;
}
template<class Archive>
void load(Archive & ar, const unsigned int file_version)
template <class Archive>
void load(Archive& ar, const unsigned int file_version)
{
ar & vma_map;
for (int i = 0; i < page_table.pointers.size(); i++) {
u32 offset{};
ar >> offset;

View file

@ -7,6 +7,9 @@
#include <functional>
#include <memory>
#include <vector>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
@ -62,6 +65,17 @@ private:
/// Function to call when this object becomes available
std::function<void()> hle_notifier;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<Object>(*this);
ar & waiting_threads;
// NB: hle_notifier *not* serialized since it's a callback!
// Fortunately it's only used in one place (DSP) so we can reconstruct it there
}
};
// Specialization of DynamicObjectCast for WaitObjects

View file

@ -14,6 +14,7 @@
#include "core/hle/ipc_helpers.h"
#include "core/hle/result.h"
#include "core/hle/service/err_f.h"
#undef exception_info
namespace Service::ERR {

View file

@ -5,8 +5,7 @@
#include <array>
#include <cstring>
#include "boost/serialization/array.hpp"
#include "boost/serialization/nvp.hpp"
#include "boost/serialization/unique_ptr.hpp"
#include "boost/serialization/binary_object.hpp"
#include "audio_core/dsp_interface.h"
#include "common/archives.h"
#include "common/assert.h"
@ -84,23 +83,17 @@ public:
private:
template<class Archive>
void add_blob(Archive & ar, std::unique_ptr<u8[]> & var, const char *name, std::size_t size)
{
ar & boost::serialization::make_nvp(
name,
*static_cast<u8 (*)[Memory::FCRAM_N3DS_SIZE]>(static_cast<void *>(var.get()))
);
}
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int file_version)
{
// TODO: Skip n3ds ram when not used?
add_blob(ar, fcram, "fcram", Memory::FCRAM_N3DS_SIZE);
add_blob(ar, vram, "vram", Memory::VRAM_SIZE);
add_blob(ar, n3ds_extra_ram, "n3ds_extra_ram", Memory::N3DS_EXTRA_RAM_SIZE);
auto s_fcram = boost::serialization::binary_object(fcram.get(), Memory::FCRAM_N3DS_SIZE);
auto s_vram = boost::serialization::binary_object(vram.get(), Memory::VRAM_SIZE);
auto s_extra = boost::serialization::binary_object(n3ds_extra_ram.get(), Memory::N3DS_EXTRA_RAM_SIZE);
ar & s_fcram;
ar & s_vram;
ar & s_extra;
ar & cache_marker;
// TODO: How the hell to do page tables..
// ar & page_table_list;
@ -114,7 +107,7 @@ MemorySystem::~MemorySystem() = default;
template<class Archive>
void MemorySystem::serialize(Archive & ar, const unsigned int file_version)
{
ar & impl;
ar & *impl.get();
}
SERIALIZE_IMPL(MemorySystem)

View file

@ -32,6 +32,13 @@ public:
virtual void Write64(VAddr addr, u64 data) = 0;
virtual bool WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size) = 0;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
}
};
using MMIORegionPointer = std::shared_ptr<MMIORegion>;

View file

@ -161,8 +161,6 @@ struct State {
UnionArray<LutEntry, 128> lut;
} fog;
#undef SERIALIZE_RAW
/// Current Pica command list
struct {
PAddr addr; // This exists only for serialization
@ -185,7 +183,7 @@ struct State {
template<class Archive>
void serialize(Archive & ar, const unsigned int file_version)
{
// ar & input_vertex;
ar & input_vertex;
ar & current_attribute;
ar & reset_geometry_pipeline;
}
@ -220,7 +218,7 @@ private:
ar & regs.reg_array;
ar & vs;
ar & gs;
// ar & input_default_attributes;
ar & input_default_attributes;
ar & proctex;
ar & lighting.luts;
ar & fog.lut;

View file

@ -10,6 +10,7 @@
#include <type_traits>
#include <nihstro/shader_bytecode.h>
#include <boost/serialization/array.hpp>
#include <boost/serialization/base_object.hpp>
#include "common/assert.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
@ -32,6 +33,14 @@ using SwizzleData = std::array<u32, MAX_SWIZZLE_DATA_LENGTH>;
struct AttributeBuffer {
alignas(16) Common::Vec4<float24> attr[16];
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & attr;
}
};
/// Handler type for receiving vertex outputs from vertex shader or geometry shader
@ -91,6 +100,19 @@ struct GSEmitter {
GSEmitter();
~GSEmitter();
void Emit(Common::Vec4<float24> (&output_regs)[16]);
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & buffer;
ar & vertex_id;
ar & prim_emit;
ar & winding;
ar & output_mask;
// Handlers are ignored because they're constant
}
};
static_assert(std::is_standard_layout<GSEmitter>::value, "GSEmitter is not standard layout type");
@ -108,6 +130,16 @@ struct UnitState {
alignas(16) Common::Vec4<float24> input[16];
alignas(16) Common::Vec4<float24> temporary[16];
alignas(16) Common::Vec4<float24> output[16];
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & input;
ar & temporary;
ar & output;
}
} registers;
static_assert(std::is_pod<Registers>::value, "Structure is not POD");
@ -160,6 +192,17 @@ struct UnitState {
void LoadInput(const ShaderRegs& config, const AttributeBuffer& input);
void WriteOutput(const ShaderRegs& config, AttributeBuffer& output);
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & registers;
ar & conditional_code;
ar & address_registers;
// TODO: emitter_ptr
}
};
/**
@ -173,6 +216,15 @@ struct GSUnitState : public UnitState {
void ConfigOutput(const ShaderRegs& config);
GSEmitter emitter;
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<UnitState>(*this);
ar & emitter;
}
};
struct Uniforms {