summaryrefslogtreecommitdiffstats
path: root/src/video_core/debug_utils
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp32
-rw-r--r--src/video_core/debug_utils/debug_utils.h64
2 files changed, 75 insertions, 21 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index c3a9c9598..2f645b441 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -4,35 +4,41 @@
#include <algorithm>
#include <condition_variable>
+#include <cstdint>
#include <cstring>
#include <fstream>
-#include <list>
#include <map>
#include <mutex>
+#include <stdexcept>
#include <string>
#ifdef HAVE_PNG
#include <png.h>
+#include <setjmp.h>
#endif
+#include <nihstro/bit_field.h>
#include <nihstro/float24.h>
#include <nihstro/shader_binary.h>
#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 "core/settings.h"
-
+#include "video_core/debug_utils/debug_utils.h"
#include "video_core/pica.h"
#include "video_core/pica_state.h"
+#include "video_core/pica_types.h"
+#include "video_core/rasterizer_interface.h"
#include "video_core/renderer_base.h"
+#include "video_core/shader/shader.h"
#include "video_core/utils.h"
#include "video_core/video_core.h"
-#include "video_core/debug_utils/debug_utils.h"
using nihstro::DVLBHeader;
using nihstro::DVLEHeader;
@@ -40,15 +46,12 @@ using nihstro::DVLPHeader;
namespace Pica {
-void DebugContext::OnEvent(Event event, void* data) {
- if (!breakpoints[event].enabled)
- return;
-
+void DebugContext::DoOnEvent(Event event, void* data) {
{
std::unique_lock<std::mutex> lock(breakpoint_mutex);
- // Commit the hardware renderer's framebuffer so it will show on debug widgets
- VideoCore::g_renderer->Rasterizer()->FlushFramebuffer();
+ // Commit the rasterizer's caches so framebuffers, render targets, etc. will show on debug widgets
+ VideoCore::g_renderer->Rasterizer()->FlushAll();
// TODO: Should stop the CPU thread here once we multithread emulation.
@@ -205,11 +208,12 @@ void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, c
// TODO: Reduce the amount of binary code written to relevant portions
dvlp.binary_offset = write_offset - dvlp_offset;
- dvlp.binary_size_words = setup.program_code.size();
- QueueForWriting(reinterpret_cast<const u8*>(setup.program_code.data()), setup.program_code.size() * sizeof(u32));
+ dvlp.binary_size_words = static_cast<uint32_t>(setup.program_code.size());
+ QueueForWriting(reinterpret_cast<const u8*>(setup.program_code.data()),
+ static_cast<u32>(setup.program_code.size()) * sizeof(u32));
dvlp.swizzle_info_offset = write_offset - dvlp_offset;
- dvlp.swizzle_info_num_entries = setup.swizzle_data.size();
+ dvlp.swizzle_info_num_entries = static_cast<uint32_t>(setup.swizzle_data.size());
u32 dummy = 0;
for (unsigned int i = 0; i < setup.swizzle_data.size(); ++i) {
QueueForWriting(reinterpret_cast<const u8*>(&setup.swizzle_data[i]), sizeof(setup.swizzle_data[i]));
@@ -261,7 +265,7 @@ void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, c
constant_table.emplace_back(constant);
}
dvle.constant_table_offset = write_offset - dvlb.dvle_offset;
- dvle.constant_table_size = constant_table.size();
+ dvle.constant_table_size = static_cast<uint32_t>(constant_table.size());
for (const auto& constant : constant_table) {
QueueForWriting(reinterpret_cast<const u8*>(&constant), sizeof(constant));
}
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h
index 7df941619..f628292a4 100644
--- a/src/video_core/debug_utils/debug_utils.h
+++ b/src/video_core/debug_utils/debug_utils.h
@@ -4,23 +4,33 @@
#pragma once
+#include <algorithm>
#include <array>
#include <condition_variable>
+#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <mutex>
+#include <string>
+#include <utility>
#include <vector>
+#include "common/common_types.h"
#include "common/vector_math.h"
-#include "core/tracer/recorder.h"
-
#include "video_core/pica.h"
-#include "video_core/shader/shader.h"
+
+namespace CiTrace {
+class Recorder;
+}
namespace Pica {
+namespace Shader {
+struct ShaderSetup;
+}
+
class DebugContext {
public:
enum class Event {
@@ -30,7 +40,7 @@ public:
PicaCommandProcessed,
IncomingPrimitiveBatch,
FinishedPrimitiveBatch,
- VertexLoaded,
+ VertexShaderInvocation,
IncomingDisplayTransfer,
GSPCommandProcessed,
BufferSwapped,
@@ -114,7 +124,15 @@ public:
* @param event Event which has happened
* @param data Optional data pointer (pass nullptr if unused). Needs to remain valid until Resume() is called.
*/
- void OnEvent(Event event, void* data);
+ void OnEvent(Event event, void* data) {
+ // This check is left in the header to allow the compiler to inline it.
+ if (!breakpoints[(int)event].enabled)
+ return;
+ // For the rest of event handling, call a separate function.
+ DoOnEvent(event, data);
+ }
+
+ void DoOnEvent(Event event, void *data);
/**
* Resume from the current breakpoint.
@@ -126,12 +144,14 @@ public:
* Delete all set breakpoints and resume emulation.
*/
void ClearBreakpoints() {
- breakpoints.clear();
+ for (auto &bp : breakpoints) {
+ bp.enabled = false;
+ }
Resume();
}
// TODO: Evaluate if access to these members should be hidden behind a public interface.
- std::map<Event, BreakPoint> breakpoints;
+ std::array<BreakPoint, (int)Event::NumEvents> breakpoints;
Event active_breakpoint;
bool at_breakpoint = false;
@@ -206,6 +226,36 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data);
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages);
+/**
+ * Used in the vertex loader to merge access records. TODO: Investigate if actually useful.
+ */
+class MemoryAccessTracker {
+ /// Combine overlapping and close ranges
+ void SimplifyRanges() {
+ for (auto it = ranges.begin(); it != ranges.end(); ++it) {
+ // NOTE: We add 32 to the range end address to make sure "close" ranges are combined, too
+ auto it2 = std::next(it);
+ while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) {
+ it->second = std::max(it->second, it2->first + it2->second - it->first);
+ it2 = ranges.erase(it2);
+ }
+ }
+ }
+
+public:
+ /// Record a particular memory access in the list
+ void AddAccess(u32 paddr, u32 size) {
+ // Create new range or extend existing one
+ ranges[paddr] = std::max(ranges[paddr], size);
+
+ // Simplify ranges...
+ SimplifyRanges();
+ }
+
+ /// Map of accessed ranges (mapping start address to range size)
+ std::map<u32, u32> ranges;
+};
+
} // namespace
} // namespace