summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-02-03 16:10:34 +1000
committerMike Lothian <mike@fireburn.co.uk>2025-05-11 14:54:45 +0100
commit35fbaef772567ac6bd2c84451a37ae48a824a9f7 (patch)
tree685ceafda37aff733261ca9e9205cf39cd8b1cb4 /src/core/memory.cpp
parenta7036e7dd9e83c84de50625157d43b1388c30368 (diff)
memory: Improve debug logging and validation in InvalidateNCE
Add more detailed debug logging and validation to the InvalidateNCE function: - Add entry debug log showing NCE invalidation request details - Add upfront validation of memory region before proceeding - Add debug logs for rasterizer and separate heap handling cases - Add warning logs for invalid address ranges and failed invalidations - Improve error message formatting and clarity - Group related operations with descriptive comments These changes make it easier to debug NCE invalidation issues by providing more visibility into the validation steps and failure cases.
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 47ec8e77b..abb2ce314 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -1093,28 +1093,54 @@ void Memory::MarkRegionDebug(Common::ProcessAddress vaddr, u64 size, bool debug)
}
bool Memory::InvalidateNCE(Common::ProcessAddress vaddr, size_t size) {
+ // Add detailed debug logging
+ LOG_DEBUG(HW_Memory, "JIT requesting NCE invalidation - Address: 0x{:016X}, Size: {} bytes",
+ GetInteger(vaddr), size);
+
+ // First check if the memory region is valid and executable
+ if (!IsValidVirtualAddressRange(vaddr, size)) {
+ LOG_WARNING(HW_Memory, "Skipping InvalidateNCE: Invalid address range - {} bytes @ 0x{:016X}",
+ size, GetInteger(vaddr));
+ return false;
+ }
+
[[maybe_unused]] bool mapped = true;
[[maybe_unused]] bool rasterizer = false;
+ // Get pointer and check memory type
u8* const ptr = impl->GetPointerImpl(
GetInteger(vaddr),
[&] {
- LOG_ERROR(HW_Memory, "Unmapped InvalidateNCE for {} bytes @ {:#x}", size,
- GetInteger(vaddr));
+ LOG_WARNING(HW_Memory,
+ "Skipping InvalidateNCE: Unmapped memory region - {} bytes @ 0x{:016X}",
+ size, GetInteger(vaddr));
mapped = false;
},
[&] { rasterizer = true; });
+
+ // Handle rasterizer memory separately
if (rasterizer) {
+ LOG_DEBUG(HW_Memory, "Invalidating rasterizer memory region - {} bytes @ 0x{:016X}",
+ size, GetInteger(vaddr));
impl->InvalidateGPUMemory(ptr, size);
}
#ifdef __linux__
- if (!rasterizer && mapped) {
+ // Handle separate heap mapping on Linux
+ if (!rasterizer && mapped && ptr) {
+ LOG_DEBUG(HW_Memory, "Handling separate heap mapping for NCE region");
impl->buffer->DeferredMapSeparateHeap(GetInteger(vaddr));
}
#endif
- return mapped && ptr != nullptr;
+ // Return success only if we have a valid pointer and the region was mapped
+ const bool success = mapped && ptr != nullptr;
+ if (!success) {
+ LOG_WARNING(HW_Memory, "NCE invalidation failed - Address: 0x{:016X}, Size: {} bytes",
+ GetInteger(vaddr), size);
+ }
+
+ return success;
}
bool Memory::InvalidateSeparateHeap(void* fault_address) {