[PR #414] [MERGED] video_core: Crucial buffer cache fixes + proper GPU clears #1548

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/414
Author: @raphaelthegreat
Created: 8/12/2024
Status: Merged
Merged: 8/13/2024
Merged by: @raphaelthegreat

Base: mainHead: buffer-fixes


📝 Commits (10+)

  • 0bac6e8 translator: Use templates for stronger type guarantees
  • 594606c spirv: Define buffer offsets upfront
  • b8084d3 buffer_cache: Use dynamic vertex input when available
  • 6ef31ef externals: Update boost
  • 27e9026 spirv: Use runtime array for ssbos
  • ceb7e30 fs: Lock when doing case insensitive search
  • 52057b4 texture_cache: More precise invalidation from compute
  • 121d850 texture_cache: Use hashes for protect gpu modified images from reupload
  • 8d4a92a translator: Treat V_CNDMASK as float
  • 7243b08 translator: Small optimization for V_SAD_U32

📊 Changes

23 files changed (+326 additions, -300 deletions)

View changed files

📝 externals/ext-boost (+1 -1)
📝 src/core/file_sys/fs.cpp (+1 -0)
📝 src/core/libraries/kernel/threads/semaphore.cpp (+0 -3)
📝 src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp (+1 -14)
📝 src/shader_recompiler/backend/spirv/emit_spirv_special.cpp (+3 -1)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.cpp (+16 -10)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.h (+3 -2)
📝 src/shader_recompiler/frontend/translate/translate.cpp (+93 -144)
📝 src/shader_recompiler/frontend/translate/translate.h (+4 -4)
📝 src/shader_recompiler/frontend/translate/vector_alu.cpp (+69 -78)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+41 -0)
📝 src/video_core/buffer_cache/buffer_cache.h (+6 -0)
📝 src/video_core/renderer_vulkan/renderer_vulkan.h (+2 -2)
📝 src/video_core/renderer_vulkan/vk_compute_pipeline.cpp (+2 -3)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp (+3 -0)
📝 src/video_core/renderer_vulkan/vk_instance.cpp (+7 -2)
📝 src/video_core/renderer_vulkan/vk_instance.h (+6 -0)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+4 -0)
📝 src/video_core/texture_cache/image.cpp (+1 -0)
📝 src/video_core/texture_cache/image.h (+1 -0)

...and 3 more files

📄 Description

Cherry-pick from https://github.com/shadps4-emu/shadPS4/pull/370 mostly.

  • Buffer offsets are now defined upfront. We can't define them on demand like previously as a buffer access might be inside a scope. If the same buffer is accessed again under a different scope it is invalid to reuse the Id of offset.
  • Use hashes to protect images from accidental re-upload. Guest might write some CPU data to the same page as a render target for example. This also fixes some flickering in simpler 2D games due to that.
  • When refreshing an image attempt to use a buffer provided from the buffer cache instead of uploading always from CPU. This particularly affects clears as guest performs them by writing to memory region of render target viewed as SSBO. Now the entire process can happen in the GPU giving more performance, and more correctness; we no longer upload whatever garbage values the CPU had in that region

🔄 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/414 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 8/12/2024 **Status:** ✅ Merged **Merged:** 8/13/2024 **Merged by:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Base:** `main` ← **Head:** `buffer-fixes` --- ### 📝 Commits (10+) - [`0bac6e8`](https://github.com/shadps4-emu/shadPS4/commit/0bac6e8e1ce6d401438a2c6d0c94cfc93c5aa05b) translator: Use templates for stronger type guarantees - [`594606c`](https://github.com/shadps4-emu/shadPS4/commit/594606c1c37e393e600b3fa97d91e411dc92985f) spirv: Define buffer offsets upfront - [`b8084d3`](https://github.com/shadps4-emu/shadPS4/commit/b8084d3ed8a60dafd29ffd3ecfafbbd45dd61a30) buffer_cache: Use dynamic vertex input when available - [`6ef31ef`](https://github.com/shadps4-emu/shadPS4/commit/6ef31ef6ea26cf41ef9de01e1eed63bb049bd900) externals: Update boost - [`27e9026`](https://github.com/shadps4-emu/shadPS4/commit/27e9026f5d36771c1fde37bb4282a8dece71968f) spirv: Use runtime array for ssbos - [`ceb7e30`](https://github.com/shadps4-emu/shadPS4/commit/ceb7e300e572e3aa2ddb51769fb17316e64934b3) fs: Lock when doing case insensitive search - [`52057b4`](https://github.com/shadps4-emu/shadPS4/commit/52057b467dec9729866d64433c4bb595d06e59db) texture_cache: More precise invalidation from compute - [`121d850`](https://github.com/shadps4-emu/shadPS4/commit/121d850fb2bb87a8625dc3956a326d96d58261ae) texture_cache: Use hashes for protect gpu modified images from reupload - [`8d4a92a`](https://github.com/shadps4-emu/shadPS4/commit/8d4a92a0cd713130ff6ad335b776725dfaa13403) translator: Treat V_CNDMASK as float - [`7243b08`](https://github.com/shadps4-emu/shadPS4/commit/7243b08fe8d29a9220f5e63fa0883c930fa42ca7) translator: Small optimization for V_SAD_U32 ### 📊 Changes **23 files changed** (+326 additions, -300 deletions) <details> <summary>View changed files</summary> 📝 `externals/ext-boost` (+1 -1) 📝 `src/core/file_sys/fs.cpp` (+1 -0) 📝 `src/core/libraries/kernel/threads/semaphore.cpp` (+0 -3) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp` (+1 -14) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_special.cpp` (+3 -1) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.cpp` (+16 -10) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.h` (+3 -2) 📝 `src/shader_recompiler/frontend/translate/translate.cpp` (+93 -144) 📝 `src/shader_recompiler/frontend/translate/translate.h` (+4 -4) 📝 `src/shader_recompiler/frontend/translate/vector_alu.cpp` (+69 -78) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+41 -0) 📝 `src/video_core/buffer_cache/buffer_cache.h` (+6 -0) 📝 `src/video_core/renderer_vulkan/renderer_vulkan.h` (+2 -2) 📝 `src/video_core/renderer_vulkan/vk_compute_pipeline.cpp` (+2 -3) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp` (+3 -0) 📝 `src/video_core/renderer_vulkan/vk_instance.cpp` (+7 -2) 📝 `src/video_core/renderer_vulkan/vk_instance.h` (+6 -0) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+4 -0) 📝 `src/video_core/texture_cache/image.cpp` (+1 -0) 📝 `src/video_core/texture_cache/image.h` (+1 -0) _...and 3 more files_ </details> ### 📄 Description Cherry-pick from https://github.com/shadps4-emu/shadPS4/pull/370 mostly. * Buffer offsets are now defined upfront. We can't define them on demand like previously as a buffer access might be inside a scope. If the same buffer is accessed again under a different scope it is invalid to reuse the Id of offset. * Use hashes to protect images from accidental re-upload. Guest might write some CPU data to the same page as a render target for example. This also fixes some flickering in simpler 2D games due to that. * When refreshing an image attempt to use a buffer provided from the buffer cache instead of uploading always from CPU. This particularly affects clears as guest performs them by writing to memory region of render target viewed as SSBO. Now the entire process can happen in the GPU giving more performance, and more correctness; we no longer upload whatever garbage values the CPU had in that region --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:13:01 +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#1548
No description provided.