Skip to main content

PARTICLE_TYPES

Constant PARTICLE_TYPES 

Source
pub const PARTICLE_TYPES: &str = "// The particle pool record and the per-emitter uniform, spliced into both\n// halves of the particle system at their PARTICLE_TYPES marker (see\n// slang_source.rs). Not a standalone program: it declares no entry point and no\n// resources. The simulation kernel writes the pool the render pair reads and\n// both stride the same uniform, so a per-shader copy is a silent layout-drift\n// hazard. Nothing here may spell the marker itself -- the splice would\n// reintroduce it into the assembled source.\n\n// One particle slot, 32 B. Matches `GpuParticle` in each backend\'s particle\n// module. Both (vec3, float) pairs are spelled as float4: MSL sizes a float3\n// at 16 bytes inside a structured buffer as well as inside a constant buffer,\n// so a literal transcription would push the second pair sixteen bytes late on\n// Metal alone.\nstruct Particle\n{\n    // xyz = world-space position, w = seconds lived.\n    float4 position_age;\n    // xyz = world-space velocity, w = total lifetime in seconds.\n    float4 velocity_lifetime;\n};\n\n// Per-frame emitter uniform, 112 B. Mirrors `ParticleParams` in\n// gfx/render_types.rs. The three (vec3, scalar) pairs are spelled as float4:\n// MSL sizes a constant-buffer float3 at 16 bytes, so a literal transcription\n// would push every following field four bytes late on Metal alone.\nstruct ParticleParams\n{\n    // xyz = world-space spawn origin, w = cosine of the emission cone\'s\n    // half-angle (1 = straight jet, -1 = full sphere).\n    float4 position_spread;\n    // xyz = unit-length mean emission direction, w = minimum spawn speed.\n    float4 direction_speed_min;\n    // xyz = constant per-frame acceleration, w = maximum spawn speed.\n    float4 gravity_speed_max;\n    float4 color_start;\n    float4 color_end;\n    float lifetime_min;\n    float lifetime_max;\n    float size_start;\n    float size_end;\n    float dt;\n    // Particles the kernel may emit this frame. Threads race for slots through\n    // the simulation\'s spawn counter, so only this many succeed.\n    uint spawn_budget;\n    uint random_seed;\n    uint max_particles;\n};\n";
Expand description

particle_types.slang.