mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-25 07:46:01 +03:00
[PR #575] [MERGED] video_core: Account of runtime state changes when compiling shaders #1641
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#1641
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/575
Author: @raphaelthegreat
Created: 8/25/2024
Status: ✅ Merged
Merged: 8/29/2024
Merged by: @raphaelthegreat
Base:
main← Head:permut📝 Commits (10+)
007147cvideo_core: Compile shader permutations19d5ac1spirv: Only specific storage image format for atomics74a5d1eir: Avoid cube coord patching for storage imagef13aa08spirv: Fix default attributes347096bdata_share: Add more instructions5c1de38video_core: Query storage flag with runtime state833a366kernel: Use std::list for semaphoref118dc7video_core: Use texture buffers for untyped format load/store97770e2buffer_cache: Limit view usaged362928vk_pipeline_cache: Fix invalid iterator📊 Changes
43 files changed (+1057 additions, -975 deletions)
View changed files
📝
CMakeLists.txt(+2 -0)📝
src/core/libraries/avplayer/avplayer.cpp(+1 -1)📝
src/core/libraries/kernel/threads/semaphore.cpp(+13 -20)📝
src/shader_recompiler/backend/spirv/emit_spirv.cpp(+25 -16)📝
src/shader_recompiler/backend/spirv/emit_spirv.h(+1 -1)📝
src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp(+15 -254)📝
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp(+93 -63)📝
src/shader_recompiler/backend/spirv/spirv_emit_context.h(+12 -5)📝
src/shader_recompiler/frontend/translate/data_share.cpp(+21 -14)📝
src/shader_recompiler/frontend/translate/export.cpp(+0 -2)📝
src/shader_recompiler/frontend/translate/translate.cpp(+1 -3)📝
src/shader_recompiler/frontend/translate/translate.h(+7 -5)📝
src/shader_recompiler/frontend/translate/vector_alu.cpp(+10 -4)📝
src/shader_recompiler/frontend/translate/vector_memory.cpp(+108 -55)📝
src/shader_recompiler/ir/ir_emitter.cpp(+5 -32)📝
src/shader_recompiler/ir/ir_emitter.h(+3 -3)📝
src/shader_recompiler/ir/microinstruction.cpp(+0 -3)📝
src/shader_recompiler/ir/opcodes.inc(+2 -8)📝
src/shader_recompiler/ir/passes/resource_tracking_pass.cpp(+74 -116)📝
src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp(+9 -0)...and 23 more files
📄 Description
A lot of state used during shader compilation is stored in the resource definitions (sharps). For buffers the stride, format (in case of untyped buffer load/store) as well as the size are relevant to compilation. For images the type is most relevant as that determines the layout of the address stream.
Due to this, it is possible for these parameters to be modified while the same shader program is bound. This can cause a variety of issues which are difficult to debug. For example a read-only buffer may get compiled as a UBO first time, but then a larger buffer may be bound which cannot fit in the 16KB size limit. Some games can also use multiple image types with the same program.
To solve this, each Program (which represents a unique guest shader) can now store a collection of vulkan shader modules. After its fetched the resource layout is determined and a resource stage key is calculated which takes into account the position of the shader in the pipeline (start binding) as well as resource information relevant to compilation. Might fix issues in some games, but can also expose issues that where hidden before. This will allow us to remove another hack in bb-hacks branch but is not a fix for bloodborne specifically.
In addition memory usage from the shader cache should be significantly reduced. We only cache Shader::Info object per shader as well as the vulkan shader modules. Before this change, the generated SPIRV code was kept around which could be dozens of KBs per object as well as the IR::Program which stored blocks and translated gcn instructions that aren't much useful
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.