summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-02-03 16:10:34 +1000
committerZephyron <zephyron@citron-emu.org>2025-02-03 16:10:34 +1000
commit71e652123ba3b7b68e42f8ea7caccf886f46bb27 (patch)
tree33c68bd3f684fc88af3685fb568d8d0fb298cb06
parentddd5e7e88765077fe8076829301531d8d3eda6d5 (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.
-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 4e9c58718..c598edbc2 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) {