diff options
| author | Subv <subv2112@gmail.com> | 2018-03-22 15:19:35 -0500 |
|---|---|---|
| committer | Subv <subv2112@gmail.com> | 2018-03-24 11:31:49 -0500 |
| commit | 77fd0d47e70968bcbc87a3b5607cd29e6211f656 (patch) | |
| tree | 54e91cede780bbd5bec2612547a61bdd799e36af /src/video_core/debug_utils/debug_utils.cpp | |
| parent | 1b8d798835c2d39c2867f53d8dcacdc7d0ba0d15 (diff) | |
Frontend: Ported the GPU breakpoints and surface viewer widgets from citra.
Diffstat (limited to 'src/video_core/debug_utils/debug_utils.cpp')
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp new file mode 100644 index 000000000..73fd4d7a3 --- /dev/null +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -0,0 +1,66 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include <algorithm> +#include <condition_variable> +#include <cstdint> +#include <cstring> +#include <fstream> +#include <map> +#include <mutex> +#include <string> + +#include "common/assert.h" +#include "common/bit_field.h" +#include "common/color.h" +#include "common/common_types.h" +#include "common/file_util.h" +#include "common/logging/log.h" +#include "common/math_util.h" +#include "common/vector_math.h" +#include "video_core/debug_utils/debug_utils.h" + +namespace Tegra { + +std::shared_ptr<DebugContext> g_debug_context; + +void DebugContext::DoOnEvent(Event event, void* data) { + { + std::unique_lock<std::mutex> lock(breakpoint_mutex); + + // TODO(Subv): Commit the rasterizer's caches so framebuffers, render targets, etc. will + // show on debug widgets + + // TODO: Should stop the CPU thread here once we multithread emulation. + + active_breakpoint = event; + at_breakpoint = true; + + // Tell all observers that we hit a breakpoint + for (auto& breakpoint_observer : breakpoint_observers) { + breakpoint_observer->OnMaxwellBreakPointHit(event, data); + } + + // Wait until another thread tells us to Resume() + resume_from_breakpoint.wait(lock, [&] { return !at_breakpoint; }); + } +} + +void DebugContext::Resume() { + { + std::lock_guard<std::mutex> lock(breakpoint_mutex); + + // Tell all observers that we are about to resume + for (auto& breakpoint_observer : breakpoint_observers) { + breakpoint_observer->OnMaxwellResume(); + } + + // Resume the waiting thread (i.e. OnEvent()) + at_breakpoint = false; + } + + resume_from_breakpoint.notify_one(); +} + +} // namespace Tegra |
