[GH-ISSUE #296] [CUSA03173] [01.09] Sliders in Bloodborne are drawn incorrectly #45

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

Originally created by @roamic on GitHub (Jul 16, 2024).
Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/296

image
The bar near 7 should be partly filled.
It seems to me that it is missing some constant buffer updates for some reason.

This shader code is responsible for the positioning:

layout(set = 0, binding = 2, scalar) uniform vs_cbuf_block_f32
{
    float data[16];
} cbuf_104;

gl_Position.x = fma(cbuf_104.data[0u], vs_in_attr1.x, fma(cbuf_104.data[1u], vs_in_attr1.y, fma(cbuf_104.data[2u], 0.0, cbuf_104.data[3u] * 1.0)));
gl_Position.y = fma(cbuf_104.data[4u], vs_in_attr1.x, fma(cbuf_104.data[5u], vs_in_attr1.y, fma(cbuf_104.data[6u], 0.0, cbuf_104.data[7u] * 1.0)));

It looks like a transform matrix multiplication.

This is the buffer content at the time of rendering:
image

Originally created by @roamic on GitHub (Jul 16, 2024). Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/296 ![image](https://github.com/user-attachments/assets/05995cda-6848-4563-bacf-57d75158d268) The bar near 7 should be partly filled. It seems to me that it is missing some constant buffer updates for some reason. This shader code is responsible for the positioning: ``` layout(set = 0, binding = 2, scalar) uniform vs_cbuf_block_f32 { float data[16]; } cbuf_104; gl_Position.x = fma(cbuf_104.data[0u], vs_in_attr1.x, fma(cbuf_104.data[1u], vs_in_attr1.y, fma(cbuf_104.data[2u], 0.0, cbuf_104.data[3u] * 1.0))); gl_Position.y = fma(cbuf_104.data[4u], vs_in_attr1.x, fma(cbuf_104.data[5u], vs_in_attr1.y, fma(cbuf_104.data[6u], 0.0, cbuf_104.data[7u] * 1.0))); ``` It looks like a transform matrix multiplication. This is the buffer content at the time of rendering: ![image](https://github.com/user-attachments/assets/33f6269c-4196-4cfb-8714-902c736aa545)
kerem 2026-02-27 21:04:18 +03:00
Author
Owner

@raphaelthegreat commented on GitHub (Jul 18, 2024):

Can you check if it uses inline constant buffers by any chance? Resource tracking pass has the pattern for them in gcn assembly.

<!-- gh-comment-id:2237038850 --> @raphaelthegreat commented on GitHub (Jul 18, 2024): Can you check if it uses inline constant buffers by any chance? Resource tracking pass has the pattern for them in gcn assembly.
Author
Owner

@roamic commented on GitHub (Jul 18, 2024):

@raphaelthegreat no, doesn't seem so

/*000000000000*/ s_mov_b32       vcc_hi, lit(20)
/*000000000008*/ s_swappc_b64    s[0:1], s[0:1]
/*00000000000c*/ s_buffer_load_dwordx16 s[0:15], s[8:11], 0x0
<!-- gh-comment-id:2237386214 --> @roamic commented on GitHub (Jul 18, 2024): @raphaelthegreat no, doesn't seem so ``` /*000000000000*/ s_mov_b32 vcc_hi, lit(20) /*000000000008*/ s_swappc_b64 s[0:1], s[0:1] /*00000000000c*/ s_buffer_load_dwordx16 s[0:15], s[8:11], 0x0 ```
Author
Owner

@raphaelthegreat commented on GitHub (Jul 18, 2024):

Go to core/memory.cpp and comment out the return; statements in the vulkan functions. Then apply this patch github.com/raphaelthegreat/shadPS4@a7c69c1512/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp (L346)

<!-- gh-comment-id:2237390683 --> @raphaelthegreat commented on GitHub (Jul 18, 2024): Go to core/memory.cpp and comment out the return; statements in the vulkan functions. Then apply this patch https://github.com/raphaelthegreat/shadPS4/blob/a7c69c1512f26896a4a6301a8c6e6e67effa5036/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp#L346
Author
Owner

@raphaelthegreat commented on GitHub (Jul 18, 2024):

Also the same in ComputePipeline just in case

<!-- gh-comment-id:2237398465 --> @raphaelthegreat commented on GitHub (Jul 18, 2024): Also the same in ComputePipeline just in case
Author
Owner

@roamic commented on GitHub (Jul 18, 2024):

With texture_cache.OnCpuWrite(address); it goes OutOfDeviceMemory before even showing the logos. Without it — it does nothing.

<!-- gh-comment-id:2237450719 --> @roamic commented on GitHub (Jul 18, 2024): With `texture_cache.OnCpuWrite(address);` it goes `OutOfDeviceMemory` before even showing the logos. Without it — it does nothing.
Author
Owner

@raphaelthegreat commented on GitHub (Jul 18, 2024):

Also add a check that address is not zero as I remember BB passes some invalid buffers

<!-- gh-comment-id:2237452038 --> @raphaelthegreat commented on GitHub (Jul 18, 2024): Also add a check that address is not zero as I remember BB passes some invalid buffers
Author
Owner

@roamic commented on GitHub (Jul 18, 2024):

It doesn't go OOM anymore even without the address check, but the original issue persists.

<!-- gh-comment-id:2237453932 --> @roamic commented on GitHub (Jul 18, 2024): It doesn't go OOM anymore even without the address check, but the original issue persists.
Author
Owner

@roamic commented on GitHub (Aug 16, 2024):

Just for the history I recap what Turtle has uncovered:
The game uses user registers to supply a parameter to the shader. Those need to be detected and implemented with push constants.

<!-- gh-comment-id:2293004127 --> @roamic commented on GitHub (Aug 16, 2024): Just for the history I recap what Turtle has uncovered: The game uses user registers to supply a parameter to the shader. Those need to be detected and implemented with push constants.
Author
Owner

@roamic commented on GitHub (Aug 17, 2024):

image

These artifacts are caused by the same issue. They use the same vertex shader.
And it's not about user registers, it's about constant buffers being invalid. The supplied CB contains two 2x4 2D transform matrices for vertex position and texcoords. Those matrices always contain values that were set during their initialization rather than current values. So either game cannot update them for some reason, or the emulator misses the update.

<!-- gh-comment-id:2294757059 --> @roamic commented on GitHub (Aug 17, 2024): ![image](https://github.com/user-attachments/assets/c8fd7bc3-108f-41ea-8a7c-709e6612f674) These artifacts are caused by the same issue. They use the same vertex shader. And it's not about user registers, it's about constant buffers being invalid. The supplied CB contains two 2x4 2D transform matrices for vertex position and texcoords. Those matrices always contain values that were set during their initialization rather than current values. So either game cannot update them for some reason, or the emulator misses the update.
Author
Owner

@roamic commented on GitHub (Aug 17, 2024):

One other possible cause is vertex buffers. Fragment shader has fragment alpha channel set to vs_attr_0.w that is directly copied from the VS input. And I can see that some values are 0. This even seems more likely than CBs.

<!-- gh-comment-id:2294789922 --> @roamic commented on GitHub (Aug 17, 2024): One other possible cause is vertex buffers. Fragment shader has fragment alpha channel set to `vs_attr_0.w` that is directly copied from the VS input. And I can see that some values are `0`. This even seems more likely than CBs.
Author
Owner

@andrew101sanders commented on GitHub (Aug 17, 2024):

Ahh, I wish I had seen this issue before trying to track down the issue in renderdoc too, ha.

Just contributing the discussion that was had in the discord a few weeks back regarding it:
image

[7:26 PM]IndecisiveTurtle:
v_mac_f32 v2, s8, v8
[7:26 PM]IndecisiveTurtle: s8 doesn't appear to be set anywhere in shader so its a user data reg
[7:26 PM]IndecisiveTurtle: user data regs atm are hardcoded as compilation constants in the shader
[7:26 PM]IndecisiveTurtle: So if the game uses a UD value as a dynamic adjustment for slider it wont work and it will stay stuck
[7:27 PM]IndecisiveTurtle: UD regs need to be made into push constants

<!-- gh-comment-id:2294819275 --> @andrew101sanders commented on GitHub (Aug 17, 2024): Ahh, I wish I had seen this issue before trying to track down the issue in renderdoc too, ha. Just contributing the discussion that was had in the discord a few weeks back regarding it: ![image](https://github.com/user-attachments/assets/8bad3175-2880-46de-b16a-814c127795a5) [7:26 PM]IndecisiveTurtle: v_mac_f32 v2, s8, v8 [7:26 PM]IndecisiveTurtle: s8 doesn't appear to be set anywhere in shader so its a user data reg [7:26 PM]IndecisiveTurtle: user data regs atm are hardcoded as compilation constants in the shader [7:26 PM]IndecisiveTurtle: So if the game uses a UD value as a dynamic adjustment for slider it wont work and it will stay stuck [7:27 PM]IndecisiveTurtle: UD regs need to be made into push constants
Author
Owner

@raphaelthegreat commented on GitHub (Aug 17, 2024):

This turned out to be incorrect, I missed the place where s8 was being written in the shader

<!-- gh-comment-id:2294819648 --> @raphaelthegreat commented on GitHub (Aug 17, 2024): This turned out to be incorrect, I missed the place where s8 was being written in the shader
Author
Owner

@roamic commented on GitHub (Aug 19, 2024):

fixed with #464

<!-- gh-comment-id:2295763317 --> @roamic commented on GitHub (Aug 19, 2024): fixed with #464
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#45
No description provided.