aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/texture_cache/util.cpp
Commit message (Collapse)AuthorAgeFilesLines
* texture_cache: back large sparse 2D images by sparse blockTakoroka3 days1-0/+204
| | | | | | | | | | | | | | | | | | | | | | | | | Mario Kart World's nine world-sized masks (R8 16384x16384, RG16 and R16 8192x8192, 170-341 MB each) live in sparse regions the game maps its own memory into, a few MiB of each. Since a mapped tile counts as written, the texture cache backed and uploaded each mask in full: about 2.9 GB of device memory, and a whole-mask upload for every tile the game streamed in. Such images (single layer, one texel per block, colour, in a sparse region, 32 MiB or more) are now unbacked SparseTiles images. The texture cache records the guest ranges written to them; Image::BindTiles gives the host sparse blocks under those ranges memory, and only those rectangles are unswizzled, a row of whole GOB blocks at a time, and uploaded. A new image starts with the tiles the game maps there (nx2:gpu 216 now records them per 64 KiB), or the written blocks where it maps none. Unmapped tiles keep their blocks and are loaded as zeros. Checked against the full unswizzle on 400 ordinary game images (row padding, mip chains, odd sizes): no row differs. Not on AMD drivers, which cannot sample images with unbound memory. Mario Kart World title screen, 150 s, against backing the masks whole: dedicated VRAM 6.6 -> 6.2 GB, shared 1.0 -> 0.3 GB, peak 8.2 -> 6.9 GB.
* 1st pass of review: code cleanup & windows testnéo Luigi4 days1-5/+5
| | | | Assisted-by: Claude Opus 5.5 (review, cleanup and log analysis)
* ASTC: decode and re-compress to BC1/BC3 on the GPU; texture cache budgetTakoroka6 days1-0/+29
| | | | | | | | | | | | | | | | | | | - accelerate_astc=Gpu with astc_recompression=Bc1/Bc3 now decodes ASTC with the GPU decoder into a temporary RGBA8 image (dedicated memory, freed once the GPU is past it) and compresses it with a new compute shader (bc_encoder.comp: bounding-box endpoints along the colours' covariance, inset 1/16, nearest palette entry; BC3 alpha ramp; BC1 punch-through), then copies the blocks into the image. No CPU decode, so streamed textures are ready the frame they are first used instead of showing placeholders for seconds; the decode pass no longer waits for the GPU on this path. - The CPU path (CpuAsynchronous) fills a new image with zero blocks before its first decode instead of showing stale VRAM, and the transcode pool is a quarter of the hardware threads. - Switch 2 titles: collector thresholds near the device budget, re-read every 60 frames from VK_EXT_memory_budget (another game shrank it from 7.0 to 5.4 GB). - EDEN_NX2_HIDE_WINDOW=0 now leaves the window visible.
* Texture cache: stop the churn, the per-frame image leak and garbage texturesTakoroka6 days1-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | - Unmapped GPU addresses get a stand-in CPU address fixed by the GPU address. A fresh one per lookup meant FindImage never found an image there again: title 1's bloom chain at 0xf0000-0x15b600 was re-created on every use (~5,400 images per 600 frames), filling VRAM. - ASTC whose blocks carry no alpha (exact endpoint-mode scan reusing the decoder's block parsing) is re-compressed to BC1 instead of BC3, half the size; about 70% of title 1's ASTC qualifies. Copies between BC1 and BC3 hosts are skipped (their guest data is uploaded instead). EDEN_NX2_ASTC_BC1=0 turns it off. - Deleting an image cancels every decode still queued for it. An image re-decoded mid-decode has two; the first to finish cleared IsDecoding, the second was not cancelled and was uploaded into the next image to take the slot: garbage textures (the title logo, road patches) and a staging overrun when that image was smaller. - Diagnostics: images created and deleted per 600 frames by shape, collector deletions, async decodes, BC1/BC3 split; collector thresholds overridable (EDEN_NX2_TC_EXPECTED_MIB/CRITICAL_MIB); GPU ASTC decode wait timing (EDEN_NX2_ASTC_FLUSH=1 submits without it). Title 1 attract loop: device memory 4.8-5.1 GB instead of 5.9-6.1 GB, no decoded textures evicted, ~17 -> 22-23 fps.
* Keep huge ASTC arrays from a lower mip on the host (title 1 terrain)Takoroka7 days1-0/+7
| | | | | | | | | | | | | | | Title 1's terrain virtual textures are 8192x8192x68 ASTC 8x8 sRGB arrays with 12 levels: 1.5 GB in guest memory (fully backed) but 23 GB each as the RGBA8 Eden decodes ASTC to, so they were created unbacked and the near terrain sampled black. A GPU-decoded ASTC 2D array over 1 GiB decoded now keeps only the levels from the first one that fits in 512 MiB (here 3: 1024x1024, 380 MiB); host mip 0 is that guest level. Uploads read each layer's tail of the mip chain into a compact buffer and decode only those levels, views shift their level range, and these images are never downloaded. Normalized coordinates and derivative LOD address the smaller image correctly; the nearest terrain is lower resolution than on the console. Also logs how unbacked images are used (views, render targets, blits, DMA).
* Switch 2: Turing macros, native compute, Ampere shader lowering, native tilingTakoroka7 days1-3/+3
| | | | | | | | | | | | | | | | | 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.
* [video_core] Increase MAX_MIP_LEVELS to 16 according to specs (#2965)MaranBr2025-11-071-2/+3
| | | | | | | | | This increases MAX_MIP_LEVELS from 14 to 16, according to specs. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2965 Reviewed-by: Maufeat <sahyno1996@gmail.com> Co-authored-by: MaranBr <maranbr@outlook.com> Co-committed-by: MaranBr <maranbr@outlook.com>
* [video_core] Bypass mip level assertion to ASSERT_MSG (#2914)JPikachu2025-11-011-0/+2
| | | | | | | | | | | | | | | | This will bypass the check and continue execution, preventing crashes in cases where games (like CTGP-DX) may request more mip levels than supported. This is a temporary solution to bypass instead of ending the crashing when asserts fail. Co-authored-by: MaranBr <maranbr@outlook.com> Co-authored-by: JPikachu <jpikachu.eden@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2914 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Co-authored-by: JPikachu <jpikachu@eden-emu.dev> Co-committed-by: JPikachu <jpikachu@eden-emu.dev>
* [cmake] enable clang-cl and WoA builds (#348)lizzie2025-09-091-7/+7
| | | | | | | | | | | | | | 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>
* [texture_cache] Enforce conservative 3D texture aliasing. Consistently ↵weakboson2025-08-041-8/+14
| | | | | | | | | | | | | merge/lookup images. (#196) Previously, the merging strategy is permissive but the lookup strategy is strict. Together they create a infinite merge loop because lookup always fails and merges are always executed. The last attempt to fix this issue made the lookup strategy more permissive which created unexpected aliased textures. This commit implements an alternative: make the merging strategy strict. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/196 Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev> Co-authored-by: weakboson <weakboson@quantum-field.net> Co-committed-by: weakboson <weakboson@quantum-field.net>
* [vk] Remove improper check for image depth in texture cache. (#164)weakboson2025-07-311-4/+7
| | | | | | | | | | When looking for existing images, ImageBase::TryFindBase checks the depth of the existing image to be greater than the layer of the base + depth of the candidate. However the depth of images are not updated when cache were merged causing the lookup to fail. This commit disables this faulty check to fix a critical memory leak that crashes the emulator in some games. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/164 Co-authored-by: weakboson <weakboson@quantum-field.net> Co-committed-by: weakboson <weakboson@quantum-field.net>
* Core: Eliminate core/memory dependancies.Fernando Sahmkow2024-01-181-1/+0
|
* SMMU: Initial adaptation to video_core.Fernando Sahmkow2024-01-181-1/+3
|
* video_core: Fix buffer_row_length computation for linear compressed texturesGPUCode2023-12-261-10/+6
|
* Merge pull request #11788 from Squall-Leonhart/IFREMOVEDFernando S2023-10-171-2/+9
|\ | | | | [crash fix]brings back the removed if statement in util.cpp and adds the num_level test to it like previous discontinued PR
| * brings back the removed If statement and adds the num_level testSquall Leonhart2023-10-151-2/+9
| | | | | | | | | | | | | | | | | | | | This resolves the out of bounds read/writes in the linear swizzler, it brings back the scaled TOTK Recall bug however, pending further work in the block size calculation. Recall is not glitched in the Dynamic FPS resolution mod to the degree that it is in the native yuzu scaler, this can be a workaround for the time being. The recall effect is constructed from multiple 320x180 texture slices, it breaking may have a similar origin to https://github.com/Ryujinx/Ryujinx/pull/5640 but it may also be connected to the other deficiencies identified in the Yuzu size calculations, such as no apparent implementation of slice testing for end of slce depth as opposed to full aligned size as implemented in https://github.com/Ryujinx/Ryujinx/pull/5220
* | Merge pull request #11743 from Squall-Leonhart/IFREMOVEDFernando S2023-10-111-2/+2
|\| | | | | Fix mistaken usage of info.block instead of level_info.block
| * Fix mistaken usage of info.block instead of level_info.blockSquall-Leonhart2023-10-111-2/+2
| | | | | | | | | | | | Fixed an error on my part, in the last change I had mistakenly passed unadjusted block info into FullUploadSwizzles and UnswizzleImage Revert (my mistaken changing of) the construction of SwizzleParameters in UnswizzleImage and FullUploadSwizzles to use level_info.block instead of info.block. This ensures that the block information used in the swizzling process is correctly adjusted for each mip level.
* | Merge pull request #11534 from Squall-Leonhart/IFREMOVEDliamwhite2023-10-101-21/+20
|\| | | | | Partial revert of #10433 (Texture Cache Util: Fix block depth adjustment on slices)
| * Reuse part of my previous idea to to use num_levels to check within ↵Squall-Leonhart2023-09-201-14/+20
| | | | | | | | | | | | AdjustMipBlockSize The partial revert was not enough for Tsukihime, this might do the trick
| * Partial revert of #10433Squall Leonhart2023-09-181-9/+2
| | | | | | | | | | The If block in this change was causing some 2D textures to be treated as if their mip 0 was a 3D Slice, this could be ascertained as the same texture viewed from different distances would render fine, but then close up would look like a decoding failure. It also resulted in some 3D ASTC textures not being scaled appropriate leading to broken graphical effects such as the jagged TOTK recall animation being a circle, as the If block was only accepting the image based on its original info without any adjustments applied.
* | ci: fix new codespell errorsLiam2023-10-021-1/+1
|/
* Use spans over guest memory where possible instead of copying data.Kelebek12023-07-021-18/+8
|
* renderer_vulkan: Add support for VK_KHR_image_format_listGPUCode2023-07-011-7/+2
|
* video_core: Add BCn decoding supportGPUCode2023-06-271-9/+15
|
* Remove memory allocations in some hot pathsKelebek12023-06-221-21/+27
|
* Texture Cache Util: Fix block depth adjustment on slices.Fernando Sahmkow2023-05-241-2/+13
|
* textures: add BC1 and BC3 compressors and recompression settingLiam2023-05-231-11/+66
|
* Texture Cache: Fix ASTC texturesFernando Sahmkow2023-05-091-5/+5
|
* Engines: Implement Accelerate DMA Texture.Fernando Sahmkow2023-03-051-10/+88
|
* texture_cache: OpenGL: Implement MSAA uploads and copiesameerj2023-02-111-5/+0
|
* texture_cache: Use Common::ScratchBuffer for swizzle buffersameerj2022-12-251-3/+3
|
* texture_cache: Use pre-allocated buffer for texture downloadsameerj2022-12-251-5/+6
|
* texture_cache: Use pre-allocated buffer for texture uploadsameerj2022-12-251-6/+3
|
* video_core: Fix SNORM texture buffer emulating error (#9001)Feng Chen2022-11-041-1/+0
|
* DMA & InlineToMemory Engines Rework.bunnei2022-10-061-1/+0
|
* VideoCore: Extra Fixes.Fernando Sahmkow2022-10-061-1/+1
|
* chore: add missing SPDX tagsAndrea Pappacoda2022-04-281-21/+2
| | | | Follow-up to 2b87305d319f0bd04da36fb96314934f37b12637
* general: Convert source file copyright comments over to SPDXMorph2022-04-231-3/+2
| | | | | This formats all copyright comments according to SPDX formatting guidelines. Additionally, this resolves the remaining GPLv2 only licensed files by relicensing them to GPLv2.0-or-later.
* Revert "texture_cache/util: Remove unneeded ReadBlockUnsafe"bunnei2022-04-041-0/+1
|
* texture_cache/util: Remove unneeded ReadBlockUnsafeameerj2022-04-041-1/+0
| | | | This call was reading GPU memory into the dst buffer, which is then overwritten by the SwizzleTexture call.
* texture_cache/util: Fix s32 overflow when resolving overlapsameerj2021-12-311-5/+5
|
* Texture Cache: Redesigning the blitting system (again).Fernando Sahmkow2021-11-271-13/+19
|
* Texture Cache: Fix issue with blitting 3D textures.Fernando Sahmkow2021-11-221-2/+4
|
* TextureCache: Eliminate format deduction as full depth conversion has been ↵Fernando Sahmkow2021-11-211-25/+3
| | | | supported.
* TextureCache: Further fixes on resolve algorithm.Fernando Sahmkow2021-11-191-12/+13
|
* TextureCache: Fix regression caused by ART and improve blit detection ↵Fernando Sahmkow2021-11-191-4/+24
| | | | algorithm to be smarter.
* Texture Cache: Fix blitting.Fernando Sahmkow2021-11-161-2/+2
|
* TextureCache: fix rescaling in aliases and overlap joins.FernandoS272021-11-161-2/+6
|
* texture_cache/util: Fix size calculations of multisampled imagesReinUsesLisp2021-07-181-53/+33
| | | | | | | | | | | | | | | | On the texture cache we handle multisampled images by keeping their real size in samples (e.g. 1920x1080 with 4 samples is 3840x2160). This works nicely with size matches and other comparisons, but the calculation for guest sizes was not having this in mind, and the size was being multiplied (again) by the number of samples per dimension. For example a 3840x2160 texture cache image had its width and height multiplied by 2, resulting in a much larger texture. Fix this issue. - Fixes performance regression on cooking related titles when an unrelated bug was fixed.