Skip to main content

Module gpu_particles

Module gpu_particles 

Source
Expand description

GPU particle systems: compute-driven emit + sim with sprite draw. GPU particle systems.

A particle system owns a persistent GPU buffer holding capacity particles. Each particle stores its world-space position, velocity, lifetime remaining, starting lifetime, colour, and size.

The host calls [DeviceResources::create_gpu_particle_system] once at startup to allocate the buffer, then submits a GpuParticleSystemItem per frame. The renderer dispatches an emit compute pass (recycling dead particles back into live ones based on EmitterConfig), then a sim compute pass (integrating ForceFields and decrementing lifetime), then draws the live particles via the route picked in [GpuParticleSystemConfig::render].

Dead particles are not compacted. The emit shader scans for slots with lifetime <= 0 and reuses them; the draw shader emits a degenerate clip position for dead slots so they cost nothing in the rasteriser. Compaction would require a prefix sum each frame and is not worth the cost at the particle counts the API targets (1k - 200k).

Structs§

GpuParticleSystemConfig
Persistent configuration for a particle system. Set at creation; the render route and capacity are stable for the system’s lifetime.
GpuParticleSystemId
Handle to a persistent GPU particle system.

Enums§

ParticleRender
How a particle system draws its live particles.