summaryrefslogtreecommitdiff
path: root/src/video_core/gpu_debugger.h
diff options
context:
space:
mode:
authorGravatar Tony Wasserka2014-05-18 17:28:30 +0200
committerGravatar bunnei2014-06-12 06:10:51 -0400
commit5d62f5d92a53d4bbec20069984f5a5c7fa73524a (patch)
treeb56a18443bc213248f28b4d1a14eedc61f02352e /src/video_core/gpu_debugger.h
parentvideo core: added PICA definitions file. (diff)
downloadyuzu-5d62f5d92a53d4bbec20069984f5a5c7fa73524a.tar.gz
yuzu-5d62f5d92a53d4bbec20069984f5a5c7fa73524a.tar.xz
yuzu-5d62f5d92a53d4bbec20069984f5a5c7fa73524a.zip
GPU debugger: Add functionality to inspect command lists.
Diffstat (limited to 'src/video_core/gpu_debugger.h')
-rw-r--r--src/video_core/gpu_debugger.h54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h
index ace9de95f..4dafd3146 100644
--- a/src/video_core/gpu_debugger.h
+++ b/src/video_core/gpu_debugger.h
@@ -11,11 +11,23 @@
11#include "common/log.h" 11#include "common/log.h"
12 12
13#include "core/hle/service/gsp.h" 13#include "core/hle/service/gsp.h"
14 14#include "pica.h"
15 15
16class GraphicsDebugger 16class GraphicsDebugger
17{ 17{
18public: 18public:
19 // A few utility structs used to expose data
20 // A vector of commands represented by their raw byte sequence
21 struct PicaCommand : public std::vector<u32>
22 {
23 Pica::CommandHeader& GetHeader()
24 {
25 return *(Pica::CommandHeader*)&(front());
26 }
27 };
28
29 typedef std::vector<PicaCommand> PicaCommandList;
30
19 // Base class for all objects which need to be notified about GPU events 31 // Base class for all objects which need to be notified about GPU events
20 class DebuggerObserver 32 class DebuggerObserver
21 { 33 {
@@ -40,6 +52,16 @@ public:
40 ERROR_LOG(GSP, "Received command: id=%x", cmd.id); 52 ERROR_LOG(GSP, "Received command: id=%x", cmd.id);
41 } 53 }
42 54
55 /**
56 * @param lst command list which triggered this call
57 * @param is_new true if the command list was called for the first time
58 * @todo figure out how to make sure called functions don't keep references around beyond their life time
59 */
60 virtual void CommandListCalled(const PicaCommandList& lst, bool is_new)
61 {
62 ERROR_LOG(GSP, "Command list called: %d", (int)is_new);
63 }
64
43 protected: 65 protected:
44 GraphicsDebugger* GetDebugger() 66 GraphicsDebugger* GetDebugger()
45 { 67 {
@@ -66,12 +88,39 @@ public:
66 } ); 88 } );
67 } 89 }
68 90
91 void CommandListCalled(u32 address, u32* command_list, u32 size_in_words)
92 {
93 // TODO: Decoding fun
94
95 // For now, just treating the whole command list as a single command
96 PicaCommandList cmdlist;
97 cmdlist.push_back(PicaCommand());
98 auto& cmd = cmdlist[0];
99 cmd.reserve(size_in_words);
100 std::copy(command_list, command_list+size_in_words, std::back_inserter(cmd));
101
102 auto obj = std::pair<u32,PicaCommandList>(address, cmdlist);
103 auto it = std::find(command_lists.begin(), command_lists.end(), obj);
104 bool is_new = (it == command_lists.end());
105 if (is_new)
106 command_lists.push_back(obj);
107
108 ForEachObserver([&](DebuggerObserver* observer) {
109 observer->CommandListCalled(obj.second, is_new);
110 } );
111 }
112
69 const GSP_GPU::GXCommand& ReadGXCommandHistory(int index) const 113 const GSP_GPU::GXCommand& ReadGXCommandHistory(int index) const
70 { 114 {
71 // TODO: Is this thread-safe? 115 // TODO: Is this thread-safe?
72 return gx_command_history[index]; 116 return gx_command_history[index];
73 } 117 }
74 118
119 const std::vector<std::pair<u32,PicaCommandList>>& GetCommandLists() const
120 {
121 return command_lists;
122 }
123
75 void RegisterObserver(DebuggerObserver* observer) 124 void RegisterObserver(DebuggerObserver* observer)
76 { 125 {
77 // TODO: Check for duplicates 126 // TODO: Check for duplicates
@@ -94,4 +143,7 @@ private:
94 std::vector<DebuggerObserver*> observers; 143 std::vector<DebuggerObserver*> observers;
95 144
96 std::vector<GSP_GPU::GXCommand> gx_command_history; 145 std::vector<GSP_GPU::GXCommand> gx_command_history;
146
147 // vector of pairs of command lists and their storage address
148 std::vector<std::pair<u32,PicaCommandList>> command_lists;
97}; 149};