[PR #2245] [MERGED] renderer_vulkan: use LDS buffer as SSBO on unsupported shared memory size #2592

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/2245
Author: @polybiusproxy
Created: 1/26/2025
Status: Merged
Merged: 1/31/2025
Merged by: @georgemoralis

Base: mainHead: lds-ssbo


📝 Commits (2)

  • 4e59a1e renderer_vulkan: use LDS buffer as SSBO on unsupported shared memory size
  • a0a1adf shader_recompiler: add v_trunc_f64 on inst format table

📊 Changes

14 files changed (+147 additions, -36 deletions)

View changed files

📝 src/shader_recompiler/backend/spirv/emit_spirv_shared_memory.cpp (+58 -16)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.cpp (+35 -10)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.h (+2 -2)
📝 src/shader_recompiler/frontend/decode.cpp (+2 -2)
📝 src/shader_recompiler/frontend/format.cpp (+3 -1)
📝 src/shader_recompiler/info.h (+2 -0)
📝 src/shader_recompiler/profile.h (+1 -0)
📝 src/shader_recompiler/runtime_info.h (+0 -1)
📝 src/shader_recompiler/specialization.h (+9 -0)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+4 -2)
📝 src/video_core/buffer_cache/buffer_cache.h (+6 -0)
📝 src/video_core/renderer_vulkan/vk_compute_pipeline.cpp (+8 -0)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+1 -1)
📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+16 -1)

📄 Description

To emulate LDS, a workgroup shared variable is made, however, this can't be done if the GPU has insufficient amounts of shared memory to meet the needs of the shader. Before PR https://github.com/shadps4-emu/shadPS4/pull/2175, if this was the case, there would be device losses.

To avoid this, if the GPU doesn't have enough shared memory size, LDS is emulated using a device local buffer bound as SSBO. This is not as optimal as a workgroup shared variable would be, but it is the only way.

This PR mainly aims to resolve one of the issues present on Gran Turismo Sport (https://github.com/shadps4-emu/shadPS4/issues/2181).


🔄 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/2245 **Author:** [@polybiusproxy](https://github.com/polybiusproxy) **Created:** 1/26/2025 **Status:** ✅ Merged **Merged:** 1/31/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `lds-ssbo` --- ### 📝 Commits (2) - [`4e59a1e`](https://github.com/shadps4-emu/shadPS4/commit/4e59a1ecdf0a474859ce5c0b53ec2cc13a5e339a) renderer_vulkan: use LDS buffer as SSBO on unsupported shared memory size - [`a0a1adf`](https://github.com/shadps4-emu/shadPS4/commit/a0a1adf0af459c15ef7e737337782fade94cf71d) shader_recompiler: add `v_trunc_f64` on inst format table ### 📊 Changes **14 files changed** (+147 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `src/shader_recompiler/backend/spirv/emit_spirv_shared_memory.cpp` (+58 -16) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.cpp` (+35 -10) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.h` (+2 -2) 📝 `src/shader_recompiler/frontend/decode.cpp` (+2 -2) 📝 `src/shader_recompiler/frontend/format.cpp` (+3 -1) 📝 `src/shader_recompiler/info.h` (+2 -0) 📝 `src/shader_recompiler/profile.h` (+1 -0) 📝 `src/shader_recompiler/runtime_info.h` (+0 -1) 📝 `src/shader_recompiler/specialization.h` (+9 -0) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+4 -2) 📝 `src/video_core/buffer_cache/buffer_cache.h` (+6 -0) 📝 `src/video_core/renderer_vulkan/vk_compute_pipeline.cpp` (+8 -0) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+1 -1) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+16 -1) </details> ### 📄 Description To emulate LDS, a workgroup shared variable is made, however, this can't be done if the GPU has insufficient amounts of shared memory to meet the needs of the shader. Before PR https://github.com/shadps4-emu/shadPS4/pull/2175, if this was the case, there would be device losses. To avoid this, if the GPU doesn't have enough shared memory size, LDS is emulated using a device local buffer bound as SSBO. This is not as optimal as a workgroup shared variable would be, but it is the only way. This PR mainly aims to resolve one of the issues present on Gran Turismo Sport (https://github.com/shadps4-emu/shadPS4/issues/2181). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:00:31 +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#2592
No description provided.