Skip to content
Joris Willems edited this page Aug 8, 2023 · 1 revision

Particle system using wgpu + egui

Subjects

  • Code overview
  • Ping pong buffers
  • Skipping vertex buffers

Code overview

The best way to understand the code setup is to look at the lib.rs file. Here you can see there are three states being used: (gui, app and gfx). The gui state is used for maintaining all changes that happen because of egui. The gfx state is used for all simple gfx settings like device, surface_configuration, rendering. The app state contains all the logic regarding the application.

Ping pong buffers

Ping pong buffers are used to drastically improve performance when using compute buffers. Since wgpu will block reading from a read_write bind_group before it is fully written to. You slow down your application a lot, with ping pong buffers wgpu render can read the read_only bind_group while compute is updating the read_write bind group.

Skipping vertex buffers

There is no need to use vertex buffers if you already have all the vertex data available. With particle systems you can skip this process and create the vertices in the shader or pass them in some uniform like I do.

Clone this wiki locally