[PR #1013] [MERGED] shader_recompiler: Additional scope handling and user data as push constants #1880

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/1013
Author: @raphaelthegreat
Created: 9/21/2024
Status: Merged
Merged: 9/23/2024
Merged by: @psucien

Base: mainHead: some-changes


📝 Commits (10+)

📊 Changes

23 files changed (+180 additions, -87 deletions)

View changed files

📝 CMakeLists.txt (+1 -0)
📝 src/shader_recompiler/backend/bindings.h (+4 -4)
📝 src/shader_recompiler/backend/spirv/emit_spirv.cpp (+1 -1)
📝 src/shader_recompiler/backend/spirv/emit_spirv.h (+2 -1)
📝 src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp (+8 -1)
📝 src/shader_recompiler/backend/spirv/emit_spirv_image.cpp (+1 -0)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.cpp (+20 -14)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.h (+3 -2)
📝 src/shader_recompiler/frontend/control_flow_graph.cpp (+15 -7)
📝 src/shader_recompiler/frontend/translate/scalar_alu.cpp (+11 -0)
📝 src/shader_recompiler/frontend/translate/translate.cpp (+1 -1)
📝 src/shader_recompiler/frontend/translate/translate.h (+1 -0)
📝 src/shader_recompiler/frontend/translate/vector_alu.cpp (+18 -0)
📝 src/shader_recompiler/info.h (+38 -5)
📝 src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp (+5 -4)
📝 src/shader_recompiler/specialization.h (+5 -4)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+5 -3)
📝 src/video_core/renderer_vulkan/vk_compute_pipeline.cpp (+11 -12)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp (+14 -14)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+7 -7)

...and 3 more files

📄 Description

The initial goal of this PR was to handle some additional cases of divergence spotted in some Bloodborne particle shaders which caused certain branches to be entirely missed.

However this fix by itself, actually regressed the game because some compute shaders used for copying data around had some bounds checks implemented that fell under this category. So the change made the branches work properly, but the limit was stored in user data regs. The compiler treated user data regs as compiler constants and expected they would not change between the same shader. However these shaders can be bound multiple times with different limits depending on how much game was copying.

So the control flow improvement is also bundled with a different change that moves user data regs to the push constant block. I've also added some minor additions from various tests that don't deserve their own PR. This may improve some particle effects in BB but I have not noticed any visual change


🔄 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/1013 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 9/21/2024 **Status:** ✅ Merged **Merged:** 9/23/2024 **Merged by:** [@psucien](https://github.com/psucien) **Base:** `main` ← **Head:** `some-changes` --- ### 📝 Commits (10+) - [`58d9218`](https://github.com/shadps4-emu/shadPS4/commit/58d92188c401053eeb7345472f869d5edb53f311) shader_recompiler: Use push constants for user data regs - [`94d8fea`](https://github.com/shadps4-emu/shadPS4/commit/94d8fea215f3cbdd7b59edb4c71355430b68b45e) shader: Add some GR2 instructions - [`fdd699a`](https://github.com/shadps4-emu/shadPS4/commit/fdd699a725439b91a548eea5bd4e80254efc8fb3) shader: Add some instructions - [`a1eee4a`](https://github.com/shadps4-emu/shadPS4/commit/a1eee4a523f0717e9633f4a54beffd6fd2ea9d04) shader: Add instructions for knack - [`dd0773d`](https://github.com/shadps4-emu/shadPS4/commit/dd0773dfb1090e61bcee38efd713fe420b305bda) touchups - [`dd0abc5`](https://github.com/shadps4-emu/shadPS4/commit/dd0abc556bb296c66c1666cdadace1c3a14fc51f) spirv: Better names - [`c15fa4f`](https://github.com/shadps4-emu/shadPS4/commit/c15fa4f9be3ebcfdc10bca401627566d3339d27c) buffer_cache: Ignore non gpu modified images - [`f37ca9c`](https://github.com/shadps4-emu/shadPS4/commit/f37ca9c44cc4cdf9314686ce38bac3b3d0505401) clang format - [`f98a73b`](https://github.com/shadps4-emu/shadPS4/commit/f98a73b3605c8c1dc10cbfcd440d08792da55378) Add log - [`bf16608`](https://github.com/shadps4-emu/shadPS4/commit/bf1660869ea14ba6ac8857abf7948a96f186a2ee) more fixes ### 📊 Changes **23 files changed** (+180 additions, -87 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+1 -0) 📝 `src/shader_recompiler/backend/bindings.h` (+4 -4) 📝 `src/shader_recompiler/backend/spirv/emit_spirv.cpp` (+1 -1) 📝 `src/shader_recompiler/backend/spirv/emit_spirv.h` (+2 -1) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp` (+8 -1) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_image.cpp` (+1 -0) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.cpp` (+20 -14) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.h` (+3 -2) 📝 `src/shader_recompiler/frontend/control_flow_graph.cpp` (+15 -7) 📝 `src/shader_recompiler/frontend/translate/scalar_alu.cpp` (+11 -0) 📝 `src/shader_recompiler/frontend/translate/translate.cpp` (+1 -1) 📝 `src/shader_recompiler/frontend/translate/translate.h` (+1 -0) 📝 `src/shader_recompiler/frontend/translate/vector_alu.cpp` (+18 -0) 📝 `src/shader_recompiler/info.h` (+38 -5) 📝 `src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp` (+5 -4) 📝 `src/shader_recompiler/specialization.h` (+5 -4) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+5 -3) 📝 `src/video_core/renderer_vulkan/vk_compute_pipeline.cpp` (+11 -12) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp` (+14 -14) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+7 -7) _...and 3 more files_ </details> ### 📄 Description The initial goal of this PR was to handle some additional cases of divergence spotted in some Bloodborne particle shaders which caused certain branches to be entirely missed. However this fix by itself, actually regressed the game because some compute shaders used for copying data around had some bounds checks implemented that fell under this category. So the change made the branches work properly, but the limit was stored in user data regs. The compiler treated user data regs as compiler constants and expected they would not change between the same shader. However these shaders can be bound multiple times with different limits depending on how much game was copying. So the control flow improvement is also bundled with a different change that moves user data regs to the push constant block. I've also added some minor additions from various tests that don't deserve their own PR. This may improve some particle effects in BB but I have not noticed any visual change --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:14:18 +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#1880
No description provided.