diff options
| author | 2014-08-14 19:21:55 +0200 | |
|---|---|---|
| committer | 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.gz yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.tar.xz yuzu-26ade98411c1d76540695f15378ff7f6b5388b1a.zip | |
Pica/citra-qt: Replace command list view and command list debugging code with something more sophisticated.
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 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <fstream> | 6 | #include <fstream> |
| 7 | #include <mutex> | ||
| 7 | #include <string> | 8 | #include <string> |
| 8 | 9 | ||
| 9 | #include "video_core/pica.h" | 10 | #include "video_core/pica.h" |
| @@ -260,6 +261,60 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data | |||
| 260 | } | 261 | } |
| 261 | } | 262 | } |
| 262 | 263 | ||
| 264 | static std::unique_ptr<PicaTrace> pica_trace; | ||
| 265 | static std::mutex pica_trace_mutex; | ||
| 266 | static int is_pica_tracing = false; | ||
| 267 | |||
| 268 | void StartPicaTracing() | ||
| 269 | { | ||
| 270 | if (is_pica_tracing) { | ||
| 271 | ERROR_LOG(GPU, "StartPicaTracing called even though tracing already running!"); | ||
| 272 | return; | ||
| 273 | } | ||
| 274 | |||
| 275 | pica_trace_mutex.lock(); | ||
| 276 | pica_trace = std::unique_ptr<PicaTrace>(new PicaTrace); | ||
| 277 | |||
| 278 | is_pica_tracing = true; | ||
| 279 | pica_trace_mutex.unlock(); | ||
| 280 | } | ||
| 281 | |||
| 282 | bool IsPicaTracing() | ||
| 283 | { | ||
| 284 | return is_pica_tracing; | ||
| 285 | } | ||
| 286 | |||
| 287 | void OnPicaRegWrite(u32 id, u32 value) | ||
| 288 | { | ||
| 289 | // Double check for is_pica_tracing to avoid pointless locking overhead | ||
| 290 | if (!is_pica_tracing) | ||
| 291 | return; | ||
| 292 | |||
| 293 | std::unique_lock<std::mutex> lock(pica_trace_mutex); | ||
| 294 | |||
| 295 | if (!is_pica_tracing) | ||
| 296 | return; | ||
| 297 | |||
| 298 | pica_trace->writes.push_back({id, value}); | ||
| 299 | } | ||
| 300 | |||
| 301 | std::unique_ptr<PicaTrace> FinishPicaTracing() | ||
| 302 | { | ||
| 303 | if (!is_pica_tracing) { | ||
| 304 | ERROR_LOG(GPU, "FinishPicaTracing called even though tracing already running!"); | ||
| 305 | return {}; | ||
| 306 | } | ||
| 307 | |||
| 308 | // signalize that no further tracing should be performed | ||
| 309 | is_pica_tracing = false; | ||
| 310 | |||
| 311 | // Wait until running tracing is finished | ||
| 312 | pica_trace_mutex.lock(); | ||
| 313 | std::unique_ptr<PicaTrace> ret(std::move(pica_trace)); | ||
| 314 | pica_trace_mutex.unlock(); | ||
| 315 | return std::move(ret); | ||
| 316 | } | ||
| 317 | |||
| 263 | } // namespace | 318 | } // namespace |
| 264 | 319 | ||
| 265 | } // namespace | 320 | } // 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 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <memory> | ||
| 8 | #include <vector> | 9 | #include <vector> |
| 9 | 10 | ||
| 10 | #include "video_core/pica.h" | 11 | #include "video_core/pica.h" |
| @@ -38,6 +39,26 @@ private: | |||
| 38 | void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size, | 39 | void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size, |
| 39 | u32 main_offset, const Regs::VSOutputAttributes* output_attributes); | 40 | u32 main_offset, const Regs::VSOutputAttributes* output_attributes); |
| 40 | 41 | ||
| 42 | |||
| 43 | // Utility class to log Pica commands. | ||
| 44 | struct PicaTrace { | ||
| 45 | struct Write : public std::pair<u32,u32> { | ||
| 46 | Write(u32 id, u32 value) : std::pair<u32,u32>(id, value) {} | ||
| 47 | |||
| 48 | u32& Id() { return first; } | ||
| 49 | const u32& Id() const { return first; } | ||
| 50 | |||
| 51 | u32& Value() { return second; } | ||
| 52 | const u32& Value() const { return second; } | ||
| 53 | }; | ||
| 54 | std::vector<Write> writes; | ||
| 55 | }; | ||
| 56 | |||
| 57 | void StartPicaTracing(); | ||
| 58 | bool IsPicaTracing(); | ||
| 59 | void OnPicaRegWrite(u32 id, u32 value); | ||
| 60 | std::unique_ptr<PicaTrace> FinishPicaTracing(); | ||
| 61 | |||
| 41 | } // namespace | 62 | } // namespace |
| 42 | 63 | ||
| 43 | } // namespace | 64 | } // namespace |