diff options
| author | 2016-09-21 11:29:48 -0700 | |
|---|---|---|
| committer | 2016-09-21 11:29:48 -0700 | |
| commit | d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch) | |
| tree | 8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/video_core/gpu_debugger.h | |
| parent | README: Specify master branch for Travis CI badge (diff) | |
| parent | Fix Travis clang-format check (diff) | |
| download | yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip | |
Merge pull request #2086 from linkmauve/clang-format
Add clang-format as part of our {commit,travis}-time checks
Diffstat (limited to 'src/video_core/gpu_debugger.h')
| -rw-r--r-- | src/video_core/gpu_debugger.h | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h index a3aab216c..3c6636d66 100644 --- a/src/video_core/gpu_debugger.h +++ b/src/video_core/gpu_debugger.h | |||
| @@ -7,20 +7,16 @@ | |||
| 7 | #include <algorithm> | 7 | #include <algorithm> |
| 8 | #include <functional> | 8 | #include <functional> |
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | |||
| 11 | #include "core/hle/service/gsp_gpu.h" | 10 | #include "core/hle/service/gsp_gpu.h" |
| 12 | 11 | ||
| 13 | class GraphicsDebugger | 12 | class GraphicsDebugger { |
| 14 | { | ||
| 15 | public: | 13 | public: |
| 16 | // Base class for all objects which need to be notified about GPU events | 14 | // Base class for all objects which need to be notified about GPU events |
| 17 | class DebuggerObserver | 15 | class DebuggerObserver { |
| 18 | { | ||
| 19 | public: | 16 | public: |
| 20 | DebuggerObserver() : observed(nullptr) { } | 17 | DebuggerObserver() : observed(nullptr) {} |
| 21 | 18 | ||
| 22 | virtual ~DebuggerObserver() | 19 | virtual ~DebuggerObserver() { |
| 23 | { | ||
| 24 | if (observed) | 20 | if (observed) |
| 25 | observed->UnregisterObserver(this); | 21 | observed->UnregisterObserver(this); |
| 26 | } | 22 | } |
| @@ -31,15 +27,13 @@ public: | |||
| 31 | * @param total_command_count Total number of commands in the GX history | 27 | * @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 | 28 | * @note All methods in this class are called from the GSP thread |
| 33 | */ | 29 | */ |
| 34 | virtual void GXCommandProcessed(int total_command_count) | 30 | virtual void GXCommandProcessed(int total_command_count) { |
| 35 | { | 31 | 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()); | 32 | LOG_TRACE(Debug_GPU, "Received command: id=%x", (int)cmd.id.Value()); |
| 38 | } | 33 | } |
| 39 | 34 | ||
| 40 | protected: | 35 | protected: |
| 41 | const GraphicsDebugger* GetDebugger() const | 36 | const GraphicsDebugger* GetDebugger() const { |
| 42 | { | ||
| 43 | return observed; | 37 | return observed; |
| 44 | } | 38 | } |
| 45 | 39 | ||
| @@ -49,8 +43,7 @@ public: | |||
| 49 | friend class GraphicsDebugger; | 43 | friend class GraphicsDebugger; |
| 50 | }; | 44 | }; |
| 51 | 45 | ||
| 52 | void GXCommandProcessed(u8* command_data) | 46 | void GXCommandProcessed(u8* command_data) { |
| 53 | { | ||
| 54 | if (observers.empty()) | 47 | if (observers.empty()) |
| 55 | return; | 48 | return; |
| 56 | 49 | ||
| @@ -60,33 +53,29 @@ public: | |||
| 60 | memcpy(&cmd, command_data, sizeof(GSP_GPU::Command)); | 53 | memcpy(&cmd, command_data, sizeof(GSP_GPU::Command)); |
| 61 | 54 | ||
| 62 | ForEachObserver([this](DebuggerObserver* observer) { | 55 | ForEachObserver([this](DebuggerObserver* observer) { |
| 63 | observer->GXCommandProcessed(static_cast<int>(this->gx_command_history.size())); | 56 | observer->GXCommandProcessed(static_cast<int>(this->gx_command_history.size())); |
| 64 | } ); | 57 | }); |
| 65 | } | 58 | } |
| 66 | 59 | ||
| 67 | const GSP_GPU::Command& ReadGXCommandHistory(int index) const | 60 | const GSP_GPU::Command& ReadGXCommandHistory(int index) const { |
| 68 | { | ||
| 69 | // TODO: Is this thread-safe? | 61 | // TODO: Is this thread-safe? |
| 70 | return gx_command_history[index]; | 62 | return gx_command_history[index]; |
| 71 | } | 63 | } |
| 72 | 64 | ||
| 73 | void RegisterObserver(DebuggerObserver* observer) | 65 | void RegisterObserver(DebuggerObserver* observer) { |
| 74 | { | ||
| 75 | // TODO: Check for duplicates | 66 | // TODO: Check for duplicates |
| 76 | observers.push_back(observer); | 67 | observers.push_back(observer); |
| 77 | observer->observed = this; | 68 | observer->observed = this; |
| 78 | } | 69 | } |
| 79 | 70 | ||
| 80 | void UnregisterObserver(DebuggerObserver* observer) | 71 | void UnregisterObserver(DebuggerObserver* observer) { |
| 81 | { | ||
| 82 | observers.erase(std::remove(observers.begin(), observers.end(), observer), observers.end()); | 72 | observers.erase(std::remove(observers.begin(), observers.end(), observer), observers.end()); |
| 83 | observer->observed = nullptr; | 73 | observer->observed = nullptr; |
| 84 | } | 74 | } |
| 85 | 75 | ||
| 86 | private: | 76 | private: |
| 87 | void ForEachObserver(std::function<void (DebuggerObserver*)> func) | 77 | void ForEachObserver(std::function<void(DebuggerObserver*)> func) { |
| 88 | { | 78 | std::for_each(observers.begin(), observers.end(), func); |
| 89 | std::for_each(observers.begin(),observers.end(), func); | ||
| 90 | } | 79 | } |
| 91 | 80 | ||
| 92 | std::vector<DebuggerObserver*> observers; | 81 | std::vector<DebuggerObserver*> observers; |