mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-31 16:37:07 +02:00
[host_memory] remove unused fastmem fallback path (#3133)
basically nobody ever used that path, we instead soft-crash upon not being able to allocate **backing** storage, we do still attempt to allocate a virtual base through, but if backing storage fails for any reason whatsoever, we pretty much cant run the emulator anyways Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3133 Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
91596c6d1b
commit
1da0a380da
2 changed files with 15 additions and 29 deletions
|
|
@ -68,8 +68,8 @@ static int memfd_create(const char* name, unsigned int flags) {
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
constexpr size_t PageAlignment = 0x1000;
|
[[maybe_unused]] constexpr size_t PageAlignment = 0x1000;
|
||||||
constexpr size_t HugePageSize = 0x200000;
|
[[maybe_unused]] constexpr size_t HugePageSize = 0x200000;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
|
@ -692,30 +692,16 @@ private:
|
||||||
|
|
||||||
#endif // ^^^ POSIX ^^^
|
#endif // ^^^ POSIX ^^^
|
||||||
|
|
||||||
HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_)
|
HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_size(backing_size_), virtual_size(virtual_size_) {
|
||||||
: backing_size(backing_size_), virtual_size(virtual_size_) {
|
// Try to allocate a fastmem arena.
|
||||||
try {
|
// The implementation will fail with std::bad_alloc on errors.
|
||||||
// Try to allocate a fastmem arena.
|
impl = std::make_unique<HostMemory::Impl>(AlignUp(backing_size, PageAlignment), AlignUp(virtual_size, PageAlignment) + HugePageSize);
|
||||||
// The implementation will fail with std::bad_alloc on errors.
|
backing_base = impl->backing_base;
|
||||||
impl =
|
virtual_base = impl->virtual_base;
|
||||||
std::make_unique<HostMemory::Impl>(AlignUp(backing_size, PageAlignment),
|
if (virtual_base) {
|
||||||
AlignUp(virtual_size, PageAlignment) + HugePageSize);
|
// Ensure the virtual base is aligned to the L2 block size.
|
||||||
backing_base = impl->backing_base;
|
virtual_base = reinterpret_cast<u8*>(Common::AlignUp(uintptr_t(virtual_base), HugePageSize));
|
||||||
virtual_base = impl->virtual_base;
|
virtual_base_offset = virtual_base - impl->virtual_base;
|
||||||
|
|
||||||
if (virtual_base) {
|
|
||||||
// Ensure the virtual base is aligned to the L2 block size.
|
|
||||||
virtual_base = reinterpret_cast<u8*>(
|
|
||||||
Common::AlignUp(reinterpret_cast<uintptr_t>(virtual_base), HugePageSize));
|
|
||||||
virtual_base_offset = virtual_base - impl->virtual_base;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (const std::bad_alloc&) {
|
|
||||||
LOG_CRITICAL(HW_Memory,
|
|
||||||
"Fastmem unavailable, falling back to VirtualBuffer for memory allocation");
|
|
||||||
fallback_buffer = std::make_unique<Common::VirtualBuffer<u8>>(backing_size);
|
|
||||||
backing_base = fallback_buffer->data();
|
|
||||||
virtual_base = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
@ -79,9 +82,6 @@ private:
|
||||||
u8* backing_base{};
|
u8* backing_base{};
|
||||||
u8* virtual_base{};
|
u8* virtual_base{};
|
||||||
size_t virtual_base_offset{};
|
size_t virtual_base_offset{};
|
||||||
|
|
||||||
// Fallback if fastmem is not supported on this platform
|
|
||||||
std::unique_ptr<Common::VirtualBuffer<u8>> fallback_buffer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue