mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-02-07 16:56:21 +01:00
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.
This commit is contained in:
parent
ddd5e7e887
commit
71e652123b
1 changed files with 30 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue