summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/gsp.cpp4
-rw-r--r--src/video_core/gpu_debugger.h54
2 files changed, 57 insertions, 1 deletions
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp
index 15e9d19a5..aabcb48db 100644
--- a/src/core/hle/service/gsp.cpp
+++ b/src/core/hle/service/gsp.cpp
@@ -126,6 +126,10 @@ void TriggerCmdReqQueue(Service::Interface* self) {
126 GPU::Write<u32>(GPU::Registers::CommandListAddress, cmd_buff[1] >> 3); 126 GPU::Write<u32>(GPU::Registers::CommandListAddress, cmd_buff[1] >> 3);
127 GPU::Write<u32>(GPU::Registers::CommandListSize, cmd_buff[2] >> 3); 127 GPU::Write<u32>(GPU::Registers::CommandListSize, cmd_buff[2] >> 3);
128 GPU::Write<u32>(GPU::Registers::ProcessCommandList, 1); // TODO: Not sure if we are supposed to always write this 128 GPU::Write<u32>(GPU::Registers::ProcessCommandList, 1); // TODO: Not sure if we are supposed to always write this
129
130 // TODO: Move this to GPU
131 // TODO: Not sure what units the size is measured in
132 g_debugger.CommandListCalled(cmd_buff[1], (u32*)Memory::GetPointer(cmd_buff[1]), cmd_buff[2]);
129 break; 133 break;
130 134
131 case GXCommandId::SET_MEMORY_FILL: 135 case GXCommandId::SET_MEMORY_FILL:
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};