class

GPUParticleRenderer

Abstract GPU particle renderer interface Manages compute simulation + billboard rendering for GPU-driven particle emitters.

Module
Particles
Header
#include "Particles/GPUParticleRenderer.h"
Namespace
Mowo

Constructors

SignatureNameDescription
virtual ~GPUParticleRenderer() = default~GPUParticleRenderer

Public functions

ReturnsNameDescription
boolInitialize
voidShutdown
voidSetTargetFramebufferOff-screen target the render pipelines build against (set before Initialize).
EmitterState*CreateEmitterStateCreate GPU state for an emitter with given max particle count
voidDestroyEmitterState
voidEmitParticlesMove particles the CPU spawned (through the emitter's spawn modules) into the pool: dead slot → particle → alive list.
voidPrepareSimulationSnapshot the alive count and clear the indirect draw args (call BEFORE Simulate).
voidSimulateDispatch compute simulation (call OUTSIDE render pass)
voidComputeBarrierCompute→compute barrier between the prepare and simulate passes.
voidInsertBarrierInsert compute→graphics barrier (call after all Simulate, before render pass)
voidResetStaging
voidStageEmit
voidStageExpressionsThe emitter's update scripts for this frame (layout: see Particles/GPUParticleExpression.comp.hlsl), run on its live particles after the simulate pass and before the sort.
boolSupportsExpressionsFalse when the expression pass could not be built (shader missing).
voidStageSimsortBackToFront orders the alive list far-to-near from the sim params' camera after the simulate pass; alpha-blended emitters need it, additive ones are order-independent and skip the cost.
voidRecordStagedSimulation
voidBeginFramePer-frame render submission: clear, record the emitters to draw, query.
voidSubmitEmitter
boolHasSubmissions
voidUpdateDepthImageScene depth for the manual depth test / soft fade, and the fog the billboards are drawn through (call BEFORE the render pass).
voidSetCollisionFieldBind the collision field's textures for the simulate pass (call before the world tick that drives Simulate).
voidRenderSubmittedDraw every submitted emitter (call INSIDE the render pass).
boolIsInitialized

Function details

~GPUParticleRenderer

C++
virtual ~GPUParticleRenderer() = default

Initialize

C++
virtual bool Initialize() = 0

Shutdown

C++
virtual void Shutdown() = 0

SetTargetFramebuffer

C++
virtual void SetTargetFramebuffer(const FramebufferSpecification& spec) = 0

Off-screen target the render pipelines build against (set before Initialize).

CreateEmitterState

C++
virtual EmitterState* CreateEmitterState(uint32_t maxParticles) = 0

Create GPU state for an emitter with given max particle count

DestroyEmitterState

C++
virtual void DestroyEmitterState(EmitterState* state) = 0

EmitParticles

C++
virtual void EmitParticles(EmitterState* state, const GPUParticle* particles, uint32_t count, const Vec4* custom = nullptr) = 0

Move particles the CPU spawned (through the emitter's spawn modules) into the pool: dead slot → particle → alive list. custom carries each new particle's custom attributes (null = all zero).

PrepareSimulation

C++
virtual void PrepareSimulation(EmitterState* state) = 0

Snapshot the alive count and clear the indirect draw args (call BEFORE Simulate).

Simulate

C++
virtual void Simulate(EmitterState* state, const GPUParticleSimParams& simParams) = 0

Dispatch compute simulation (call OUTSIDE render pass)

ComputeBarrier

C++
virtual void ComputeBarrier() = 0

Compute→compute barrier between the prepare and simulate passes.

InsertBarrier

C++
virtual void InsertBarrier() = 0

Insert compute→graphics barrier (call after all Simulate, before render pass)

ResetStaging

C++
virtual void ResetStaging() = 0

StageEmit

C++
virtual void StageEmit(EmitterState* state, const GPUParticle* particles, uint32_t count, const Vec4* custom = nullptr) = 0

StageExpressions

C++
virtual void StageExpressions(EmitterState* state, const uint32_t* words, uint32_t wordCount, const Vec3& emitterPos, float deltaTime) = 0

The emitter's update scripts for this frame (layout: see Particles/GPUParticleExpression.comp.hlsl), run on its live particles after the simulate pass and before the sort.

SupportsExpressions

C++
virtual bool SupportsExpressions() const = 0

False when the expression pass could not be built (shader missing).

StageSim

C++
virtual void StageSim(EmitterState* state, const GPUParticleSimParams& simParams, bool sortBackToFront) = 0

sortBackToFront orders the alive list far-to-near from the sim params' camera after the simulate pass; alpha-blended emitters need it, additive ones are order-independent and skip the cost.

RecordStagedSimulation

C++
virtual void RecordStagedSimulation() = 0

BeginFrame

C++
virtual void BeginFrame() = 0

Per-frame render submission: clear, record the emitters to draw, query.

SubmitEmitter

C++
virtual void SubmitEmitter(EmitterState* state, const GPURenderEmitterParams& params) = 0

HasSubmissions

C++
virtual bool HasSubmissions() const = 0

UpdateDepthImage

C++
virtual void UpdateDepthImage(Ref<Image2D> depthImage, const FParticleFogInputs& fog) = 0

Scene depth for the manual depth test / soft fade, and the fog the billboards are drawn through (call BEFORE the render pass).

SetCollisionField

C++
virtual void SetCollisionField(Ref<Image3D> sdf, Ref<Image2D> depth) = 0

Bind the collision field's textures for the simulate pass (call before the world tick that drives Simulate). Null textures bind dummies; the per-emitter collision params ride in GPUParticleSimParams and gate whether an emitter samples them at all.

RenderSubmitted

C++
virtual void RenderSubmitted(const Mat4& viewProjection, const Vec3& cameraPos, const Vec4& depthLinearize, uint32_t viewportWidth, uint32_t viewportHeight) = 0

Draw every submitted emitter (call INSIDE the render pass). depthLinearize is the projection's (m22, m23, m32, m33), matching the CPU soft-particle fade.

IsInitialized

C++
virtual bool IsInitialized() const = 0
Generated from Particles/GPUParticleRenderer.h via particles.json · Oct 31, 2026Version 1.0.0