[PR #3211] [MERGED] buffer_cache: Bring back upload batching and temporary buffer #3307

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3211
Author: @raphaelthegreat
Created: 7/8/2025
Status: Merged
Merged: 7/8/2025
Merged by: @georgemoralis

Base: mainHead: staging-fix


📝 Commits (2)

  • 4abffb2 buffer_cache: Bring back upload batching and temporary buffer
  • faee44a buffer_cache: Move buffer barriers and copy outside of lock range

📊 Changes

6 files changed (+96 additions, -35 deletions)

View changed files

📝 src/video_core/buffer_cache/buffer.cpp (+23 -7)
📝 src/video_core/buffer_cache/buffer.h (+2 -6)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+44 -12)
📝 src/video_core/buffer_cache/buffer_cache.h (+3 -0)
📝 src/video_core/buffer_cache/memory_tracker.h (+19 -9)
📝 src/video_core/renderer_vulkan/vk_scheduler.h (+5 -1)

📄 Description

This should fix regressions reported from https://github.com/shadps4-emu/shadPS4/pull/3186

Because that PR fused the write and read protections under a single function call, it was a requirement to move the actual memory copy part inside the lambda to perform it before the read protection kicks in. However on certain large data transfers it had potential for data corruption. If, for example, an upload had two copies, a 400MB and a 300MB one, the first one would fit in the staging buffer, very likely with an induced stall. However the second one wouldn't have space to fit alongside the other data, but it's also small enough for the buffer to fit it, so the staging buffer would cause a flush and wait to copy it, overwriting the previous transfer.

To address this the upload function has been reworked to allow for batching like previously but with the new locking behavior. Also the condition to use temporary buffers has been expanded to also include cases when staging buffer will stall, which should increase performance a little in some cases.


🔄 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/3211 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 7/8/2025 **Status:** ✅ Merged **Merged:** 7/8/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `staging-fix` --- ### 📝 Commits (2) - [`4abffb2`](https://github.com/shadps4-emu/shadPS4/commit/4abffb2489c27ab6e41b32977c4f349aa8c68485) buffer_cache: Bring back upload batching and temporary buffer - [`faee44a`](https://github.com/shadps4-emu/shadPS4/commit/faee44a820ab17860956df57f32ad323233bdf6e) buffer_cache: Move buffer barriers and copy outside of lock range ### 📊 Changes **6 files changed** (+96 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `src/video_core/buffer_cache/buffer.cpp` (+23 -7) 📝 `src/video_core/buffer_cache/buffer.h` (+2 -6) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+44 -12) 📝 `src/video_core/buffer_cache/buffer_cache.h` (+3 -0) 📝 `src/video_core/buffer_cache/memory_tracker.h` (+19 -9) 📝 `src/video_core/renderer_vulkan/vk_scheduler.h` (+5 -1) </details> ### 📄 Description This should fix regressions reported from https://github.com/shadps4-emu/shadPS4/pull/3186 Because that PR fused the write and read protections under a single function call, it was a requirement to move the actual memory copy part inside the lambda to perform it before the read protection kicks in. However on certain large data transfers it had potential for data corruption. If, for example, an upload had two copies, a 400MB and a 300MB one, the first one would fit in the staging buffer, very likely with an induced stall. However the second one wouldn't have space to fit alongside the other data, but it's also small enough for the buffer to fit it, so the staging buffer would cause a flush and wait to copy it, overwriting the previous transfer. To address this the upload function has been reworked to allow for batching like previously but with the new locking behavior. Also the condition to use temporary buffers has been expanded to also include cases when staging buffer will stall, which should increase performance a little in some cases. --- <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:13 +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#3307
No description provided.