summaryrefslogtreecommitdiff
path: root/src/video_core/gpu_debugger.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/gpu_debugger.h')
-rw-r--r--src/video_core/gpu_debugger.h63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h
index 2ba873457..5a81fcfcb 100644
--- a/src/video_core/gpu_debugger.h
+++ b/src/video_core/gpu_debugger.h
@@ -18,19 +18,6 @@
18class GraphicsDebugger 18class GraphicsDebugger
19{ 19{
20public: 20public:
21 // A few utility structs used to expose data
22 // A vector of commands represented by their raw byte sequence
23 struct PicaCommand : public std::vector<u32>
24 {
25 const Pica::CommandProcessor::CommandHeader& GetHeader() const
26 {
27 const u32& val = at(1);
28 return *(Pica::CommandProcessor::CommandHeader*)&val;
29 }
30 };
31
32 typedef std::vector<PicaCommand> PicaCommandList;
33
34 // Base class for all objects which need to be notified about GPU events 21 // Base class for all objects which need to be notified about GPU events
35 class DebuggerObserver 22 class DebuggerObserver
36 { 23 {
@@ -55,16 +42,6 @@ public:
55 ERROR_LOG(GSP, "Received command: id=%x", (int)cmd.id.Value()); 42 ERROR_LOG(GSP, "Received command: id=%x", (int)cmd.id.Value());
56 } 43 }
57 44
58 /**
59 * @param lst command list which triggered this call
60 * @param is_new true if the command list was called for the first time
61 * @todo figure out how to make sure called functions don't keep references around beyond their life time
62 */
63 virtual void OnCommandListCalled(const PicaCommandList& lst, bool is_new)
64 {
65 ERROR_LOG(GSP, "Command list called: %d", (int)is_new);
66 }
67
68 protected: 45 protected:
69 const GraphicsDebugger* GetDebugger() const 46 const GraphicsDebugger* GetDebugger() const
70 { 47 {
@@ -93,49 +70,12 @@ public:
93 } ); 70 } );
94 } 71 }
95 72
96 void CommandListCalled(u32 address, u32* command_list, u32 size_in_words)
97 {
98 if (observers.empty())
99 return;
100
101 PicaCommandList cmdlist;
102 for (u32* parse_pointer = command_list; parse_pointer < command_list + size_in_words;)
103 {
104 const Pica::CommandProcessor::CommandHeader& header = *(Pica::CommandProcessor::CommandHeader*)(&parse_pointer[1]);
105
106 cmdlist.push_back(PicaCommand());
107 auto& cmd = cmdlist.back();
108
109 size_t size = 2 + header.extra_data_length;
110 size = (size + 1) / 2 * 2; // align to 8 bytes
111 cmd.reserve(size);
112 std::copy(parse_pointer, parse_pointer + size, std::back_inserter(cmd));
113
114 parse_pointer += size;
115 }
116
117 auto obj = std::pair<u32,PicaCommandList>(address, cmdlist);
118 auto it = std::find(command_lists.begin(), command_lists.end(), obj);
119 bool is_new = (it == command_lists.end());
120 if (is_new)
121 command_lists.push_back(obj);
122
123 ForEachObserver([&](DebuggerObserver* observer) {
124 observer->OnCommandListCalled(obj.second, is_new);
125 } );
126 }
127
128 const GSP_GPU::Command& ReadGXCommandHistory(int index) const 73 const GSP_GPU::Command& ReadGXCommandHistory(int index) const
129 { 74 {
130 // TODO: Is this thread-safe? 75 // TODO: Is this thread-safe?
131 return gx_command_history[index]; 76 return gx_command_history[index];
132 } 77 }
133 78
134 const std::vector<std::pair<u32,PicaCommandList>>& GetCommandLists() const
135 {
136 return command_lists;
137 }
138
139 void RegisterObserver(DebuggerObserver* observer) 79 void RegisterObserver(DebuggerObserver* observer)
140 { 80 {
141 // TODO: Check for duplicates 81 // TODO: Check for duplicates
@@ -158,7 +98,4 @@ private:
158 std::vector<DebuggerObserver*> observers; 98 std::vector<DebuggerObserver*> observers;
159 99
160 std::vector<GSP_GPU::Command> gx_command_history; 100 std::vector<GSP_GPU::Command> gx_command_history;
161
162 // vector of pairs of command lists and their storage address
163 std::vector<std::pair<u32,PicaCommandList>> command_lists;
164}; 101};