[PR #3238] [MERGED] shader_recompiler: Replace buffer pulling with attribute divisor for instance step rates #3327

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

📋 Pull Request Information

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

Base: mainHead: step-rate-clean


📝 Commits (9)

  • c0878db shader_recompiler: Replace buffer pulling with attribute divisor for instance step rates
  • 7994ee8 flatten_extended_userdata: Remove special step rate buffer handling
  • 3d9d274 Review comments
  • 94da278 spirv_emit_context: Name all instance rate attribs properly
  • ec462bb spirv: Merge ReadConstBuffer again
  • de90601 attribute: Add missing attributes
  • fc3454c translate: Reimplement step rate instance id
  • b16b9a1 Resolve validation warnings
  • dde954a shader_recompiler: Separate vertex inputs from LS stage, cleanup tess

📊 Changes

22 files changed (+208 additions, -274 deletions)

View changed files

📝 src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp (+48 -80)
📝 src/shader_recompiler/backend/spirv/emit_spirv_instructions.h (+1 -1)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.cpp (+24 -50)
📝 src/shader_recompiler/backend/spirv/spirv_emit_context.h (+0 -1)
📝 src/shader_recompiler/frontend/fetch_shader.h (+0 -12)
📝 src/shader_recompiler/frontend/translate/translate.cpp (+37 -26)
📝 src/shader_recompiler/info.h (+5 -9)
📝 src/shader_recompiler/ir/attribute.cpp (+18 -4)
📝 src/shader_recompiler/ir/attribute.h (+0 -2)
📝 src/shader_recompiler/ir/ir_emitter.cpp (+2 -2)
📝 src/shader_recompiler/ir/ir_emitter.h (+1 -2)
📝 src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp (+1 -23)
📝 src/shader_recompiler/ir/passes/ring_access_elimination.cpp (+4 -7)
📝 src/shader_recompiler/ir/passes/srt.h (+1 -12)
📝 src/shader_recompiler/runtime_info.h (+4 -2)
📝 src/shader_recompiler/specialization.h (+13 -7)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+4 -1)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp (+31 -15)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.h (+3 -1)
📝 src/video_core/renderer_vulkan/vk_instance.cpp (+4 -0)

...and 2 more files

📄 Description

This is first part of trying to cleanup the attribute code in recompiler before I can implement what I want, as it has suffered from a bit of scope creep.

In this PR the code for manually pulling buffers for emulating instance step rates is removed in favor of using VK_EXT_vertex_attribute_divisor. That extension is quite old and ubiquitously supported on all platforms so the benefit of code simplification is worth it. Also added divisor into specialization for checking both input rate and step rate, on main the former wasn't checked (is it even possible for an attribute to go from vertex to instance rate with same shader?) and removed code in backend for handling InstanceId0-1 as it seemed wrong; if those vgprs are used for as index for buffer loads shouldn't they be InstanceId / step_rate_0-1 instead of just step rate? Can be checked now when their assertion hits


🔄 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/3238 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 7/13/2025 **Status:** ✅ Merged **Merged:** 7/13/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `step-rate-clean` --- ### 📝 Commits (9) - [`c0878db`](https://github.com/shadps4-emu/shadPS4/commit/c0878db548dd7a687f0882de04f44228f33ea2c1) shader_recompiler: Replace buffer pulling with attribute divisor for instance step rates - [`7994ee8`](https://github.com/shadps4-emu/shadPS4/commit/7994ee814f1921dd9e672aefb4f6b7b0d5eedcb9) flatten_extended_userdata: Remove special step rate buffer handling - [`3d9d274`](https://github.com/shadps4-emu/shadPS4/commit/3d9d2743491491bb1bae9770ec63c6fe68d46f71) Review comments - [`94da278`](https://github.com/shadps4-emu/shadPS4/commit/94da2786d3e624a7936b7472693370ec83dc4ffc) spirv_emit_context: Name all instance rate attribs properly - [`ec462bb`](https://github.com/shadps4-emu/shadPS4/commit/ec462bbcbaf40158b02c2459938668bd45b6252f) spirv: Merge ReadConstBuffer again - [`de90601`](https://github.com/shadps4-emu/shadPS4/commit/de90601f28bee51100bbe5ca234a7e3f9c13db26) attribute: Add missing attributes - [`fc3454c`](https://github.com/shadps4-emu/shadPS4/commit/fc3454cd9ef22098ec299b8988821c65ea89812d) translate: Reimplement step rate instance id - [`b16b9a1`](https://github.com/shadps4-emu/shadPS4/commit/b16b9a154432c638ebff5f4bb4f05d4bcdaabf58) Resolve validation warnings - [`dde954a`](https://github.com/shadps4-emu/shadPS4/commit/dde954a3cb80f9d9d42b8bbcd00989dd291a1c9f) shader_recompiler: Separate vertex inputs from LS stage, cleanup tess ### 📊 Changes **22 files changed** (+208 additions, -274 deletions) <details> <summary>View changed files</summary> 📝 `src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp` (+48 -80) 📝 `src/shader_recompiler/backend/spirv/emit_spirv_instructions.h` (+1 -1) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.cpp` (+24 -50) 📝 `src/shader_recompiler/backend/spirv/spirv_emit_context.h` (+0 -1) 📝 `src/shader_recompiler/frontend/fetch_shader.h` (+0 -12) 📝 `src/shader_recompiler/frontend/translate/translate.cpp` (+37 -26) 📝 `src/shader_recompiler/info.h` (+5 -9) 📝 `src/shader_recompiler/ir/attribute.cpp` (+18 -4) 📝 `src/shader_recompiler/ir/attribute.h` (+0 -2) 📝 `src/shader_recompiler/ir/ir_emitter.cpp` (+2 -2) 📝 `src/shader_recompiler/ir/ir_emitter.h` (+1 -2) 📝 `src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp` (+1 -23) 📝 `src/shader_recompiler/ir/passes/ring_access_elimination.cpp` (+4 -7) 📝 `src/shader_recompiler/ir/passes/srt.h` (+1 -12) 📝 `src/shader_recompiler/runtime_info.h` (+4 -2) 📝 `src/shader_recompiler/specialization.h` (+13 -7) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+4 -1) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp` (+31 -15) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.h` (+3 -1) 📝 `src/video_core/renderer_vulkan/vk_instance.cpp` (+4 -0) _...and 2 more files_ </details> ### 📄 Description This is first part of trying to cleanup the attribute code in recompiler before I can implement what I want, as it has suffered from a bit of scope creep. In this PR the code for manually pulling buffers for emulating instance step rates is removed in favor of using VK_EXT_vertex_attribute_divisor. That extension is quite old and ubiquitously supported on all platforms so the benefit of code simplification is worth it. Also added divisor into specialization for checking both input rate and step rate, on main the former wasn't checked (is it even possible for an attribute to go from vertex to instance rate with same shader?) and removed code in backend for handling InstanceId0-1 as it seemed wrong; if those vgprs are used for as index for buffer loads shouldn't they be InstanceId / step_rate_0-1 instead of just step rate? Can be checked now when their assertion hits --- <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: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#3327
No description provided.