aboutsummaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [video_core] buffer cache readback for nce invalidations (#4490)xbzk2026-09-301-1/+1
| | | | | | | | | | | | | | | | | | - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- This is a follow up of 4473, a fix for the next Ender Magnolia known crash, the shackled beast's vaper crash, but specific for NCE. Imma try to be short: NCE invalidation was dooming whole guest pages when it shouldn't. If the GPU buffer cache owns some bytes on a page, invalidating first discards their ownership, and the retrying CPU can then observe stale data. On Android, this was corrupting some indirect draw packets and causing huge invalid index count reach staging memory allocation. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4490 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: lizzie <lizzie@eden-emu.dev>
* [common/core/dynarmic] Optimize page table allocations (#4219)Exverge2026-09-091-38/+41
| | | | | | | | | | | | | | Reduces the page entries from 32 bytes to 8 and rewrites `VirtualBuffer` to be more efficient in memory usage and specifically for large zero regions. The page table will now only reserve 1GiB instead of 4GiB and of this memory it should only use at most ~8MiB. This PR has the side effect of using Eden on Windows on low memory systems much more plausible since it would previously require ~10GiB of committable memory at front (despite using ~5-6 at most, inadvertently stalling other processes) where as now it should only require around the amount that it'll actually use. Co-authored-by: Lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4219 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: lizzie <lizzie@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
* [fmt] use {#:x} instead of 0x{:#x} (#4170)lizzie2026-07-251-10/+10
| | | | | | | | | | continuation of #309 but applying to even more files than before :) also makes them lowercase because `0xfafafa` is better as `0XFAFAFA` Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4170 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: Maufeat <sahyno1996@gmail.com>
* [core/memory] remove duplicates from template when unsafe=T/F, remove ↵lizzie2026-05-181-197/+107
| | | | | | | | | | | | | increment, remove sad path for exception code on cache op (#3972) Ideally this should increase perf when doing write/read operations not by a lot, just enough for it not to suck so much as it does right now Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3972 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Maufeat <sahyno1996@gmail.com>
* [core] remove parallel thread remnants that keep calling sysconf() everytime ↵lizzie2026-03-311-12/+2
| | | | | | | | | | | | | | a memory object is created (#3804) pure spam of calls for _sysconf() Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3804 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* Revert "[core/memory] remove indirection handling for unaligned access ↵lizzie2026-03-131-83/+101
| | | | | | | | | | | | (#3584)" (#3725) This reverts commit 2d273590747cec4716a2e3c293a5b8693abb0403. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3725 Reviewed-by: DraVee <chimera@dravee.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [common/logging] Simplify logging logic and fix issues when logging before ↵lizzie2026-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | system is created (#3688) - our logging code was bigger than spdlog itself, why???? just keep it simple - fix issues when logging before logging system is even started - removes the "initialized logging twice" issue - removes uneeded indirection in file logging - uses direct formatting instead of jumping hoopla-around the fmt::format() ressult - code duplication and dead code removal as usual I did explore dup2() but I think it's not worth the hassle I did try `fwopen()` but it's better if things are just kept as-is. there is a lot of noise because I removed a bunch of redundant files on logging and just put everything in one file now normally this wouldn't be a good idea, however consider: the complexity of logging; it's less than 500 lines... does it really need a whole subsystem?!?!?! ITS JUST LOGGING Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3688 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: DraVee <chimera@dravee.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [core/memory] remove indirection handling for unaligned access (#3584)lizzie2026-02-221-101/+83
| | | | | | | | | Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3584 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>
* [dynarmic] add current code page cache (#3459)lizzie2026-02-121-3/+2
| | | | | | | | | | | | | | | | | | | should make JIT translation a bit faster - especially for non-fastmem test if thumb still werks previously: we read 32-bits one by one, and do translation **for each u32 we read** now: one big read of 4096 bytes (aligned of course), only 1 VAddr translation Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3459 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>
* [dynarmic, common] pagetable clustering (#3215)lizzie2026-01-131-63/+39
| | | | | | | | | | | | | | | | Raises the size of each page entry to 32 bytes, however, it merges them into a single structure THEORETICALLY this is better since the access pattern observed corresponds to the program wanting backing_addr/pointers/blocks immediately after one another. This may improve performance at the cost of some extra memory. Another implementation would be to structure only backing_addr/blocks within the same virtual buffer. Alas spamming virtual buffers is evil since each of them is a cache trasher (imagine jumping from wildly different block to wildly different block immediately). Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3215 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>
* [core] use memcpy instead of hand rolling aligned cases (#2639)lizzie2025-12-191-167/+36
| | | | | | | | | | | Hand rolling memcpy like this is always frowned upon because the compiler has more insight on whats going on (plus the code resolves to a worse version of itself on assembly). This removes some branches that are just straight up redundant. May save stuff especially for systems without fastmem enabled. Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2639 Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* Partial revert "[common] remove HeapTracker (#3001)" (#3107)lizzie2025-11-271-0/+23
| | | | | | | | Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3107 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: Maufeat <sahyno1996@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [common] remove HeapTracker (#3001)lizzie2025-11-271-24/+0
| | | | | | | | | | | Should fix a bunch of leaks on Android? - PLEASE CHECK UE4 GAMES Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3001 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* Revert "[core/memory] Remove defered heap allocation on Linux." (#2974)PavelBARABANOV2025-11-091-0/+15
| | | | | | | | | Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2974 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev> Co-authored-by: PavelBARABANOV <pavelbarabanov94@gmail.com> Co-committed-by: PavelBARABANOV <pavelbarabanov94@gmail.com>
* [core/memory] Remove defered heap allocation on Linux. (#2587)lizzie2025-10-311-15/+0
| | | | | | | | | | Authored-by: weakboson <weakboson@eden-emu.dev> Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2587 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [cmake] enable clang-cl and WoA builds (#348)lizzie2025-09-091-4/+4
| | | | | | | | | | | | | | Compilation and CMake fixes for both Windows on ARM and clang-cl, meaning Windows can now be built on both MSVC and clang on both amd64 and aarch64. Compiling on clang is *dramatically* faster so this should be useful for CI. Co-authored-by: crueter <crueter@eden-emu.dev> Co-authored-by: crueter <crueter@crueter.xyz> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/348 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* Revert "[heap_tracker] Use ankerl map instead of rb tree (#249)" (#382)crueter2025-09-041-2/+19
| | | | | | | | | | | | This reverts commit c9a3baab5d5ba524778492027ef8961da947df2d. this commit caused issues in ender magnolia or something, need to make sure I didn't mess up the revert Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/382 Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev> Reviewed-by: Lizzie <lizzie@eden-emu.dev> Reviewed-by: MaranBr <maranbr@outlook.com>
* [heap_tracker] Use ankerl map instead of rb tree (#249)lizzie2025-08-271-19/+2
| | | | | | | | Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/249 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [memory] remove "fast" memcpy and memset (not fast at all), remove slow ↵lizzie2025-08-031-204/+17
| | | | | | | | parallel impl and just use serial (#188) Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/188 Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [vk, opengl] defer checks to topmost call (avoid unnecessary call) (#40)lizzie2025-07-131-30/+39
| | | | | | | Co-authored-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/40 Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* Initial MMO implementationMrPurple6662025-04-281-4/+128
| | | | MMO (Multithreaded Memory Operations)
* Better FastMemcpy and FastMemsetMrPurple6662025-04-281-10/+163
| | | | Use 16-byte copy paths
* Replace std::memcpy/memset with intrinsics on known sizesMrPurple6662025-04-281-9/+49
|
* "Merge Tagged PR 13018"yuzubot2024-03-031-2/+1
|
* scope_exit: Make constexprFearlessTobi2024-02-191-4/+4
| | | | | Allows the use of the macro in constexpr-contexts. Also avoids some potential problems when nesting braces inside it.
* atomic_ops: Remove volatile qualifierMerry2024-01-271-4/+2
|
* SMMU: Add Android compatibilityFernando Sahmkow2024-01-181-36/+26
|
* SMMU: Implement physical memory mirroringFernando Sahmkow2024-01-181-21/+32
|
* SMMU: Initial adaptation to video_core.Fernando Sahmkow2024-01-181-7/+18
|
* core: track separate heap allocation for linuxLiam2023-12-251-23/+63
|
* general: properly support multiple memory instancesLiam2023-12-221-14/+14
|
* core: refactor emulated cpu core activationLiam2023-12-041-7/+3
|
* Address more review commentsGPUCode2023-11-251-0/+50
|
* arm: Implement native code execution backendLiam2023-11-251-0/+13
|
* core: Respect memory permissions in MapGPUCode2023-11-251-4/+4
|
* Merge pull request #11995 from FernandoS27/you-dont-need-the-new-iphoneliamwhite2023-11-161-5/+20
|\ | | | | Revert PR #11806 and do a proper fix to the memory handling.
| * Memory: Fix invalidation handling from the CPU/ServicesFernando Sahmkow2023-11-121-5/+20
| |
* | kernel: add KPageTableBaseLiam2023-11-101-3/+3
|/ | | | Co-authored-by: Kelebek1 <eeeedddccc@hotmail.co.uk>
* Merge pull request #11155 from liamwhite/memory3liamwhite2023-07-281-3/+18
|\ | | | | memory: check page against address space size
| * memory: check page against address space sizeLiam2023-07-251-3/+18
| |
* | Merge pull request #10990 from comex/ubsanliamwhite2023-07-261-13/+17
|\ \ | |/ |/| Fixes and workarounds to make UBSan happier on macOS
| * Fixes and workarounds to make UBSan happier on macOScomex2023-07-151-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are still some other issues not addressed here, but it's a start. Workarounds for false-positive reports: - `RasterizerAccelerated`: Put a gigantic array behind a `unique_ptr`, because UBSan has a [hardcoded limit](https://stackoverflow.com/questions/64531383/c-runtime-error-using-fsanitize-undefined-object-has-a-possibly-invalid-vp) of how big it thinks objects can be, specifically when dealing with offset-to-top values used with multiple inheritance. Hopefully this doesn't have a performance impact. - `QueryCacheBase::QueryCacheBase`: Avoid an operation that UBSan thinks is UB even though it at least arguably isn't. See the link in the comment for more information. Fixes for correct reports: - `PageTable`, `Memory`: Use `uintptr_t` values instead of pointers to avoid UB from pointer overflow (when pointer arithmetic wraps around the address space). - `KScheduler::Reload`: `thread->GetOwnerProcess()` can be `nullptr`; avoid calling methods on it in this case. (The existing code returns a garbage reference to a field, which is then passed into `LoadWatchpointArray`, and apparently it's never used, so it's harmless in practice but still triggers UBSan.) - `KAutoObject::Close`: This function calls `this->Destroy()`, which overwrites the beginning of the object with junk (specifically a free list pointer). Then it calls `this->UnregisterWithKernel()`. UBSan complains about a type mismatch because the vtable has been overwritten, and I believe this is indeed UB. `UnregisterWithKernel` also loads `m_kernel` from the 'freed' object, which seems to be technically safe (the overwriting doesn't extend as far as that field), but seems dubious. Switch to a `static` method and load `m_kernel` in advance.
* | memory: minimize dependency on processLiam2023-07-221-58/+57
| |
* | k_process: PageTable -> GetPageTableLiam2023-07-141-4/+4
|/
* Use spans over guest memory where possible instead of copying data.Kelebek12023-07-021-5/+49
|
* Memory Tracking: Optimize tracking to only use atomic writes when contested ↵Fernando Sahmkow2023-06-281-6/+33
| | | | with the host GPU
* MemoryTracking: Initial setup of atomic writes.Fernando Sahmkow2023-06-281-3/+4
|
* Address feedback, add CR notice, etcFernando Sahmkow2023-05-071-6/+5
|
* Settings: add option to enable / disable reactive flushingFernando Sahmkow2023-05-071-1/+2
|
* GPU: Add Reactive flushingFernando Sahmkow2023-05-071-6/+21
|