[PR #3350] [MERGED] video_core: garbage collector (part 1) #3406

Closed
opened 2026-02-27 22:03:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3350
Author: @LNDF
Created: 7/30/2025
Status: Merged
Merged: 8/6/2025
Merged by: @LNDF

Base: mainHead: gc


📝 Commits (10+)

  • 5c39b7f Memory information
  • 0b764bc Buffer cache GC
  • 59c1691 Texture cache GC
  • ed3a475 Fix ChangeRegister
  • 527b99f Better image touching
  • 0468787 Buffer async download on GC destroy
  • c576a1e Handle image download, SKIP NON-LINEAR WORKAROUND
  • 5863735 Only download when not dirty
  • ba137aa Correctly handle BDA pagefile update
  • 35e12b9 Restructure ChangeRegistration

📊 Changes

14 files changed (+508 additions, -29 deletions)

View changed files

📝 CMakeLists.txt (+1 -0)
src/common/lru_cache.h (+135 -0)
📝 src/video_core/amdgpu/liverpool.cpp (+1 -1)
📝 src/video_core/buffer_cache/buffer.h (+9 -0)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+120 -22)
📝 src/video_core/buffer_cache/buffer_cache.h (+19 -1)
📝 src/video_core/page_manager.cpp (+1 -0)
📝 src/video_core/renderer_vulkan/vk_instance.cpp (+62 -0)
📝 src/video_core/renderer_vulkan/vk_instance.h (+23 -1)
📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+3 -1)
📝 src/video_core/renderer_vulkan/vk_rasterizer.h (+1 -1)
📝 src/video_core/texture_cache/image.h (+6 -0)
📝 src/video_core/texture_cache/texture_cache.cpp (+100 -0)
📝 src/video_core/texture_cache/texture_cache.h (+27 -2)

📄 Description

The intent is to implement a garbage collector for GPU resources.

This garbage collector is based on the yuzu implementation.

For anyone testing, you are noit suposed to see any inmediate effects upon launching the game. This is a garbage collector, and the goal is to delete OLD_DATA (😉) from GPU in order to keep memory usage under control.

A note regarding DMA: Due to how DMA is currently implemented, garbage collection will not work on buffers on games that make use of DMA. This is because current DMA implementation syncs all buffers, touching them all. Referencing my other DMA PR (#3197) since it could be solved there.

Checklist:

  • Memory usage collecting
  • Garbage collector for buffer cache
  • Garbage collector for texture cache*

* The texture cache will not garbage collect non-linear GPU modified images. This will be fixed in a future PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/3350 **Author:** [@LNDF](https://github.com/LNDF) **Created:** 7/30/2025 **Status:** ✅ Merged **Merged:** 8/6/2025 **Merged by:** [@LNDF](https://github.com/LNDF) **Base:** `main` ← **Head:** `gc` --- ### 📝 Commits (10+) - [`5c39b7f`](https://github.com/shadps4-emu/shadPS4/commit/5c39b7f10b9b76fc8cd29427a7e980595adc0937) Memory information - [`0b764bc`](https://github.com/shadps4-emu/shadPS4/commit/0b764bc8e025bdd4ff8755022c5681d8274fd5a4) Buffer cache GC - [`59c1691`](https://github.com/shadps4-emu/shadPS4/commit/59c1691b04172bf95c37aa17379f5d4578e38c31) Texture cache GC - [`ed3a475`](https://github.com/shadps4-emu/shadPS4/commit/ed3a475d1aba0eca52fc37a00437227873795b33) Fix ChangeRegister - [`527b99f`](https://github.com/shadps4-emu/shadPS4/commit/527b99fa0c704df49433f08b2aad5ce365ace033) Better image touching - [`0468787`](https://github.com/shadps4-emu/shadPS4/commit/0468787125d39b4009255162942f3aae93f31971) Buffer async download on GC destroy - [`c576a1e`](https://github.com/shadps4-emu/shadPS4/commit/c576a1ee4f8f507dcfb3e8e8b729429d1a453304) Handle image download, SKIP NON-LINEAR WORKAROUND - [`5863735`](https://github.com/shadps4-emu/shadPS4/commit/5863735c7b2be64e09cb586e68643b10329b239e) Only download when not dirty - [`ba137aa`](https://github.com/shadps4-emu/shadPS4/commit/ba137aa00b474549452df7173b4d1dc1766403ba) Correctly handle BDA pagefile update - [`35e12b9`](https://github.com/shadps4-emu/shadPS4/commit/35e12b904ece5fe9c545c071ddbe41d8925ed99f) Restructure ChangeRegistration ### 📊 Changes **14 files changed** (+508 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+1 -0) ➕ `src/common/lru_cache.h` (+135 -0) 📝 `src/video_core/amdgpu/liverpool.cpp` (+1 -1) 📝 `src/video_core/buffer_cache/buffer.h` (+9 -0) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+120 -22) 📝 `src/video_core/buffer_cache/buffer_cache.h` (+19 -1) 📝 `src/video_core/page_manager.cpp` (+1 -0) 📝 `src/video_core/renderer_vulkan/vk_instance.cpp` (+62 -0) 📝 `src/video_core/renderer_vulkan/vk_instance.h` (+23 -1) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+3 -1) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.h` (+1 -1) 📝 `src/video_core/texture_cache/image.h` (+6 -0) 📝 `src/video_core/texture_cache/texture_cache.cpp` (+100 -0) 📝 `src/video_core/texture_cache/texture_cache.h` (+27 -2) </details> ### 📄 Description The intent is to implement a garbage collector for GPU resources. This garbage collector is based on the yuzu implementation. For anyone testing, you are noit suposed to see any inmediate effects upon launching the game. This is a garbage collector, and the goal is to delete OLD_DATA (😉) from GPU in order to keep memory usage under control. A note regarding DMA: Due to how DMA is currently implemented, garbage collection will not work on buffers on games that make use of DMA. This is because current DMA implementation syncs all buffers, touching them all. Referencing my other DMA PR (#3197) since it could be solved there. Checklist: - [x] Memory usage collecting - [x] Garbage collector for buffer cache - [x] Garbage collector for texture cache* \* The texture cache will not garbage collect non-linear GPU modified images. This will be fixed in a future PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:03:35 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#3406
No description provided.