Skip to content

vk: Resource binding model rewrites [part 2 of 2] - #17427

Merged
kd-11 merged 50 commits into
RPCS3:masterfrom
kd-11:descriptors-plan-b
Oct 13, 2025
Merged

kd-11 merged 50 commits into
RPCS3:masterfrom
kd-11:descriptors-plan-b

Conversation

@kd-11

@kd-11 kd-11 commented Aug 10, 2025

Copy link
Copy Markdown
Contributor

Relates to #17277

Changes

  • Remove all per-draw UBO objects and replace with SSBO array-of-structs model. This removes a lot of descriptor bind operations completely.
  • Avoid using more than a few bytes of data in push constants. Instead, we write a per-draw config and push a pointer offset to the next one. Restricting push constants memory to 4 bytes per draw has decent gains.
  • Replace std::vector with rsx::simple_array for trivial storage. The latter has small-vector optimizations that drastically reduce the number of memory allocations done on the fly and gives a decent perf bump to both Vulkan and OpenGL.
  • Other minor optimizations related to resource bindings.

Overall, a 10-20% boost is observed depending on the game. MESA drivers benefit the most here since they doesn't keep a state cache like the properietary ones so state changes are more expensive on those drivers.

@AniLeo

AniLeo commented Aug 10, 2025

Copy link
Copy Markdown
Member

Reduces performance gap between radeonsi and radv as described on #15926

radv: 319 FPS -> 349 FPS (+30 FPS)

image image

radeonsi: 385 FPS -> 390 FPS (+5 FPS)

image image

System information

  • Kernel: 6.15.7-1-MANJARO
  • CPU: AMD Ryzen 7 9800X3D
  • GPU: AMD Radeon RX 6800 XT (RADV NAVI21)
  • Driver: mesa 25.1.6

@digant73

digant73 commented Aug 10, 2025 •

Copy link
Copy Markdown
Contributor

quick test on KZ3 but perf seems worse (more gpu usage and lower fps).
Attached log files and screenshots on both this PR and current build.

CPU: 9950X3D
GPU: RTX 5090 (latest driver 580.88)
RAM: 64 GB

Current build:

RPCS3.log_current.gz

kz3_current

PR:

RPCS3.log.gz

kz3_pr

@AniLeo

AniLeo commented Aug 10, 2025

Copy link
Copy Markdown
Member

No system specifications, no cpu/gpu/driver info, no performance overlay with averages, can't do anything just from that

@digant73

Copy link
Copy Markdown
Contributor

No system specifications, no cpu/gpu/driver info, no performance overlay with averages, can't do anything just from that

Added the requested info. As I said, it was a very quick test. I see also R3 has more GPU usage. I will test the PR more in deep tomorrow.

Comment thread rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp Outdated
@LucioXerus

LucioXerus commented Aug 11, 2025 •

Copy link
Copy Markdown

I tested 10 games. (Call of Duty Black Ops, CN Punchtime Explosion, Goldeneye Reloaded, Playstation All Stars Battle Royale, Street Fighter X Tekken, Super Street Fighter 2 Turbo, Need for Speed Carbon, Tekken 6, Virtua Fighter 5 and WWE All Stars). They all went ingame without crashes or graphical glitches. 4 player splitscreen with Call of Duty i saw the fps go from approximately 15fps average to 18 fps average. So all good on my end so far.
Master:
master
PR:
pr
Intel i9 11900K
16GB RAM
AMD Radeon RX 7600
Fedora 42 Kde Plasma

@digant73

digant73 commented Aug 11, 2025 •

Copy link
Copy Markdown
Contributor

Got a DEVICE_LOST in Resistance 3 after few minutes of gameplay.
Attached also the log file.

NOTE: I confirm also the worse perf on KZ3 (previous post edited adding onscreen stats)

RPCS3.zip

image

@kd-11

kd-11 commented Aug 11, 2025

Copy link
Copy Markdown
Contributor Author

I think the perf loss is just because I forgot to restore optimizations in the shader compiler.

@digant73

digant73 commented Aug 11, 2025 •

Copy link
Copy Markdown
Contributor

Infamous 2 demo crashing in the same place with the following error just when shooting the first enemy:

RPCS3.zip

image

infamous_2_demo

@digant73

digant73 commented Aug 11, 2025 •

Copy link
Copy Markdown
Contributor

same crash as in Infamous 2 demo also in UC1 just in a place where current build has an avg of 40 fps (on top of the u-boat):

image

uc1_pr_crash

@kd-11
kd-11 marked this pull request as draft August 11, 2025 21:23
@kd-11

kd-11 commented Aug 11, 2025

Copy link
Copy Markdown
Contributor Author

The crashes are fixed so I pushed the commits though I have drafted the PR due to serious issues with vulkan shader interpreter.

@digant73

digant73 commented Aug 11, 2025 •

Copy link
Copy Markdown
Contributor

I think the perf loss is just because I forgot to restore optimizations in the shader compiler.

Hmm no difference on perf on KZ3 with latest commit.
Also the crashes on shaders are still there

@kd-11

kd-11 commented Aug 12, 2025

Copy link
Copy Markdown
Contributor Author

I think the perf loss is just because I forgot to restore optimizations in the shader compiler.

Hmm no difference on perf on KZ3 with latest commit. Also the crashes on shaders are still there

Compilation crashes in the log you provided previously should be fixed already. If there are new crashes, upload the log files.

@digant73

Copy link
Copy Markdown
Contributor

I think the perf loss is just because I forgot to restore optimizations in the shader compiler.

Hmm no difference on perf on KZ3 with latest commit. Also the crashes on shaders are still there

Compilation crashes in the log you provided previously should be fixed already. If there are new crashes, upload the log files.

Here the log for Infamous 2 demo. It crashes in the same place

RPCS3.log

image

else
{
return name;
index =::size32(properties.constant_offsets);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
index =::size32(properties.constant_offsets);
index = ::size32(properties.constant_offsets);

@kd-11

kd-11 commented Aug 12, 2025

Copy link
Copy Markdown
Contributor Author

I think the perf loss is just because I forgot to restore optimizations in the shader compiler.

Hmm no difference on perf on KZ3 with latest commit. Also the crashes on shaders are still there

Compilation crashes in the log you provided previously should be fixed already. If there are new crashes, upload the log files.

Here the log for Infamous 2 demo. It crashes in the same place

RPCS3.log

image

Looks like a glslang bug? Same shader compiles fine for me. I'll circle back to this once I finish the interpreter work.

@digant73

Copy link
Copy Markdown
Contributor

with latest two commits the crashes are still present even in other places were it was not previously present such as in the following, in UC1 (u-boat chapter):

RPCS3.zip

image

@EmulationChannell

Copy link
Copy Markdown
Captura de tela 2025-08-14 185449 [RPCS3.log](https://github.com/user-attachments/files/21780949/RPCS3.log)

@bigol83

bigol83 commented Aug 15, 2025

Copy link
Copy Markdown

GTA IV crashes with this log just before reaching ingame

RPCS3.log

F 0:00:45.700683 {RSX [0x024179c]} SIG: Thread terminated due to fatal error: Failed to compile fragment shader
(in file C:/a/rpcs3/rpcs3/rpcs3/Emu/RSX/VK/VKProgramPipeline.cpp:109[:5], in function 'VkShaderModule vk::glsl::shader::compile()')

@kd-11

kd-11 commented Aug 17, 2025

Copy link
Copy Markdown
Contributor Author

Compiler crash is definitely a glslang bug. I'll figure out a workaround.

@kd-11

kd-11 commented Aug 17, 2025

Copy link
Copy Markdown
Contributor Author

@digant73 @bigol83 Time to retest once the artifacts are ready

@digant73

Copy link
Copy Markdown
Contributor

the crashes seem fixed but perf are overall the same or worse on my rtx 5090, especially on KZ2 and KZ3. In all games, I see more GPU usage (in RivaTuner SS) in the PR than in current build. E.g. in Infamous 1 and 2 it is 33% against 30%. In KZ1 and 2 the difference is more evident with high GPU usage (99% against 82%) with lower FPS (53 against solid 60) as reported in my previous post for KZ3

@bigol83

bigol83 commented Aug 17, 2025

Copy link
Copy Markdown

GTA IV also fixed for me, performance is about the same, maybe slightly lower in PR compared to master, like 1-2 fps lower in PR compared to master. I am on rtx 3060 gpu

@kd-11
kd-11 marked this pull request as ready for review August 17, 2025 20:09
@kd-11

kd-11 commented Aug 17, 2025

Copy link
Copy Markdown
Contributor Author

Not sure what is bugging with the NV driver, definitely something from their end. CPU usage should be much lower, and I don't have any plans on moving stuff back to the CPU. In fact, the roadmap offloads even more work to the GPU. I'll benchmark a few things, I probably just need to remove the UAVs from the FS stage. I'll see what nsight has to say about it.

@Valtekken

Copy link
Copy Markdown

Not sure what is bugging with the NV driver, definitely something from their end. CPU usage should be much lower, and I don't have any plans on moving stuff back to the CPU. In fact, the roadmap offloads even more work to the GPU. I'll benchmark a few things, I probably just need to remove the UAVs from the FS stage. I'll see what nsight has to say about it.

Offloading work to the GPU sounds good, would this result in lower requirements on the CPU side by any chance?

@digant73

Copy link
Copy Markdown
Contributor

Not sure what is bugging with the NV driver, definitely something from their end. CPU usage should be much lower, and I don't have any plans on moving stuff back to the CPU. In fact, the roadmap offloads even more work to the GPU. I'll benchmark a few things, I probably just need to remove the UAVs from the FS stage. I'll see what nsight has to say about it.

ok. CPU usage remained basically the same in my 9950X3D (otherwise I also reported it). Only GPU usage is worse

@kd-11
kd-11 force-pushed the descriptors-plan-b branch from ec9c38b to 93b6c87 Compare October 12, 2025 00:53
@kd-11

kd-11 commented Oct 12, 2025

Copy link
Copy Markdown
Contributor Author

This is ready for testing again. A workaround is in place for the crashing issue.

@Jonathan44062

Copy link
Copy Markdown

Completed the whole level of Manchester in Resistance without any crashes
playing a few races in GT5 and GT6 seems fine
GOW 3 seems fine too

@digant73

Copy link
Copy Markdown
Contributor

I confirm no more crash on FOM after some long runs.
@woj1993 Hopefully even the glitches on your games could be fixed. Please retest

@kd-11

kd-11 commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

Let's track any visual bugs in a separate ticket if any are found. Otherwise we'll never merge this monster of a PR.

@kd-11
kd-11 merged commit 1cae72c into RPCS3:master Oct 13, 2025
8 of 9 checks passed
@woj1993

woj1993 commented Oct 13, 2025

Copy link
Copy Markdown

Well after last commit Asura's Wrath has crashed RPCS3. It seems his wrath was too powerful. Log:
log.zip

@kd-11

kd-11 commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

Well after last commit Asura's Wrath has crashed RPCS3. It seems his wrath was too powerful. Log: log.zip

I don't see a RSX crash in the log. What happened when you ran it? It could be some random issue.
If you can reproduce it, just open a ticket with the log attached and tag me, I'll take it over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.