aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/memory_manager.cpp
Commit message (Collapse)AuthorAgeFilesLines
* nx2: leave unwritten sparse blocks without memory when they get zerosTakoroka2 days1-2/+2
| | | | | | | | | | | Title 1 clears about 1 GB of its sparse regions at boot through the GPU memory manager. Every block the clear touched got 4 MiB of guest memory, which the clear itself then committed on the host, and counted as written, so the texture cache gave the images over it device memory too. A block nobody wrote reads zero already: when the part of a write that lands on it is all zero, leave it as it is. (cherry picked from commit 0d7ff63fd1a373cecff6ba91022c9027e801e53f)
* memory_manager: copy big pages without host memory page by pageTakoroka3 days1-8/+12
| | | | | | | | | | | GPU reads and writes of a continuous big page copied through GetPointer() without checking it; the small-page path checks. A big page whose host memory is not there yet (a Switch 2 region backed as it is written, with its backing pending) made that memcpy fault: Mario Kart World crashed in WriteBlockImpl (access violation) on its title screen in two runs of a build on the 10-31 nx2. Such a page now takes the per-page copy, which reports and skips missing pages, as non-continuous big pages already did. Three 10-minute runs after the change, no crash.
* nx2: give sparse regions memory only where the GPU writesTakoroka4 days1-8/+22
| | | | | | | | | | | | | | | | | | | | | | nx2:gpu 214 regions with the sparse flag (word 7 bit 0x200) are Mario Kart World's terrain texture arrays and layer pools, 170 MB to 5.8 GB, mostly empty. Backed whole they ran the graphics pool dry (26 "could not allocate" per session, later regions without memory), and backing a block at a time made the texture cache rebuild the 1.45 GB arrays each time a block was mapped. A sparse region now gets a device (SMMU) range of its own when it is created, mapped for the GPU at once, so its GPU mapping never changes. Before a GPU-side write lands in it (WriteBlock, Write<T>), the 4 MiB blocks it touches get memory, cleared, behind their device pages. Unbacked device pages read zero and drop writes instead of crashing, and the unmapped-device-access errors are logged 16 times, not once per page. nx2:gpu 215 releases the device range and the blocks after the GPU is done with them. The log reports GPU-only memory in use and its peak. Mario Kart World, 180 s: no allocation failures; ~2.8 GB of terrain blocks get memory instead of 6.5 GB of whole regions, next to 3 GB of ordinary GPU-only regions. Terrain renders as before.
* memory_manager: notify the caches once per changed rangeTakoroka4 days1-2/+32
| | | | | | | PageTableOp and BigPageTableOp called ModifyGPUMemory for every page whose entry changed, and each call scans the texture and buffer caches. Mapping one of Mario Kart World's 1.45 GB sparse regions made ~370,000 of those scans. Runs of changed pages are now reported as one range.
* video_core: cheaper small GPU reads, buffer usage tracking and compute uniformsTakoroka6 days1-0/+10
| | | | | | | | | | | | | | - MemoryManager::ReadBlockUnsafe reads within one 4 KiB page through a single translation (as Read<T> does) instead of the page walk: texture and sampler descriptors, several per draw (2.6% -> 0.1% of title 1's GPU thread). - UsageTracker skips ranges it tracked just before (until Reset): draws bind the same multi-megabyte storage buffers again and again, and each Track wrote a word per 4 KiB (2.0% -> 0.7%). - Small compute uniform buffers the GPU has not written are streamed, as graphics ones are; synchronizing them re-protected pages an inline upload had just unprotected, two VirtualProtect calls per dispatch (1.9% -> 0.7%, page protection 3.2% -> 2.3%).
* Switch 2: Turing macros, native compute, Ampere shader lowering, native tilingTakoroka7 days1-0/+4
| | | | | | | | | | | | | | | | | From changes.patch: the TU104/GA10x MME interpreter (shared macro context for the process's channels, also on the compute class), native compute with QMD 3.0 dependency scheduling, the Ampere-to-Maxwell shader lowering, native vertex stream sizes, and the console's GOB swizzle for textures, DMA copies and the host unswizzle shaders. Switch 2 channels turn all of it on at init. The lowering is widened for title 4 (all 32 of its programs lower): general TEX (any dimension/LOD/mask, operand split 1+1/2+1/2+2/4+n, any but consistent descriptor buffer), cube/array, SULD channel masks, 128-bit STG, indexed IPA, VOTE, SHFL with any immediate or predicate output, R2P/P2R byte select, uniform ULOP3/ULEA/UBREV/UFLO.SH/UISETP signed/UMOV URZ, IMNMX cbuf, IADD3 and FFMA uniform operands, FMUL /4 /8 x8, and BSSY/BSYNC/BREAK/WARPSYNC as no-ops. The capture stops at unmapped memory. EDEN_NX2_SHADER_DUMP dumps every native program; tools in C:\dev\nx2work test the lowering offline.
* Switch 2: suspend channels on semaphore acquires; fix pushbuffer desyncsTakoroka7 days1-1/+4
| | | | | | | | | | | | | | | | NVN2 gates command buffers with semaphores the CPU releases after writing them. Eden read past unmet SEMAPHORED acquires, so it executed stale commands and desynchronised. Channels now suspend on an unmet acquire and resume from the same word once it is met (scheduler keeps the waiting channels, the GPU thread polls them), as in changes.patch. Also: methods split across GPFIFO entries around a called command buffer are set aside and resumed; subchannel 2 defaults to inline-to-memory; unbound subchannels and out-of-range compute/DMA methods are dropped instead of crashing; 4-byte semaphore releases no longer write 16 bytes; Ampere SEM_PAYLOAD_HI/SEM_EXECUTE no longer spin as Kepler acquires; unmapped GPU reads log instead of asserting. Debug aids: EDEN_NX2_PB_CHECK (pushbuffer changed after submit), EDEN_NX2_QUERY_TRACE, a one-time pushbuffer dump.
* Switch 2: native memory/images, GPU-accessible attribute, TSG subcontexts, ↵Takoroka7 days1-0/+13
| | | | | | | | | | | | | syncpoint shim - gsv 111/112/114/423/429/430/314/315/435 track native memory and images with real ids (meanings from changes.patch); 1510/435 use its block-linear layout. - svc 0x80 sets a real GpuAccessible (0x20) memory attribute (from changes.patch). - Characteristics report TSG subcontexts (flag 22, 64 per TSG at 0xb4); NvRm otherwise allows one subcontext and a second NVN queue fails its setup. - Syncpoint shim: flag 26, address-space ioctl 0xB, and GPU reads of the shim page return guest syncpoint values (scheme from changes.patch). - EDEN_NX2_IPC_TRACE also logs TIPC commands; gdbrsp.py watch/mem improvements.
* [*] Remove Fix{Static,Small}VectorADL workaround for GCC 12 (#4386)lizzie2026-10-121-1/+1
| | | | | | | | | | | | | | | 1. We demand at least, minimum, gcc 14 2. Debian stable boost uses a newer version https://packages.debian.org/trixie/libboost-all-dev, so fix isn't longer required - [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. ------------------- Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4386 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev>
* [common/core/dynarmic] Optimize page table allocations (#4219)Exverge2026-09-091-2/+2
| | | | | | | | | | | | | | 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>
* [video_core] use bool params for read/writes and cascade them thru the ↵lizzie2026-07-181-127/+84
| | | | | | | | | | | | | calltree (#4001) should make codegen a tad bit better and reduce icache pressure for what is otherwise a glorified memcpy Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4001 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
* [video_core] simplify InvalidationAccumulator (#3890)lizzie2026-04-281-25/+19
| | | | | | | | | | various redundant fields aren't required, so just redo it for good measure Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3890 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
* [common/logging] Simplify logging logic and fix issues when logging before ↵lizzie2026-03-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [compat] Debian stable gcc12/clang14 compilation fixes (#2763)lizzie2025-10-181-1/+3
| | | | | | | | | | | | | Mainly because - while we can just give out an AppImage and call it a day - building natively should be an option for all major distros. And "base" stable debian doesn't provide a new enough g++/clang++ so... we need to make some "fixups". Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2763 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>
* [meta] fix license headers (#2547)lizzie2025-09-211-0/+3
| | | | | | | Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2547 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-2/+2
| | | | | | | | | | | | | | 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>
* MemoryManager: Reduce the page table size based on last big page address.Fernando Sahmkow2024-02-011-8/+9
|
* Core: Eliminate core/memory dependancies.Fernando Sahmkow2024-01-181-4/+4
|
* SMMU: Fix 8Gb layout.Fernando Sahmkow2024-01-181-0/+3
|
* GPU SMMU: Expand to 34 bitsFernando Sahmkow2024-01-181-7/+11
|
* SMMU: Initial adaptation to video_core.Fernando Sahmkow2024-01-181-101/+103
|
* Use spans over guest memory where possible instead of copying data.Kelebek12023-07-021-7/+23
|
* Remove memory allocations in some hot pathsKelebek12023-06-221-6/+7
|
* Use current GPU address when unmapping GPU pages, not the baseKelebek12023-06-191-2/+2
|
* Memory manager: Fix possible softlockFernando Sahmkow2023-05-041-4/+5
|
* MemoryManager: Fix race conditions.Fernando Sahmkow2023-04-281-3/+7
|
* Fixes 'Continous' typoMax Dunbar2023-03-291-17/+17
|
* memory: rename global memory references to application memoryLiam2023-03-231-1/+1
|
* Revert "MemoryManager: use fastmem directly."Merry2023-01-251-31/+9
| | | | This reverts commit 7f18e3bb898911343e3909f676dc96f3a34b1e95.
* BufferBase: Don't ignore GPU pages.Fernando Sahmkow2023-01-051-1/+1
|
* MemoryManager: use fastmem directly.Fernando Sahmkow2023-01-051-9/+31
|
* video_core: Cache GPU internal writes.Fernando Sahmkow2023-01-051-14/+48
|
* RasterizerMemory: Add filtering for flushing/invalidation operations.Fernando Sahmkow2023-01-011-27/+33
|
* MacroHLE: Reduce massive calculations on sizing estimation.Fernando Sahmkow2023-01-011-85/+6
|
* MacroHLE: Add HLE replacement for base vertex and base instance.Fernando Sahmkow2023-01-011-1/+9
|
* MacroHLE: Add Index Buffer size estimation.Fernando Sahmkow2023-01-011-3/+50
|
* video_core:Fix vmm kinds size errorFengChen2022-11-061-1/+1
|
* general: Resolve -Wunused-but-set-variableMorph2022-10-221-2/+2
|
* video_core: Implement memory manager page kindFengChen2022-10-171-10/+51
|
* General: Fix clang format.Fernando Sahmkow2022-10-061-1/+0
|
* Buffer Cache: Deduce vertex array limit from memory layout when limit is the ↵Fernando Sahmkow2022-10-061-1/+1
| | | | highest possible.
* DMA & InlineToMemory Engines Rework.bunnei2022-10-061-0/+91
|
* Memory Manager: ensure safety of GPU to CPU address.Fernando Sahmkow2022-10-061-0/+3
|
* MemoryManager: Fix errors popping out.Fernando Sahmkow2022-10-061-4/+8
|
* MemoryManager: Finish up the initial implementation.Fernando Sahmkow2022-10-061-46/+131
|
* MemoryManager: initial multi paging system implementation.Fernando Sahmkow2022-10-061-173/+263
|
* Texture cache: Fix the remaining issues with memory mnagement and unmapping.Fernando Sahmkow2022-10-061-1/+10
|
* Refactor VideoCore to use AS sepparate from Channel.Fernando Sahmkow2022-10-061-1/+4
|
* NVDRV: Remake ASGPUFernando Sahmkow2022-10-061-3/+7
|
* MemoryManager: Temporary Fix for NVDEC.Fernando Sahmkow2022-10-061-1/+1
|