diff options
author | Tony Wasserka <NeoBrainX@gmail.com> | 2014-05-17 22:34:55 +0200 |
---|---|---|
committer | bunnei <ericbunnie@gmail.com> | 2014-06-12 12:10:48 +0200 |
commit | 31666632caf9e5f0eea8d8d839e7120e38be97f9 (patch) | |
tree | a4cd919f52ff5ee64b3337c1cb3f7c01dd330ef9 /src | |
parent | GSP: Define more GX commands. (diff) | |
download | yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar.gz yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar.bz2 yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar.lz yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar.xz yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.tar.zst yuzu-31666632caf9e5f0eea8d8d839e7120e38be97f9.zip |
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 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// +// Main graphics debugger object - TODO: Here is probably not the best place for this +GraphicsDebugger g_debugger; + /// GSP shared memory GX command buffer header union GX_CmdBufferHeader { u32 hex; @@ -45,6 +48,9 @@ static inline u8* GX_GetCmdBufferPointer(u32 thread_id, u32 offset=0) { /// Finishes execution of a GSP command void GX_FinishCommand(u32 thread_id) { GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id); + + g_debugger.GXCommandProcessed(GX_GetCmdBufferPointer(thread_id, 0x20 + (header->index * 0x20))); + header->number_commands = header->number_commands - 1; // TODO: Increment header->index? } 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 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include <algorithm> +#include <functional> +#include <vector> + +#include "common/log.h" + +#include "core/hle/service/gsp.h" + + +class GraphicsDebugger +{ +public: + // Base class for all objects which need to be notified about GPU events + class DebuggerObserver + { + public: + DebuggerObserver() : observed(nullptr) { } + + virtual ~DebuggerObserver() + { + if (observed) + observed->UnregisterObserver(this); + } + + /** + * Called when a GX command has been processed and is ready for being + * read via GraphicsDebugger::ReadGXCommandHistory. + * @param total_command_count Total number of commands in the GX history + * @note All methods in this class are called from the GSP thread + */ + virtual void GXCommandProcessed(int total_command_count) + { + const GSP_GPU::GXCommand& cmd = observed->ReadGXCommandHistory(total_command_count-1); + ERROR_LOG(GSP, "Received command: id=%x", cmd.id); + } + + protected: + GraphicsDebugger* GetDebugger() + { + return observed; + } + + private: + GraphicsDebugger* observed; + bool in_destruction; + + friend class GraphicsDebugger; + }; + + void GXCommandProcessed(u8* command_data) + { + gx_command_history.push_back(GSP_GPU::GXCommand()); + GSP_GPU::GXCommand& cmd = gx_command_history[gx_command_history.size()-1]; + + const int cmd_length = sizeof(GSP_GPU::GXCommand); + memcpy(cmd.data, command_data, cmd_length); + + ForEachObserver([this](DebuggerObserver* observer) { + observer->GXCommandProcessed(this->gx_command_history.size()); + } ); + } + + const GSP_GPU::GXCommand& ReadGXCommandHistory(int index) const + { + // TODO: Is this thread-safe? + return gx_command_history[index]; + } + + void RegisterObserver(DebuggerObserver* observer) + { + // TODO: Check for duplicates + observers.push_back(observer); + observer->observed = this; + } + + void UnregisterObserver(DebuggerObserver* observer) + { + std::remove(observers.begin(), observers.end(), observer); + observer->observed = nullptr; + } + +private: + void ForEachObserver(std::function<void (DebuggerObserver*)> func) + { + std::for_each(observers.begin(),observers.end(), func); + } + + std::vector<DebuggerObserver*> observers; + + std::vector<GSP_GPU::GXCommand> gx_command_history; +}; 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 @@ <ClCompile Include="video_core.cpp" /> </ItemGroup> <ItemGroup> + <ClInclude Include="gpu_debugger.h" /> <ClInclude Include="renderer_base.h" /> - <ClInclude Include="renderer_opengl\renderer_opengl.h" /> <ClInclude Include="utils.h" /> <ClInclude Include="video_core.h" /> + <ClInclude Include="renderer_opengl\renderer_opengl.h" /> </ItemGroup> <ItemGroup> <Text Include="CMakeLists.txt" /> @@ -128,4 +129,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project>
\ No newline at end of file +</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 @@ <ClInclude Include="renderer_opengl\renderer_opengl.h"> <Filter>renderer_opengl</Filter> </ClInclude> + <ClInclude Include="gpu_debugger.h" /> <ClInclude Include="renderer_base.h" /> <ClInclude Include="utils.h" /> <ClInclude Include="video_core.h" /> @@ -23,4 +24,4 @@ <ItemGroup> <Text Include="CMakeLists.txt" /> </ItemGroup> -</Project>
\ No newline at end of file +</Project> |