[PR #3066] [MERGED] texture_cache: Basic handling of partially resident images #3191

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3066
Author: @raphaelthegreat
Created: 6/9/2025
Status: Merged
Merged: 6/9/2025
Merged by: @squidbus

Base: mainHead: prt-init


📝 Commits (3)

  • d279dfa texture_cache: Avoid gpu tracking assert on sparse image
  • 1db18c9 tile_manager: Downgrade assert to error
  • 79daeba fix macos

📊 Changes

6 files changed (+73 additions, -3 deletions)

View changed files

📝 src/core/libraries/kernel/memory.cpp (+3 -0)
📝 src/core/memory.cpp (+40 -0)
📝 src/core/memory.h (+16 -0)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+5 -2)
📝 src/video_core/buffer_cache/buffer_cache.h (+5 -0)
📝 src/video_core/texture_cache/tile_manager.cpp (+4 -1)

📄 Description

This allows Driveclub (CUSA00093) to go in-game without any hacks.

The game setups a PRT area, maps only some pages inside it and creates a render target covering all of it causing a gpu tracking assert to kick in. To avoid this the memory manager will register active PRT areas and map those areas to gpu, so the page manager can track any image inside the region. Meanwhile access to cpu memory will be handled via a new function CopySparseMemory which behaves the same as a memcpy, except when source address is a PRT area, where it will copy only mapped regions, while zeroing unmapped areas.

Using host sparse feature would be ideal, but its very inconvenient as host sparse page size and alignment might differ a lot from the guest. So its a lot easier to eat the extra memory cost of creating the non sparse version of the full image. This can also be expanded in the future with subresource uploads, on every gpu map we can invalidate the texture cache and reupload parts of PRT that were mapped. This isn't done here as that would trash the entire thing (due to unimplemented subres upload) and DC uses it as a render target


🔄 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/3066 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 6/9/2025 **Status:** ✅ Merged **Merged:** 6/9/2025 **Merged by:** [@squidbus](https://github.com/squidbus) **Base:** `main` ← **Head:** `prt-init` --- ### 📝 Commits (3) - [`d279dfa`](https://github.com/shadps4-emu/shadPS4/commit/d279dfa0db914cf3521ee06d5618dded3d5d39f9) texture_cache: Avoid gpu tracking assert on sparse image - [`1db18c9`](https://github.com/shadps4-emu/shadPS4/commit/1db18c97e933cecb609af286de1db4b1fa9e4341) tile_manager: Downgrade assert to error - [`79daeba`](https://github.com/shadps4-emu/shadPS4/commit/79daebab1978ae86c7bff5f7f75225bad5744857) fix macos ### 📊 Changes **6 files changed** (+73 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/core/libraries/kernel/memory.cpp` (+3 -0) 📝 `src/core/memory.cpp` (+40 -0) 📝 `src/core/memory.h` (+16 -0) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+5 -2) 📝 `src/video_core/buffer_cache/buffer_cache.h` (+5 -0) 📝 `src/video_core/texture_cache/tile_manager.cpp` (+4 -1) </details> ### 📄 Description This allows Driveclub (CUSA00093) to go in-game without any hacks. The game setups a PRT area, maps only some pages inside it and creates a render target covering all of it causing a gpu tracking assert to kick in. To avoid this the memory manager will register active PRT areas and map those areas to gpu, so the page manager can track any image inside the region. Meanwhile access to cpu memory will be handled via a new function CopySparseMemory which behaves the same as a memcpy, except when source address is a PRT area, where it will copy only mapped regions, while zeroing unmapped areas. Using host sparse feature would be ideal, but its very inconvenient as host sparse page size and alignment might differ a lot from the guest. So its a lot easier to eat the extra memory cost of creating the non sparse version of the full image. This can also be expanded in the future with subresource uploads, on every gpu map we can invalidate the texture cache and reupload parts of PRT that were mapped. This isn't done here as that would trash the entire thing (due to unimplemented subres upload) and DC uses it as a render target --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:02:46 +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#3191
No description provided.