-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathreplayer_driver.hpp
121 lines (106 loc) · 4.4 KB
/
replayer_driver.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* Copyright (c) 2020 Themaister
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <memory>
#include "rdp_dump.hpp"
namespace Vulkan
{
class Device;
}
namespace RDP
{
enum class MessageType
{
Info,
Warn,
Error
};
static inline const char *command_name(Op cmd_id)
{
auto index = unsigned(cmd_id);
static const char *names[64] = {
/* 0x00 */ "NOP", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/* 0x08 */ "TRI", "ZBUF_TRI", "TEX_TRI", "TEX_Z_TRI", "SHADE_TRI", "SHADE_Z_TRI", "SHADE_TEX_TRI", "SHADE_TEX_Z_TRI",
/* 0x10 */ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/* 0x18 */ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/* 0x20 */ nullptr, nullptr, nullptr, nullptr, "TEX_RECT", "TEX_RECT_FLIP", "SYNC_LOAD", "SYNC_PIPE",
/* 0x28 */ "SYNC_TILE", "SYNC_FULL", "SET_KEY_GB", "SET_KEY_R", "SET_CONVERT", "SET_SCISSOR", "SET_PRIM_DEPTH", "SET_OTHER",
/* 0x30 */ "LOAD_TLUT", nullptr, "SET_TILE_SIZE", "LOAD_BLOCK", "LOAD_TILE", "SET_TILE", "FILL_RECT", "SET_FILL_COLOR",
/* 0x38 */ "SET_FOG_COLOR", "SET_BLEND_COLOR", "SET_PRIM_COLOR", "SET_ENV_COLOR", "SET_COMBINE", "SET_TEX_IMAGE", "SET_MASK_IMAGE", "SET_COLOR_IMAGE",
};
if (index < 64 && names[index])
return names[index];
else
return "???";
}
class ReplayerDriver : public CommandListenerInterface
{
public:
virtual ~ReplayerDriver() = default;
virtual uint8_t *get_rdram() = 0;
virtual size_t get_rdram_size() = 0;
virtual uint8_t *get_hidden_rdram() = 0;
virtual size_t get_hidden_rdram_size() = 0;
virtual uint8_t *get_tmem() = 0;
virtual void idle() = 0;
virtual void flush_caches() = 0;
virtual void invalidate_caches() = 0;
virtual void begin_vi_register_per_scanline() = 0;
virtual void set_vi_register_for_scanline(unsigned vi_line, uint32_t h_start, uint32_t x_scale) = 0;
virtual void end_vi_register_per_scanline() = 0;
virtual void set_crop_rect(unsigned left, unsigned right, unsigned top, unsigned bottom) = 0;
};
static inline bool command_is_draw_call(Op cmd_id)
{
switch (cmd_id)
{
case Op::FillTriangle:
case Op::TextureZBufferTriangle:
case Op::TextureTriangle:
case Op::FillZBufferTriangle:
case Op::ShadeTriangle:
case Op::ShadeZBufferTriangle:
case Op::ShadeTextureTriangle:
case Op::ShadeTextureZBufferTriangle:
case Op::TextureRectangle:
case Op::TextureRectangleFlip:
case Op::FillRectangle:
return true;
default:
return false;
}
}
struct ReplayerEventInterface
{
virtual void update_screen(const void *data, unsigned width, unsigned height, unsigned row_length) = 0;
virtual void notify_command(Op cmd_id, uint32_t num_words, const uint32_t *words) = 0;
virtual void message(MessageType type, const char *msg) = 0;
virtual void eof() = 0;
virtual void set_context_index(unsigned index) = 0;
virtual void signal_complete() = 0;
};
std::unique_ptr<ReplayerDriver> create_replayer_driver_angrylion(CommandInterface &player, ReplayerEventInterface &iface);
std::unique_ptr<ReplayerDriver> create_replayer_driver_parallel(Vulkan::Device &device, CommandInterface &player, ReplayerEventInterface &iface,
bool benchmarking = false,
bool upscale = false);
std::unique_ptr<ReplayerDriver> create_side_by_side_driver(ReplayerDriver *first, ReplayerDriver *second, ReplayerEventInterface &iface);
}