sodium-fabric icon indicating copy to clipboard operation
sodium-fabric copied to clipboard

Combine draw commands to improve rendering performance

Open douira opened this issue 4 months ago • 4 comments

Prerequisite PR: https://github.com/CaffeineMC/sodium-fabric/pull/2352 (built on top of that branch, when that PR is merged this PR will only have one differing commit)

This PR makes it so that draw commands that read from adjacent vertex data are combined. This reduces the number of draw commands by around 30% and improves fps on my system by 16-30% depending on the scene and circumstances. I'm on macOS with a 6900 XT. This performance improvement likely comes, as jellysquid stated on discord, from reduced CPU overhead in the driver and better GPU occupancy.

Please test if this results in a similar improvement or other effect, as it's probably dependent on graphics card, memory bandwidth, and platform (os/driver/vendor etc).

Here's a recording of the number of draw commands per pass: ts on, before: Draw total for pass Solid: 15531 Draw total for pass Cutout: 13277 Draw total for pass Translucent: 2298

ts on, after: Draw total for pass Solid: 9571 Draw total for pass Cutout: 8306 Draw total for pass Translucent: 2298

ts off, before: Draw total for pass Solid: 15531 Draw total for pass Cutout: 13277 Draw total for pass Translucent: 3812

ts off, after: Draw total for pass Solid: 9571 Draw total for pass Cutout: 8306 Draw total for pass Translucent: 3645

Here's some screenshots without and with this patch:

Screenshot 2024-04-14 at 04 29 12 Screenshot 2024-04-14 at 04 27 59 Screenshot 2024-04-14 at 04 30 51 Screenshot 2024-04-14 at 04 32 25 Screenshot 2024-04-14 at 04 48 21 Screenshot 2024-04-14 at 04 49 16

douira avatar Apr 14 '24 03:04 douira