Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jun 3, 2021
1 parent 40dcbf8 commit 7592ca3
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 236 deletions.
99 changes: 0 additions & 99 deletions rpcs3/Emu/RSX/Capture/rsx_replay.h
Expand Up @@ -19,12 +19,6 @@ namespace rsx
struct memory_block_data
{
std::vector<u8> data{};

template<typename Archive>
void serialize(Archive& ar)
{
ar(data);
}
};

// simple block to hold ps3 address and data
Expand All @@ -33,14 +27,6 @@ namespace rsx
u32 offset; // Offset in rsx address space
u32 location; // rsx memory location of the block
u64 data_state;

template<typename Archive>
void serialize(Archive & ar)
{
ar(offset);
ar(location);
ar(data_state);
}
};

struct replay_command
Expand All @@ -49,15 +35,6 @@ namespace rsx
std::unordered_set<u64> memory_state{}; // index into memory_map for the various memory blocks that need applying before this command can run
u64 tile_state{0}; // tile state for this command
u64 display_buffer_state{0};

template<typename Archive>
void serialize(Archive & ar)
{
ar(rsx_command);
ar(memory_state);
ar(tile_state);
ar(display_buffer_state);
}
};

struct tile_info
Expand All @@ -66,15 +43,6 @@ namespace rsx
u32 limit;
u32 pitch;
u32 format;

template<typename Archive>
void serialize(Archive & ar)
{
ar(tile);
ar(limit);
ar(pitch);
ar(format);
}
};

struct zcull_info
Expand All @@ -85,31 +53,13 @@ namespace rsx
u32 offset;
u32 status0;
u32 status1;

template<typename Archive>
void serialize(Archive & ar)
{
ar(region);
ar(size);
ar(start);
ar(offset);
ar(status0);
ar(status1);
}
};

// bleh, may need to break these out, might be unnecessary to do both always
struct tile_state
{
tile_info tiles[15]{};
zcull_info zculls[8]{};

template<typename Archive>
void serialize(Archive & ar)
{
ar(tiles);
ar(zculls);
}
};

struct buffer_state
Expand All @@ -118,28 +68,12 @@ namespace rsx
u32 height{0};
u32 pitch{0};
u32 offset{0};

template<typename Archive>
void serialize(Archive & ar)
{
ar(width);
ar(height);
ar(pitch);
ar(offset);
}
};

struct display_buffers_state
{
std::array<buffer_state, 8> buffers{};
u32 count{0};

template<typename Archive>
void serialize(Archive & ar)
{
ar(buffers);
ar(count);
}
};

u32 magic = FRAME_CAPTURE_MAGIC;
Expand All @@ -158,39 +92,6 @@ namespace rsx
// Initial registers state at the beginning of the capture
rsx::rsx_state reg_state;

template<typename Archive>
void serialize(Archive & ar)
{
ar(magic);

// Check if deserializing
if constexpr (std::is_same_v<std::invoke_result_t<Archive>, bool>)
{
if (magic != FRAME_CAPTURE_MAGIC)
{
// Failure
return;
}
}

ar(version);

if constexpr (std::is_same_v<std::invoke_result_t<Archive>, bool>)
{
if (version != FRAME_CAPTURE_VERSION)
{
return;
}
}

ar(tile_map);
ar(memory_map);
ar(memory_data_map);
ar(display_buffers_map);
ar(replay_commands);
ar(reg_state);
}

void reset()
{
magic = FRAME_CAPTURE_MAGIC;
Expand Down
46 changes: 46 additions & 0 deletions rpcs3/Emu/RSX/RSXThread.cpp
Expand Up @@ -39,6 +39,52 @@ rsx::frame_capture_data frame_capture;
extern CellGcmOffsetTable offsetTable;
extern thread_local std::string(*g_tls_log_prefix)();

template <>
bool utils::serial::op(rsx::rsx_state& obj)
{
operator()(obj.transform_program,
// obj.transform_constants,
obj.registers
);

return operator bool();
}

template <>
bool utils::serial::op(rsx::frame_capture_data& obj)
{
operator()(obj.magic, obj.version);

// Check if deserializing
if (!is_writing())
{
if (obj.magic != rsx::FRAME_CAPTURE_MAGIC || obj.version != rsx::FRAME_CAPTURE_VERSION)
{
// Failure
return false;
}
}

operator()(obj.tile_map, obj.memory_map, obj.memory_data_map, obj.display_buffers_map, obj.replay_commands, obj.reg_state);
return operator bool();
}

template <>
bool utils::serial::op(rsx::frame_capture_data::memory_block_data& obj)
{
operator()(obj.data);

return operator bool();
}

template <>
bool utils::serial::op(rsx::frame_capture_data::replay_command& obj)
{
operator()(obj.rsx_command, obj.memory_state, obj.tile_state, obj.display_buffer_state);

return operator bool();
}

namespace rsx
{
std::function<bool(u32 addr, bool is_writing)> g_access_violation_handler;
Expand Down
9 changes: 0 additions & 9 deletions rpcs3/Emu/RSX/rsx_methods.h
Expand Up @@ -554,15 +554,6 @@ namespace rsx

void init();

template<typename Archive>
void serialize(Archive & ar)
{
ar(transform_program,
// transform_constants,
registers
);
}

u16 viewport_width() const
{
return decode<NV4097_SET_VIEWPORT_HORIZONTAL>().width();
Expand Down
4 changes: 3 additions & 1 deletion rpcs3/Emu/System.cpp
Expand Up @@ -380,7 +380,9 @@ bool Emulator::BootRsxCapture(const std::string& path)
}

std::unique_ptr<rsx::frame_capture_data> frame = std::make_unique<rsx::frame_capture_data>();
utils::deserial load_manager{ in_file.to_vector<u8>() };
utils::serial load_manager;
load_manager.set_reading_state(in_file.to_vector<u8>());

load_manager(*frame);
in_file.close();

Expand Down

0 comments on commit 7592ca3

Please sign in to comment.