summaryrefslogtreecommitdiff
path: root/src/video_core/gpu_debugger.h
diff options
context:
space:
mode:
authorGravatar Emmanuel Gil Peyrot2016-09-18 09:38:01 +0900
committerGravatar Emmanuel Gil Peyrot2016-09-18 09:38:01 +0900
commitdc8479928c5aee4c6ad6fe4f59006fb604cee701 (patch)
tree569a7f13128450bbab973236615587ff00bced5f /src/video_core/gpu_debugger.h
parentTravis: Import Dolphin’s clang-format hook. (diff)
downloadyuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.gz
yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.xz
yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.zip
Sources: Run clang-format on everything.
Diffstat (limited to 'src/video_core/gpu_debugger.h')
-rw-r--r--src/video_core/gpu_debugger.h41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h
index a3aab216c..e3ba80d8f 100644
--- a/src/video_core/gpu_debugger.h
+++ b/src/video_core/gpu_debugger.h
@@ -10,17 +10,15 @@
10 10
11#include "core/hle/service/gsp_gpu.h" 11#include "core/hle/service/gsp_gpu.h"
12 12
13class GraphicsDebugger 13class GraphicsDebugger {
14{
15public: 14public:
16 // Base class for all objects which need to be notified about GPU events 15 // Base class for all objects which need to be notified about GPU events
17 class DebuggerObserver 16 class DebuggerObserver {
18 {
19 public: 17 public:
20 DebuggerObserver() : observed(nullptr) { } 18 DebuggerObserver() : observed(nullptr) {
19 }
21 20
22 virtual ~DebuggerObserver() 21 virtual ~DebuggerObserver() {
23 {
24 if (observed) 22 if (observed)
25 observed->UnregisterObserver(this); 23 observed->UnregisterObserver(this);
26 } 24 }
@@ -31,15 +29,13 @@ public:
31 * @param total_command_count Total number of commands in the GX history 29 * @param total_command_count Total number of commands in the GX history
32 * @note All methods in this class are called from the GSP thread 30 * @note All methods in this class are called from the GSP thread
33 */ 31 */
34 virtual void GXCommandProcessed(int total_command_count) 32 virtual void GXCommandProcessed(int total_command_count) {
35 { 33 const GSP_GPU::Command& cmd = observed->ReadGXCommandHistory(total_command_count - 1);
36 const GSP_GPU::Command& cmd = observed->ReadGXCommandHistory(total_command_count-1);
37 LOG_TRACE(Debug_GPU, "Received command: id=%x", (int)cmd.id.Value()); 34 LOG_TRACE(Debug_GPU, "Received command: id=%x", (int)cmd.id.Value());
38 } 35 }
39 36
40 protected: 37 protected:
41 const GraphicsDebugger* GetDebugger() const 38 const GraphicsDebugger* GetDebugger() const {
42 {
43 return observed; 39 return observed;
44 } 40 }
45 41
@@ -49,8 +45,7 @@ public:
49 friend class GraphicsDebugger; 45 friend class GraphicsDebugger;
50 }; 46 };
51 47
52 void GXCommandProcessed(u8* command_data) 48 void GXCommandProcessed(u8* command_data) {
53 {
54 if (observers.empty()) 49 if (observers.empty())
55 return; 50 return;
56 51
@@ -60,33 +55,29 @@ public:
60 memcpy(&cmd, command_data, sizeof(GSP_GPU::Command)); 55 memcpy(&cmd, command_data, sizeof(GSP_GPU::Command));
61 56
62 ForEachObserver([this](DebuggerObserver* observer) { 57 ForEachObserver([this](DebuggerObserver* observer) {
63 observer->GXCommandProcessed(static_cast<int>(this->gx_command_history.size())); 58 observer->GXCommandProcessed(static_cast<int>(this->gx_command_history.size()));
64 } ); 59 });
65 } 60 }
66 61
67 const GSP_GPU::Command& ReadGXCommandHistory(int index) const 62 const GSP_GPU::Command& ReadGXCommandHistory(int index) const {
68 {
69 // TODO: Is this thread-safe? 63 // TODO: Is this thread-safe?
70 return gx_command_history[index]; 64 return gx_command_history[index];
71 } 65 }
72 66
73 void RegisterObserver(DebuggerObserver* observer) 67 void RegisterObserver(DebuggerObserver* observer) {
74 {
75 // TODO: Check for duplicates 68 // TODO: Check for duplicates
76 observers.push_back(observer); 69 observers.push_back(observer);
77 observer->observed = this; 70 observer->observed = this;
78 } 71 }
79 72
80 void UnregisterObserver(DebuggerObserver* observer) 73 void UnregisterObserver(DebuggerObserver* observer) {
81 {
82 observers.erase(std::remove(observers.begin(), observers.end(), observer), observers.end()); 74 observers.erase(std::remove(observers.begin(), observers.end(), observer), observers.end());
83 observer->observed = nullptr; 75 observer->observed = nullptr;
84 } 76 }
85 77
86private: 78private:
87 void ForEachObserver(std::function<void (DebuggerObserver*)> func) 79 void ForEachObserver(std::function<void(DebuggerObserver*)> func) {
88 { 80 std::for_each(observers.begin(), observers.end(), func);
89 std::for_each(observers.begin(),observers.end(), func);
90 } 81 }
91 82
92 std::vector<DebuggerObserver*> observers; 83 std::vector<DebuggerObserver*> observers;