diff options
| author | 2014-05-17 22:34:55 +0200 | |
|---|---|---|
| committer | 2014-06-12 06:10:48 -0400 | |
| commit | 31666632caf9e5f0eea8d8d839e7120e38be97f9 (patch) | |
| tree | a4cd919f52ff5ee64b3337c1cb3f7c01dd330ef9 /src | |
| parent | GSP: Define more GX commands. (diff) | |
| download | yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar.gz yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar.xz yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.zip | |
Add initial graphics debugger interface.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/gsp.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_debugger.h | 97 | ||||
| -rw-r--r-- | src/video_core/video_core.vcxproj | 5 | ||||
| -rw-r--r-- | src/video_core/video_core.vcxproj.filters | 3 |
4 files changed, 108 insertions, 3 deletions
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp index 3dda4c934..a42759053 100644 --- a/src/core/hle/service/gsp.cpp +++ b/src/core/hle/service/gsp.cpp | |||
| @@ -16,6 +16,9 @@ | |||
| 16 | 16 | ||
| 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 18 | 18 | ||
| 19 | // Main graphics debugger object - TODO: Here is probably not the best place for this | ||
| 20 | GraphicsDebugger g_debugger; | ||
| 21 | |||
| 19 | /// GSP shared memory GX command buffer header | 22 | /// GSP shared memory GX command buffer header |
| 20 | union GX_CmdBufferHeader { | 23 | union GX_CmdBufferHeader { |
| 21 | u32 hex; | 24 | u32 hex; |
| @@ -45,6 +48,9 @@ static inline u8* GX_GetCmdBufferPointer(u32 thread_id, u32 offset=0) { | |||
| 45 | /// Finishes execution of a GSP command | 48 | /// Finishes execution of a GSP command |
| 46 | void GX_FinishCommand(u32 thread_id) { | 49 | void GX_FinishCommand(u32 thread_id) { |
| 47 | GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id); | 50 | GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id); |
| 51 | |||
| 52 | g_debugger.GXCommandProcessed(GX_GetCmdBufferPointer(thread_id, 0x20 + (header->index * 0x20))); | ||
| 53 | |||
| 48 | header->number_commands = header->number_commands - 1; | 54 | header->number_commands = header->number_commands - 1; |
| 49 | // TODO: Increment header->index? | 55 | // TODO: Increment header->index? |
| 50 | } | 56 | } |
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h new file mode 100644 index 000000000..ace9de95f --- /dev/null +++ b/src/video_core/gpu_debugger.h | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <algorithm> | ||
| 8 | #include <functional> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | #include "common/log.h" | ||
| 12 | |||
| 13 | #include "core/hle/service/gsp.h" | ||
| 14 | |||
| 15 | |||
| 16 | class GraphicsDebugger | ||
| 17 | { | ||
| 18 | public: | ||
| 19 | // Base class for all objects which need to be notified about GPU events | ||
| 20 | class DebuggerObserver | ||
| 21 | { | ||
| 22 | public: | ||
| 23 | DebuggerObserver() : observed(nullptr) { } | ||
| 24 | |||
| 25 | virtual ~DebuggerObserver() | ||
| 26 | { | ||
| 27 | if (observed) | ||
| 28 | observed->UnregisterObserver(this); | ||
| 29 | } | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Called when a GX command has been processed and is ready for being | ||
| 33 | * read via GraphicsDebugger::ReadGXCommandHistory. | ||
| 34 | * @param total_command_count Total number of commands in the GX history | ||
| 35 | * @note All methods in this class are called from the GSP thread | ||
| 36 | */ | ||
| 37 | virtual void GXCommandProcessed(int total_command_count) | ||
| 38 | { | ||
| 39 | const GSP_GPU::GXCommand& cmd = observed->ReadGXCommandHistory(total_command_count-1); | ||
| 40 | ERROR_LOG(GSP, "Received command: id=%x", cmd.id); | ||
| 41 | } | ||
| 42 | |||
| 43 | protected: | ||
| 44 | GraphicsDebugger* GetDebugger() | ||
| 45 | { | ||
| 46 | return observed; | ||
| 47 | } | ||
| 48 | |||
| 49 | private: | ||
| 50 | GraphicsDebugger* observed; | ||
| 51 | bool in_destruction; | ||
| 52 | |||
| 53 | friend class GraphicsDebugger; | ||
| 54 | }; | ||
| 55 | |||
| 56 | void GXCommandProcessed(u8* command_data) | ||
| 57 | { | ||
| 58 | gx_command_history.push_back(GSP_GPU::GXCommand()); | ||
| 59 | GSP_GPU::GXCommand& cmd = gx_command_history[gx_command_history.size()-1]; | ||
| 60 | |||
| 61 | const int cmd_length = sizeof(GSP_GPU::GXCommand); | ||
| 62 | memcpy(cmd.data, command_data, cmd_length); | ||
| 63 | |||
| 64 | ForEachObserver([this](DebuggerObserver* observer) { | ||
| 65 | observer->GXCommandProcessed(this->gx_command_history.size()); | ||
| 66 | } ); | ||
| 67 | } | ||
| 68 | |||
| 69 | const GSP_GPU::GXCommand& ReadGXCommandHistory(int index) const | ||
| 70 | { | ||
| 71 | // TODO: Is this thread-safe? | ||
| 72 | return gx_command_history[index]; | ||
| 73 | } | ||
| 74 | |||
| 75 | void RegisterObserver(DebuggerObserver* observer) | ||
| 76 | { | ||
| 77 | // TODO: Check for duplicates | ||
| 78 | observers.push_back(observer); | ||
| 79 | observer->observed = this; | ||
| 80 | } | ||
| 81 | |||
| 82 | void UnregisterObserver(DebuggerObserver* observer) | ||
| 83 | { | ||
| 84 | std::remove(observers.begin(), observers.end(), observer); | ||
| 85 | observer->observed = nullptr; | ||
| 86 | } | ||
| 87 | |||
| 88 | private: | ||
| 89 | void ForEachObserver(std::function<void (DebuggerObserver*)> func) | ||
| 90 | { | ||
| 91 | std::for_each(observers.begin(),observers.end(), func); | ||
| 92 | } | ||
| 93 | |||
| 94 | std::vector<DebuggerObserver*> observers; | ||
| 95 | |||
| 96 | std::vector<GSP_GPU::GXCommand> gx_command_history; | ||
| 97 | }; | ||
diff --git a/src/video_core/video_core.vcxproj b/src/video_core/video_core.vcxproj index d8c53271e..a4df92386 100644 --- a/src/video_core/video_core.vcxproj +++ b/src/video_core/video_core.vcxproj | |||
| @@ -24,10 +24,11 @@ | |||
| 24 | <ClCompile Include="video_core.cpp" /> | 24 | <ClCompile Include="video_core.cpp" /> |
| 25 | </ItemGroup> | 25 | </ItemGroup> |
| 26 | <ItemGroup> | 26 | <ItemGroup> |
| 27 | <ClInclude Include="gpu_debugger.h" /> | ||
| 27 | <ClInclude Include="renderer_base.h" /> | 28 | <ClInclude Include="renderer_base.h" /> |
| 28 | <ClInclude Include="renderer_opengl\renderer_opengl.h" /> | ||
| 29 | <ClInclude Include="utils.h" /> | 29 | <ClInclude Include="utils.h" /> |
| 30 | <ClInclude Include="video_core.h" /> | 30 | <ClInclude Include="video_core.h" /> |
| 31 | <ClInclude Include="renderer_opengl\renderer_opengl.h" /> | ||
| 31 | </ItemGroup> | 32 | </ItemGroup> |
| 32 | <ItemGroup> | 33 | <ItemGroup> |
| 33 | <Text Include="CMakeLists.txt" /> | 34 | <Text Include="CMakeLists.txt" /> |
| @@ -128,4 +129,4 @@ | |||
| 128 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | 129 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
| 129 | <ImportGroup Label="ExtensionTargets"> | 130 | <ImportGroup Label="ExtensionTargets"> |
| 130 | </ImportGroup> | 131 | </ImportGroup> |
| 131 | </Project> \ No newline at end of file | 132 | </Project> |
diff --git a/src/video_core/video_core.vcxproj.filters b/src/video_core/video_core.vcxproj.filters index 4eb2ef0a4..cc173a718 100644 --- a/src/video_core/video_core.vcxproj.filters +++ b/src/video_core/video_core.vcxproj.filters | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | <ClInclude Include="renderer_opengl\renderer_opengl.h"> | 16 | <ClInclude Include="renderer_opengl\renderer_opengl.h"> |
| 17 | <Filter>renderer_opengl</Filter> | 17 | <Filter>renderer_opengl</Filter> |
| 18 | </ClInclude> | 18 | </ClInclude> |
| 19 | <ClInclude Include="gpu_debugger.h" /> | ||
| 19 | <ClInclude Include="renderer_base.h" /> | 20 | <ClInclude Include="renderer_base.h" /> |
| 20 | <ClInclude Include="utils.h" /> | 21 | <ClInclude Include="utils.h" /> |
| 21 | <ClInclude Include="video_core.h" /> | 22 | <ClInclude Include="video_core.h" /> |
| @@ -23,4 +24,4 @@ | |||
| 23 | <ItemGroup> | 24 | <ItemGroup> |
| 24 | <Text Include="CMakeLists.txt" /> | 25 | <Text Include="CMakeLists.txt" /> |
| 25 | </ItemGroup> | 26 | </ItemGroup> |
| 26 | </Project> \ No newline at end of file | 27 | </Project> |