gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.79k stars 938 forks source link

State change (draw call) overhead in `wgpu` is very high relative to vulkan #6357

Open alice-i-cecile opened 2 months ago

alice-i-cecile commented 2 months ago

Bevy users like @JMS55 and @HackerFoo have reported painfully high overhead costs paid by Bevy users due to our use of wgpu.

The "draw call overhead" issues are really more like state change overhead. In wgpu if you just call draw(), draw_indirect(), etc.. in an ultra tight loop, and don't do anything else in the loop, it's actually very fast. But if you do as much as bind a vertex and index buffer in that loop performance tanks relative to wgpu-hal or raw vulkan. And its something like the more bindings you change the more perf delta there is between wgpu and vulkan.

From @DGriffin91on Discord.

I'll be attempting to gather representative and/or minimal examples from the community: please link them here if you have any!

jimblandy commented 1 month ago

@alice-i-cecile With these apps you've linked, are there changes we can make to the code to compare the "good" and "bad" cases?

alice-i-cecile commented 1 month ago

Let me ask. Discussion here; I'll summarize anything concrete that comes out of it.

Update: Griffin has modified the bevy_caldera_scene above, as discussed here, to use unique materials per unique mesh and frame time went from 50 ms to 109 ms. Those changes should be available on the repo linked in the first message.