mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-12 14:48:52 +00:00
Core: physical backing for flexible and pooled memory allocations (#3639)
* Fix isDevKit Previously, isDevKit could increase the physical memory used above the length we reserve in the backing file. * Physical backing for flexible allocations I took the simple approach here, creating a separate map for flexible allocations and pretty much just copying over the logic used in the direct memory map. * Various fixups * Fix mistake #1 * Assert + clang * Fix 2 * Clang * Fix CanMergeWith Validate physical base for flexible mappings * Clang * Physical backing for pooled memory * Allow VMA splitting in NameVirtualRange This should be safe, since with the changes in this PR, the only issues that come from discrepancies between address space and vma_map are issues related to vmas being larger than address space mappings. NameVirtualRange will only ever shrink VMAs by naming part of one. * Fix * Fix NameVirtualRange * Revert NameVirtualRange changes Seems like it doesn't play nice for Windows * Clean up isDevKit logic We already log both isNeo and isDevKit in Emulator::Run, so the additional logging in MemoryManager::SetupMemoryRegions isn't really necessary. I've also added a separate constant for non-pro devkit memory, as suggested. Finally I've changed a couple constants to use the ORBIS prefix we generally follow here, instead of the SCE prefix. * Erase flexible memory contents from physical memory on unmap Flexible memory should not be preserved on unmap, so erase flexible contents from the physical backing when unmapping. * Expand flexible memory map Some games will end up fragmenting the physical backing space used for flexible memory. To reduce the frequency of this happening under normal circumstances, allocate the entirety of the remaining physical backing to the flexible memory map. This is effectively a workaround to the problem, but at the moment I think this should suffice. * Clang
This commit is contained in:
@@ -27,7 +27,7 @@ asm(".zerofill SYSTEM_RESERVED,SYSTEM_RESERVED,__SYSTEM_RESERVED,0x7C0004000");
|
||||
|
||||
namespace Core {
|
||||
|
||||
static constexpr size_t BackingSize = SCE_KERNEL_TOTAL_MEM_PRO;
|
||||
static constexpr size_t BackingSize = ORBIS_KERNEL_TOTAL_MEM_DEV_PRO;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -579,9 +579,9 @@ void AddressSpace::Unmap(VAddr virtual_addr, size_t size, VAddr start_in_vma, VA
|
||||
// the entire allocation and remap the portions outside of the requested unmapping range.
|
||||
impl->Unmap(virtual_addr, size, has_backing && !readonly_file);
|
||||
|
||||
// TODO: Determine if any titles require partial unmapping support for flexible allocations.
|
||||
// TODO: Determine if any titles require partial unmapping support for un-backed allocations.
|
||||
ASSERT_MSG(has_backing || (start_in_vma == 0 && end_in_vma == size),
|
||||
"Partial unmapping of flexible allocations is not supported");
|
||||
"Partial unmapping of un-backed allocations is not supported");
|
||||
|
||||
if (start_in_vma != 0) {
|
||||
Map(virtual_addr, start_in_vma, 0, phys_base, is_exec);
|
||||
|
||||
Reference in New Issue
Block a user