mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-25 15:56:00 +03:00
[PR #3159] [MERGED] shader_recompiler: Optimize general case of buffer addressing #3271
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#3271
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/3159
Author: @raphaelthegreat
Created: 6/25/2025
Status: ✅ Merged
Merged: 6/26/2025
Merged by: @georgemoralis
Base:
main← Head:buffer-opts📝 Commits (5)
a0c1542shader_recompiler: Simplify dma types6fa5f51shader_recompiler: Perform address shift on IR levele741c3cshader_recompiler: Optimize common buffer access pattern002aebaemit_spirv: Use 32-bit integer ops for fault buffer808fe6aresource_tracking_pass: Fix texel buffer shift📊 Changes
12 files changed (+272 additions, -234 deletions)
View changed files
📝
src/shader_recompiler/backend/spirv/emit_spirv.cpp(+1 -1)📝
src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp(+26 -26)📝
src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp(+53 -58)📝
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp(+81 -76)📝
src/shader_recompiler/backend/spirv/spirv_emit_context.h(+34 -56)📝
src/shader_recompiler/frontend/translate/scalar_alu.cpp(+0 -1)📝
src/shader_recompiler/info.h(+1 -1)📝
src/shader_recompiler/ir/passes/resource_tracking_pass.cpp(+63 -1)📝
src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp(+8 -7)📝
src/shader_recompiler/profile.h(+1 -1)📝
src/video_core/renderer_vulkan/vk_pipeline_cache.cpp(+1 -0)📝
src/video_core/renderer_vulkan/vk_rasterizer.cpp(+3 -6)📄 Description
Buffer instructions have always had a strange API where regardless of their element size, they would receive a byte address from IR, add the offset in bytes and shift the address to get the array index. This makes buffer reads harder to read and has additional overhead in the form of a shift operation. For example:
With this PR buffer instruction now directly accept the array index of the buffer and add the correctly sized offset. By doing the shift in IR the most common buffer addressing mode can be detected and optimize away the shift by directly shifting the constants instead.
On platforms where minStorageBufferOffsetAlignment = 4 (AMD, Intel) we can go a step further and eliminate the buffer offset addition, saving another ALU operation per access
This might have some impact on GPU performance especially if many shaders do many buffer accesses, as the saved ALU ops can add up
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.