mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 00:05:58 +03:00
[PR #2767] [CLOSED] shader_recompiler: (WIP) Implement more accurate ReadConst support (including dynamic indexing) #2966
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#2966
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/2767
Author: @LNDF
Created: 4/10/2025
Status: ❌ Closed
Base:
main← Head:read-const📝 Commits (10+)
d88294aDump IR program38957baHandle non inmediate offset on S_LOAD_DWORD6465310ASL dumping60be1e4Fix unreacheable ASL dump4bf9bbfAdd conditional tree6fff3a0Usefulness of conditional treee15bf43Subprogram creation03d4471clang-format5843352Fix subprogram generation7a93230ImmValue📊 Changes
72 files changed (+9312 additions, -158 deletions)
View changed files
📝
CMakeLists.txt(+56 -1)➕
src/common/cartesian_invoke.h(+43 -0)📝
src/common/func_traits.h(+1 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64.cpp(+268 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64.h(+15 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_atomic.cpp(+138 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_barrier.cpp(+20 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_bitwise_conversion.cpp(+204 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_composite.cpp(+350 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_context_get_set.cpp(+221 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_convert.cpp(+279 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_floating_point.cpp(+766 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_image.cpp(+62 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_instructions.h(+482 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_integer.cpp(+624 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_logical.cpp(+42 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_select.cpp(+71 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_shared_memory.cpp(+39 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_special.cpp(+55 -0)➕
src/shader_recompiler/backend/asm_x64/emit_x64_undefined.cpp(+28 -0)...and 52 more files
📄 Description
The goal of this pull request is to be able to more accurately support ReadConst (LOAD_DWORD) in shaders.
The current implementation doesn't support dynamic offsets, and doesn't correctly handle the cases where the base address is modified between the source ReadConst/UserData and the user ReadConst. Example:
This PR aims to solve this issue in the following way.
Doing that, the flatbuf should contain all the data the shader needs.
Current issues and status
This is a draft, because it regresses/braks games right now.
I was able to toest in 2 games.
Bloodborne issue
A crash occurs when executing the x64 code generated for the 0x8bc6ea32 shader. The following is the IR of the subprogram:
If condition %33 is true, the shader gets an address (%35 and %36) that will be used to read from later (%40-%43).
The address obtained in %35 and %36 is not a valid address (0xC28C270A00000030). The buffer resource used to point to the buffer that is read from seems correct (base address, stride, etc.). I think the ReadConstBuffer implementation in the x64 shader backend is correct (apart from clamping)and I'm not able to find the cause of this issue.
Would be great if someone with more knowledge on how buffers work could take a look at this.
Additional notes
Now, if shader dumping is enabled, the ASL will also be dumped. Additionaly, IR, ASL and assembly code will be dumped for the subprogram.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.