diff options
Diffstat (limited to 'src/video_core/gpu_debugger.h')
| -rw-r--r-- | src/video_core/gpu_debugger.h | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h deleted file mode 100644 index c1f9b43c2..000000000 --- a/src/video_core/gpu_debugger.h +++ /dev/null | |||
| @@ -1,85 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <algorithm> | ||
| 8 | #include <functional> | ||
| 9 | #include <vector> | ||
| 10 | #include "core/hle/service/gsp_gpu.h" | ||
| 11 | |||
| 12 | class GraphicsDebugger { | ||
| 13 | public: | ||
| 14 | // Base class for all objects which need to be notified about GPU events | ||
| 15 | class DebuggerObserver { | ||
| 16 | public: | ||
| 17 | DebuggerObserver() : observed(nullptr) {} | ||
| 18 | |||
| 19 | virtual ~DebuggerObserver() { | ||
| 20 | if (observed) | ||
| 21 | observed->UnregisterObserver(this); | ||
| 22 | } | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Called when a GX command has been processed and is ready for being | ||
| 26 | * read via GraphicsDebugger::ReadGXCommandHistory. | ||
| 27 | * @param total_command_count Total number of commands in the GX history | ||
| 28 | * @note All methods in this class are called from the GSP thread | ||
| 29 | */ | ||
| 30 | virtual void GXCommandProcessed(int total_command_count) { | ||
| 31 | const Service::GSP::Command& cmd = | ||
| 32 | observed->ReadGXCommandHistory(total_command_count - 1); | ||
| 33 | LOG_TRACE(Debug_GPU, "Received command: id=%x", (int)cmd.id.Value()); | ||
| 34 | } | ||
| 35 | |||
| 36 | protected: | ||
| 37 | const GraphicsDebugger* GetDebugger() const { | ||
| 38 | return observed; | ||
| 39 | } | ||
| 40 | |||
| 41 | private: | ||
| 42 | GraphicsDebugger* observed; | ||
| 43 | |||
| 44 | friend class GraphicsDebugger; | ||
| 45 | }; | ||
| 46 | |||
| 47 | void GXCommandProcessed(u8* command_data) { | ||
| 48 | if (observers.empty()) | ||
| 49 | return; | ||
| 50 | |||
| 51 | gx_command_history.emplace_back(); | ||
| 52 | Service::GSP::Command& cmd = gx_command_history.back(); | ||
| 53 | |||
| 54 | memcpy(&cmd, command_data, sizeof(Service::GSP::Command)); | ||
| 55 | |||
| 56 | ForEachObserver([this](DebuggerObserver* observer) { | ||
| 57 | observer->GXCommandProcessed(static_cast<int>(this->gx_command_history.size())); | ||
| 58 | }); | ||
| 59 | } | ||
| 60 | |||
| 61 | const Service::GSP::Command& ReadGXCommandHistory(int index) const { | ||
| 62 | // TODO: Is this thread-safe? | ||
| 63 | return gx_command_history[index]; | ||
| 64 | } | ||
| 65 | |||
| 66 | void RegisterObserver(DebuggerObserver* observer) { | ||
| 67 | // TODO: Check for duplicates | ||
| 68 | observers.push_back(observer); | ||
| 69 | observer->observed = this; | ||
| 70 | } | ||
| 71 | |||
| 72 | void UnregisterObserver(DebuggerObserver* observer) { | ||
| 73 | observers.erase(std::remove(observers.begin(), observers.end(), observer), observers.end()); | ||
| 74 | observer->observed = nullptr; | ||
| 75 | } | ||
| 76 | |||
| 77 | private: | ||
| 78 | void ForEachObserver(std::function<void(DebuggerObserver*)> func) { | ||
| 79 | std::for_each(observers.begin(), observers.end(), func); | ||
| 80 | } | ||
| 81 | |||
| 82 | std::vector<DebuggerObserver*> observers; | ||
| 83 | |||
| 84 | std::vector<Service::GSP::Command> gx_command_history; | ||
| 85 | }; | ||