[PR #1683] [MERGED] renderer_vulkan: Introduce shader HLE system with copy shader implementation. #2245

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/1683
Author: @squidbus
Created: 12/7/2024
Status: Merged
Merged: 12/10/2024
Merged by: @raphaelthegreat

Base: mainHead: copy-shader-hle


📝 Commits (3)

  • 84e8168 renderer_vulkan: Introduce shader HLE system with copy shader implementation.
  • cc0c498 buffer_cache: Handle obtaining buffer views partially within buffers.
  • 363c6c1 vk_shader_hle: Make more efficient

📊 Changes

9 files changed (+195 additions, -5 deletions)

View changed files

📝 CMakeLists.txt (+2 -0)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+9 -1)
📝 src/video_core/buffer_cache/buffer_cache.h (+2 -1)
📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+6 -0)
📝 src/video_core/renderer_vulkan/vk_rasterizer.h (+8 -0)
📝 src/video_core/renderer_vulkan/vk_scheduler.h (+4 -0)
src/video_core/renderer_vulkan/vk_shader_hle.cpp (+139 -0)
src/video_core/renderer_vulkan/vk_shader_hle.h (+20 -0)
📝 src/video_core/texture_cache/texture_cache.cpp (+5 -3)

📄 Description

Introduces a system for implementing more efficient HLE macros for simple shaders.

In this case, implements a macro for a copy shader used by Bloodborne to copy arbitrary blocks of memory from one buffer to another. Currently this shader is responsible for big spikes in memory usage from mapping 2GB+ buffers of memory space to arbitrarily copy between. On a real console this would not be an issue since it just provides a window into the memory range, but for us this results in buffer memory allocations to cover the entire range.

By implementing this shader in HLE we can avoid these giant buffer allocations, instead only mapping much smaller areas where the copy actually occurs. This should eliminate memory spikes, reduce overall VRAM usage, and be generally more performant. We hope to have a more low-level solution for this problem in the future, but pending that this is a good way to keep memory usage under control and improve performance.

This also allows Bloodborne to go in-game on macOS (if compiled using the latest dev build of MoltenVK) since this shader was the main blocker for that. Still needs some more improvements to be fully stable.

Thanks to @raphaelthegreat for implementing the algorithm to batch the copies together.


🔄 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/1683 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 12/7/2024 **Status:** ✅ Merged **Merged:** 12/10/2024 **Merged by:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Base:** `main` ← **Head:** `copy-shader-hle` --- ### 📝 Commits (3) - [`84e8168`](https://github.com/shadps4-emu/shadPS4/commit/84e8168c8afcd11ceeb2941a4eb4d8e57266b529) renderer_vulkan: Introduce shader HLE system with copy shader implementation. - [`cc0c498`](https://github.com/shadps4-emu/shadPS4/commit/cc0c49876b8935ed89d84d6007a858dc1a1739bd) buffer_cache: Handle obtaining buffer views partially within buffers. - [`363c6c1`](https://github.com/shadps4-emu/shadPS4/commit/363c6c1b7babf10babeac7d0996d222829e79d7d) vk_shader_hle: Make more efficient ### 📊 Changes **9 files changed** (+195 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+2 -0) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+9 -1) 📝 `src/video_core/buffer_cache/buffer_cache.h` (+2 -1) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+6 -0) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.h` (+8 -0) 📝 `src/video_core/renderer_vulkan/vk_scheduler.h` (+4 -0) ➕ `src/video_core/renderer_vulkan/vk_shader_hle.cpp` (+139 -0) ➕ `src/video_core/renderer_vulkan/vk_shader_hle.h` (+20 -0) 📝 `src/video_core/texture_cache/texture_cache.cpp` (+5 -3) </details> ### 📄 Description Introduces a system for implementing more efficient HLE macros for simple shaders. In this case, implements a macro for a copy shader used by Bloodborne to copy arbitrary blocks of memory from one buffer to another. Currently this shader is responsible for big spikes in memory usage from mapping 2GB+ buffers of memory space to arbitrarily copy between. On a real console this would not be an issue since it just provides a window into the memory range, but for us this results in buffer memory allocations to cover the entire range. By implementing this shader in HLE we can avoid these giant buffer allocations, instead only mapping much smaller areas where the copy actually occurs. This should eliminate memory spikes, reduce overall VRAM usage, and be generally more performant. We hope to have a more low-level solution for this problem in the future, but pending that this is a good way to keep memory usage under control and improve performance. This also allows Bloodborne to go in-game on macOS (if compiled using the latest dev build of MoltenVK) since this shader was the main blocker for that. Still needs some more improvements to be fully stable. Thanks to @raphaelthegreat for implementing the algorithm to batch the copies together. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:15:44 +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#2245
No description provided.