mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-31 10:36:56 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99a926829a | |||
| ea41c3e731 | |||
| 2e99100467 | |||
| d9334ca68e | |||
| ec275e6e26 | |||
| cb490de31b |
@@ -63,8 +63,6 @@ add_library(
|
|||||||
fs/path_util.cpp
|
fs/path_util.cpp
|
||||||
fs/path_util.h
|
fs/path_util.h
|
||||||
hash.h
|
hash.h
|
||||||
heap_tracker.cpp
|
|
||||||
heap_tracker.h
|
|
||||||
hex_util.cpp
|
hex_util.cpp
|
||||||
hex_util.h
|
hex_util.h
|
||||||
host_memory.cpp
|
host_memory.cpp
|
||||||
|
|||||||
@@ -1,282 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include "common/heap_tracker.h"
|
|
||||||
#include "common/logging.h"
|
|
||||||
#include "common/assert.h"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
s64 GetMaxPermissibleResidentMapCount() {
|
|
||||||
// Default value.
|
|
||||||
s64 value = 65530;
|
|
||||||
|
|
||||||
// Try to read how many mappings we can make.
|
|
||||||
std::ifstream s("/proc/sys/vm/max_map_count");
|
|
||||||
s >> value;
|
|
||||||
|
|
||||||
// Print, for debug.
|
|
||||||
LOG_INFO(HW_Memory, "Current maximum map count: {}", value);
|
|
||||||
|
|
||||||
// Allow 20000 maps for other code and to account for split inaccuracy.
|
|
||||||
return std::max<s64>(value - 20000, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
HeapTracker::HeapTracker(Common::HostMemory& buffer)
|
|
||||||
: m_buffer(buffer), m_max_resident_map_count(GetMaxPermissibleResidentMapCount()) {}
|
|
||||||
HeapTracker::~HeapTracker() = default;
|
|
||||||
|
|
||||||
void HeapTracker::Map(size_t virtual_offset, size_t host_offset, size_t length,
|
|
||||||
MemoryPermission perm, bool is_separate_heap) {
|
|
||||||
// When mapping other memory, map pages immediately.
|
|
||||||
if (!is_separate_heap) {
|
|
||||||
m_buffer.Map(virtual_offset, host_offset, length, perm, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// We are mapping part of a separate heap.
|
|
||||||
std::scoped_lock lk{m_lock};
|
|
||||||
|
|
||||||
auto* const map = new SeparateHeapMap{
|
|
||||||
.vaddr = virtual_offset,
|
|
||||||
.paddr = host_offset,
|
|
||||||
.size = length,
|
|
||||||
.tick = m_tick++,
|
|
||||||
.perm = perm,
|
|
||||||
.is_resident = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Insert into mappings.
|
|
||||||
m_map_count++;
|
|
||||||
m_mappings.insert(*map);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, map.
|
|
||||||
this->DeferredMapSeparateHeap(virtual_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeapTracker::Unmap(size_t virtual_offset, size_t size, bool is_separate_heap) {
|
|
||||||
// If this is a separate heap...
|
|
||||||
if (is_separate_heap) {
|
|
||||||
std::scoped_lock lk{m_lock};
|
|
||||||
|
|
||||||
const SeparateHeapMap key{
|
|
||||||
.vaddr = virtual_offset,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Split at the boundaries of the region we are removing.
|
|
||||||
this->SplitHeapMapLocked(virtual_offset);
|
|
||||||
this->SplitHeapMapLocked(virtual_offset + size);
|
|
||||||
|
|
||||||
// Erase all mappings in range.
|
|
||||||
auto it = m_mappings.find(key);
|
|
||||||
while (it != m_mappings.end() && it->vaddr < virtual_offset + size) {
|
|
||||||
// Get underlying item.
|
|
||||||
auto* const item = std::addressof(*it);
|
|
||||||
|
|
||||||
// If resident, erase from resident map.
|
|
||||||
if (item->is_resident) {
|
|
||||||
ASSERT(--m_resident_map_count >= 0);
|
|
||||||
m_resident_mappings.erase(m_resident_mappings.iterator_to(*item));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Erase from map.
|
|
||||||
ASSERT(--m_map_count >= 0);
|
|
||||||
it = m_mappings.erase(it);
|
|
||||||
|
|
||||||
// Free the item.
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmap pages.
|
|
||||||
m_buffer.Unmap(virtual_offset, size, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeapTracker::Protect(size_t virtual_offset, size_t size, MemoryPermission perm) {
|
|
||||||
// Ensure no rebuild occurs while reprotecting.
|
|
||||||
std::shared_lock lk{m_rebuild_lock};
|
|
||||||
|
|
||||||
// Split at the boundaries of the region we are reprotecting.
|
|
||||||
this->SplitHeapMap(virtual_offset, size);
|
|
||||||
|
|
||||||
// Declare tracking variables.
|
|
||||||
const VAddr end = virtual_offset + size;
|
|
||||||
VAddr cur = virtual_offset;
|
|
||||||
|
|
||||||
while (cur < end) {
|
|
||||||
VAddr next = cur;
|
|
||||||
bool should_protect = false;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::scoped_lock lk2{m_lock};
|
|
||||||
|
|
||||||
const SeparateHeapMap key{
|
|
||||||
.vaddr = next,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Try to get the next mapping corresponding to this address.
|
|
||||||
const auto it = m_mappings.nfind(key);
|
|
||||||
|
|
||||||
if (it == m_mappings.end()) {
|
|
||||||
// There are no separate heap mappings remaining.
|
|
||||||
next = end;
|
|
||||||
should_protect = true;
|
|
||||||
} else if (it->vaddr == cur) {
|
|
||||||
// We are in range.
|
|
||||||
// Update permission bits.
|
|
||||||
it->perm = perm;
|
|
||||||
|
|
||||||
// Determine next address and whether we should protect.
|
|
||||||
next = cur + it->size;
|
|
||||||
should_protect = it->is_resident;
|
|
||||||
} else /* if (it->vaddr > cur) */ {
|
|
||||||
// We weren't in range, but there is a block coming up that will be.
|
|
||||||
next = it->vaddr;
|
|
||||||
should_protect = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clamp to end.
|
|
||||||
next = (std::min)(next, end);
|
|
||||||
// Reprotect, if we need to.
|
|
||||||
if (should_protect) {
|
|
||||||
m_buffer.Protect(cur, next - cur, perm);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Advance.
|
|
||||||
cur = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HeapTracker::DeferredMapSeparateHeap(u8* fault_address) {
|
|
||||||
if (m_buffer.IsInVirtualRange(fault_address)) {
|
|
||||||
return this->DeferredMapSeparateHeap(fault_address - m_buffer.VirtualBasePointer());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HeapTracker::DeferredMapSeparateHeap(size_t virtual_offset) {
|
|
||||||
bool rebuild_required = false;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::scoped_lock lk{m_lock};
|
|
||||||
|
|
||||||
// Check to ensure this was a non-resident separate heap mapping.
|
|
||||||
const auto it = this->GetNearestHeapMapLocked(virtual_offset);
|
|
||||||
if (it == m_mappings.end() || it->is_resident) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update tick before possible rebuild.
|
|
||||||
it->tick = m_tick++;
|
|
||||||
|
|
||||||
// Check if we need to rebuild.
|
|
||||||
if (m_resident_map_count > m_max_resident_map_count) {
|
|
||||||
rebuild_required = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map the area.
|
|
||||||
m_buffer.Map(it->vaddr, it->paddr, it->size, it->perm, false);
|
|
||||||
|
|
||||||
// This map is now resident.
|
|
||||||
it->is_resident = true;
|
|
||||||
m_resident_map_count++;
|
|
||||||
m_resident_mappings.insert(*it);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rebuild_required) {
|
|
||||||
// A rebuild was required, so perform it now.
|
|
||||||
this->RebuildSeparateHeapAddressSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeapTracker::RebuildSeparateHeapAddressSpace() {
|
|
||||||
std::scoped_lock lk{m_rebuild_lock, m_lock};
|
|
||||||
|
|
||||||
ASSERT(!m_resident_mappings.empty());
|
|
||||||
|
|
||||||
// Dump half of the mappings.
|
|
||||||
//
|
|
||||||
// Despite being worse in theory, this has proven to be better in practice than more
|
|
||||||
// regularly dumping a smaller amount, because it significantly reduces average case
|
|
||||||
// lock contention.
|
|
||||||
std::size_t const desired_count = (std::min)(m_resident_map_count, m_max_resident_map_count) / 2;
|
|
||||||
std::size_t const evict_count = m_resident_map_count - desired_count;
|
|
||||||
auto it = m_resident_mappings.begin();
|
|
||||||
|
|
||||||
for (size_t i = 0; i < evict_count && it != m_resident_mappings.end(); i++) {
|
|
||||||
// Unmark and unmap.
|
|
||||||
it->is_resident = false;
|
|
||||||
m_buffer.Unmap(it->vaddr, it->size, false);
|
|
||||||
|
|
||||||
// Advance.
|
|
||||||
ASSERT(--m_resident_map_count >= 0);
|
|
||||||
it = m_resident_mappings.erase(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeapTracker::SplitHeapMap(VAddr offset, size_t size) {
|
|
||||||
std::scoped_lock lk{m_lock};
|
|
||||||
|
|
||||||
this->SplitHeapMapLocked(offset);
|
|
||||||
this->SplitHeapMapLocked(offset + size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeapTracker::SplitHeapMapLocked(VAddr offset) {
|
|
||||||
const auto it = this->GetNearestHeapMapLocked(offset);
|
|
||||||
if (it == m_mappings.end() || it->vaddr == offset) {
|
|
||||||
// Not contained or no split required.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache the original values.
|
|
||||||
auto* const left = std::addressof(*it);
|
|
||||||
const size_t orig_size = left->size;
|
|
||||||
|
|
||||||
// Adjust the left map.
|
|
||||||
const size_t left_size = offset - left->vaddr;
|
|
||||||
left->size = left_size;
|
|
||||||
|
|
||||||
// Create the new right map.
|
|
||||||
auto* const right = new SeparateHeapMap{
|
|
||||||
.vaddr = left->vaddr + left_size,
|
|
||||||
.paddr = left->paddr + left_size,
|
|
||||||
.size = orig_size - left_size,
|
|
||||||
.tick = left->tick,
|
|
||||||
.perm = left->perm,
|
|
||||||
.is_resident = left->is_resident,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Insert the new right map.
|
|
||||||
m_map_count++;
|
|
||||||
m_mappings.insert(*right);
|
|
||||||
|
|
||||||
// If resident, also insert into resident map.
|
|
||||||
if (right->is_resident) {
|
|
||||||
m_resident_map_count++;
|
|
||||||
m_resident_mappings.insert(*right);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HeapTracker::AddrTree::iterator HeapTracker::GetNearestHeapMapLocked(VAddr offset) {
|
|
||||||
const SeparateHeapMap key{
|
|
||||||
.vaddr = offset,
|
|
||||||
};
|
|
||||||
|
|
||||||
return m_mappings.find(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Common
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <mutex>
|
|
||||||
#include <set>
|
|
||||||
#include <shared_mutex>
|
|
||||||
|
|
||||||
#include "common/host_memory.h"
|
|
||||||
#include "common/intrusive_red_black_tree.h"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
struct SeparateHeapMap {
|
|
||||||
Common::IntrusiveRedBlackTreeNode addr_node{};
|
|
||||||
Common::IntrusiveRedBlackTreeNode tick_node{};
|
|
||||||
VAddr vaddr{};
|
|
||||||
PAddr paddr{};
|
|
||||||
size_t size{};
|
|
||||||
size_t tick{};
|
|
||||||
MemoryPermission perm{};
|
|
||||||
bool is_resident{};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SeparateHeapMapAddrComparator {
|
|
||||||
static constexpr int Compare(const SeparateHeapMap& lhs, const SeparateHeapMap& rhs) {
|
|
||||||
if (lhs.vaddr < rhs.vaddr) {
|
|
||||||
return -1;
|
|
||||||
} else if (lhs.vaddr <= (rhs.vaddr + rhs.size - 1)) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SeparateHeapMapTickComparator {
|
|
||||||
static constexpr int Compare(const SeparateHeapMap& lhs, const SeparateHeapMap& rhs) {
|
|
||||||
if (lhs.tick < rhs.tick) {
|
|
||||||
return -1;
|
|
||||||
} else if (lhs.tick > rhs.tick) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return SeparateHeapMapAddrComparator::Compare(lhs, rhs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class HeapTracker {
|
|
||||||
public:
|
|
||||||
explicit HeapTracker(Common::HostMemory& buffer);
|
|
||||||
~HeapTracker();
|
|
||||||
|
|
||||||
void Map(size_t virtual_offset, size_t host_offset, size_t length, MemoryPermission perm,
|
|
||||||
bool is_separate_heap);
|
|
||||||
void Unmap(size_t virtual_offset, size_t size, bool is_separate_heap);
|
|
||||||
void Protect(size_t virtual_offset, size_t length, MemoryPermission perm);
|
|
||||||
u8* VirtualBasePointer() {
|
|
||||||
return m_buffer.VirtualBasePointer();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DeferredMapSeparateHeap(u8* fault_address);
|
|
||||||
bool DeferredMapSeparateHeap(size_t virtual_offset);
|
|
||||||
|
|
||||||
private:
|
|
||||||
using AddrTreeTraits =
|
|
||||||
Common::IntrusiveRedBlackTreeMemberTraitsDeferredAssert<&SeparateHeapMap::addr_node>;
|
|
||||||
using AddrTree = AddrTreeTraits::TreeType<SeparateHeapMapAddrComparator>;
|
|
||||||
|
|
||||||
using TickTreeTraits =
|
|
||||||
Common::IntrusiveRedBlackTreeMemberTraitsDeferredAssert<&SeparateHeapMap::tick_node>;
|
|
||||||
using TickTree = TickTreeTraits::TreeType<SeparateHeapMapTickComparator>;
|
|
||||||
|
|
||||||
AddrTree m_mappings{};
|
|
||||||
TickTree m_resident_mappings{};
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SplitHeapMap(VAddr offset, size_t size);
|
|
||||||
void SplitHeapMapLocked(VAddr offset);
|
|
||||||
|
|
||||||
AddrTree::iterator GetNearestHeapMapLocked(VAddr offset);
|
|
||||||
|
|
||||||
void RebuildSeparateHeapAddressSpace();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Common::HostMemory& m_buffer;
|
|
||||||
const s64 m_max_resident_map_count;
|
|
||||||
|
|
||||||
std::shared_mutex m_rebuild_lock{};
|
|
||||||
std::mutex m_lock{};
|
|
||||||
s64 m_map_count{};
|
|
||||||
s64 m_resident_map_count{};
|
|
||||||
size_t m_tick{};
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Common
|
|
||||||
+6
-40
@@ -16,7 +16,6 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/atomic_ops.h"
|
#include "common/atomic_ops.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/heap_tracker.h"
|
|
||||||
#include "common/logging.h"
|
#include "common/logging.h"
|
||||||
#include "common/page_table.h"
|
#include "common/page_table.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
@@ -55,36 +54,24 @@ struct Memory::Impl {
|
|||||||
} else {
|
} else {
|
||||||
current_page_table->fastmem_arena = nullptr;
|
current_page_table->fastmem_arena = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
heap_tracker.emplace(system.DeviceMemory().buffer);
|
|
||||||
host_buffer = std::addressof(*heap_tracker);
|
|
||||||
#else
|
|
||||||
host_buffer = std::addressof(system.DeviceMemory().buffer);
|
host_buffer = std::addressof(system.DeviceMemory().buffer);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapMemoryRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size,
|
void MapMemoryRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size, Common::PhysicalAddress target, Common::MemoryPermission perms, bool separate_heap) {
|
||||||
Common::PhysicalAddress target, Common::MemoryPermission perms,
|
|
||||||
bool separate_heap) {
|
|
||||||
ASSERT_MSG((size & YUZU_PAGEMASK) == 0, "non-page aligned size: {:016X}", size);
|
ASSERT_MSG((size & YUZU_PAGEMASK) == 0, "non-page aligned size: {:016X}", size);
|
||||||
ASSERT_MSG((base & YUZU_PAGEMASK) == 0, "non-page aligned base: {:016X}", GetInteger(base));
|
ASSERT_MSG((base & YUZU_PAGEMASK) == 0, "non-page aligned base: {:016X}", GetInteger(base));
|
||||||
ASSERT_MSG(target >= DramMemoryMap::Base, "Out of bounds target: {:016X}",
|
ASSERT_MSG(target >= DramMemoryMap::Base, "Out of bounds target: {:016X}", GetInteger(target));
|
||||||
GetInteger(target));
|
MapPages(page_table, base / YUZU_PAGESIZE, size / YUZU_PAGESIZE, target, Common::PageType::Memory);
|
||||||
MapPages(page_table, base / YUZU_PAGESIZE, size / YUZU_PAGESIZE, target,
|
|
||||||
Common::PageType::Memory);
|
|
||||||
|
|
||||||
if (current_page_table->fastmem_arena) {
|
if (current_page_table->fastmem_arena) {
|
||||||
host_buffer->Map(GetInteger(base), GetInteger(target) - DramMemoryMap::Base, size, perms, separate_heap);
|
host_buffer->Map(GetInteger(base), GetInteger(target) - DramMemoryMap::Base, size, perms, separate_heap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnmapRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size,
|
void UnmapRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size, bool separate_heap) {
|
||||||
bool separate_heap) {
|
|
||||||
ASSERT_MSG((size & YUZU_PAGEMASK) == 0, "non-page aligned size: {:016X}", size);
|
ASSERT_MSG((size & YUZU_PAGEMASK) == 0, "non-page aligned size: {:016X}", size);
|
||||||
ASSERT_MSG((base & YUZU_PAGEMASK) == 0, "non-page aligned base: {:016X}", GetInteger(base));
|
ASSERT_MSG((base & YUZU_PAGEMASK) == 0, "non-page aligned base: {:016X}", GetInteger(base));
|
||||||
MapPages(page_table, base / YUZU_PAGESIZE, size / YUZU_PAGESIZE, 0,
|
MapPages(page_table, base / YUZU_PAGESIZE, size / YUZU_PAGESIZE, 0, Common::PageType::Unmapped);
|
||||||
Common::PageType::Unmapped);
|
|
||||||
|
|
||||||
if (current_page_table->fastmem_arena) {
|
if (current_page_table->fastmem_arena) {
|
||||||
host_buffer->Unmap(GetInteger(base), size, separate_heap);
|
host_buffer->Unmap(GetInteger(base), size, separate_heap);
|
||||||
@@ -767,12 +754,7 @@ struct Memory::Impl {
|
|||||||
std::array<Common::ScratchBuffer<u32>, Core::Hardware::NUM_CPU_CORES> scratch_buffers{};
|
std::array<Common::ScratchBuffer<u32>, Core::Hardware::NUM_CPU_CORES> scratch_buffers{};
|
||||||
std::span<Core::GPUDirtyMemoryManager> gpu_dirty_managers;
|
std::span<Core::GPUDirtyMemoryManager> gpu_dirty_managers;
|
||||||
std::mutex sys_core_guard;
|
std::mutex sys_core_guard;
|
||||||
#ifdef __ANDROID__
|
|
||||||
std::optional<Common::HeapTracker> heap_tracker;
|
|
||||||
Common::HeapTracker* host_buffer{};
|
|
||||||
#else
|
|
||||||
Common::HostMemory* host_buffer{};
|
Common::HostMemory* host_buffer{};
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Memory::Memory(Core::System& system_) : system{system_} {
|
Memory::Memory(Core::System& system_) : system{system_} {
|
||||||
@@ -965,30 +947,14 @@ bool Memory::InvalidateNCE(Common::ProcessAddress vaddr, size_t size) {
|
|||||||
u8* const ptr = impl->GetPointerImpl(
|
u8* const ptr = impl->GetPointerImpl(
|
||||||
GetInteger(vaddr),
|
GetInteger(vaddr),
|
||||||
[&] {
|
[&] {
|
||||||
LOG_ERROR(HW_Memory, "Unmapped InvalidateNCE for {} bytes @ {:#x}", size,
|
LOG_ERROR(HW_Memory, "Unmapped InvalidateNCE for {} bytes @ {:#x}", size, GetInteger(vaddr));
|
||||||
GetInteger(vaddr));
|
|
||||||
mapped = false;
|
mapped = false;
|
||||||
},
|
},
|
||||||
[&] { rasterizer = true; });
|
[&] { rasterizer = true; });
|
||||||
if (rasterizer) {
|
if (rasterizer) {
|
||||||
impl->InvalidateGPUMemory(ptr, size);
|
impl->InvalidateGPUMemory(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
if (!rasterizer && mapped) {
|
|
||||||
impl->host_buffer->DeferredMapSeparateHeap(GetInteger(vaddr));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return mapped && ptr != nullptr;
|
return mapped && ptr != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Memory::InvalidateSeparateHeap(void* fault_address) {
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
return impl->host_buffer->DeferredMapSeparateHeap(static_cast<u8*>(fault_address));
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Core::Memory
|
} // namespace Core::Memory
|
||||||
|
|||||||
+1
-6
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
||||||
@@ -490,13 +490,8 @@ public:
|
|||||||
* marked as debug or non-debug.
|
* marked as debug or non-debug.
|
||||||
*/
|
*/
|
||||||
void MarkRegionDebug(Common::ProcessAddress vaddr, u64 size, bool debug);
|
void MarkRegionDebug(Common::ProcessAddress vaddr, u64 size, bool debug);
|
||||||
|
|
||||||
void SetGPUDirtyManagers(std::span<Core::GPUDirtyMemoryManager> managers);
|
void SetGPUDirtyManagers(std::span<Core::GPUDirtyMemoryManager> managers);
|
||||||
|
|
||||||
bool InvalidateNCE(Common::ProcessAddress vaddr, size_t size);
|
bool InvalidateNCE(Common::ProcessAddress vaddr, size_t size);
|
||||||
|
|
||||||
bool InvalidateSeparateHeap(void* fault_address);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user