diff options
author | Tony Wasserka <NeoBrainX@gmail.com> | 2014-08-14 19:21:55 +0200 |
---|---|---|
committer | Tony Wasserka <NeoBrainX@gmail.com> | 2014-08-25 22:03:18 +0200 |
commit | 26ade98411c1d76540695f15378ff7f6b5388b1a (patch) | |
tree | db1b6eba40bacdc049d4c3c668ee875b209c73ac /src/video_core/debug_utils | |
parent | Pica/CommandProcessor: Implement parameter masking. (diff) | |
download | yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.tar yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.tar.gz yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.tar.bz2 yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.tar.lz yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.tar.xz yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.tar.zst yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.zip |
Diffstat (limited to 'src/video_core/debug_utils')
-rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 55 | ||||
-rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 21 |
2 files changed, 76 insertions, 0 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index f41249eac..1bbc0330c 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -4,6 +4,7 @@ #include <algorithm> #include <fstream> +#include <mutex> #include <string> #include "video_core/pica.h" @@ -260,6 +261,60 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data } } +static std::unique_ptr<PicaTrace> pica_trace; +static std::mutex pica_trace_mutex; +static int is_pica_tracing = false; + +void StartPicaTracing() +{ + if (is_pica_tracing) { + ERROR_LOG(GPU, "StartPicaTracing called even though tracing already running!"); + return; + } + + pica_trace_mutex.lock(); + pica_trace = std::unique_ptr<PicaTrace>(new PicaTrace); + + is_pica_tracing = true; + pica_trace_mutex.unlock(); +} + +bool IsPicaTracing() +{ + return is_pica_tracing; +} + +void OnPicaRegWrite(u32 id, u32 value) +{ + // Double check for is_pica_tracing to avoid pointless locking overhead + if (!is_pica_tracing) + return; + + std::unique_lock<std::mutex> lock(pica_trace_mutex); + + if (!is_pica_tracing) + return; + + pica_trace->writes.push_back({id, value}); +} + +std::unique_ptr<PicaTrace> FinishPicaTracing() +{ + if (!is_pica_tracing) { + ERROR_LOG(GPU, "FinishPicaTracing called even though tracing already running!"); + return {}; + } + + // signalize that no further tracing should be performed + is_pica_tracing = false; + + // Wait until running tracing is finished + pica_trace_mutex.lock(); + std::unique_ptr<PicaTrace> ret(std::move(pica_trace)); + pica_trace_mutex.unlock(); + return std::move(ret); +} + } // namespace } // namespace diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index bd7a0a89b..023500066 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h @@ -5,6 +5,7 @@ #pragma once #include <array> +#include <memory> #include <vector> #include "video_core/pica.h" @@ -38,6 +39,26 @@ private: void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size, u32 main_offset, const Regs::VSOutputAttributes* output_attributes); + +// Utility class to log Pica commands. +struct PicaTrace { + struct Write : public std::pair<u32,u32> { + Write(u32 id, u32 value) : std::pair<u32,u32>(id, value) {} + + u32& Id() { return first; } + const u32& Id() const { return first; } + + u32& Value() { return second; } + const u32& Value() const { return second; } + }; + std::vector<Write> writes; +}; + +void StartPicaTracing(); +bool IsPicaTracing(); +void OnPicaRegWrite(u32 id, u32 value); +std::unique_ptr<PicaTrace> FinishPicaTracing(); + } // namespace } // namespace |