Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::GpuParticles Class Reference

#include <GpuParticles.hpp>

Classes

struct  Job

Public Member Functions

 GpuParticles (GfxDevice &device)
 ~GpuParticles ()
 GpuParticles (const GpuParticles &)=delete
GpuParticles & operator= (const GpuParticles &)=delete
bool available () const
 Whether the device can run the kernel at all.
void beginFrame ()
 A new frame: the previous frame's jobs are gone, and a slot nobody asked for in a while is given back.
bool submit (Entity entity, const ecs::ParticleEmitter &emitter, const ecs::Transform &transform, particle::ParticleSystem &system, const particle::GpuStep &step, const glm::vec4 &eye, BufferHandle &instances, BufferHandle &segments, u32 &segmentCount)
 Queues the step an emitter needs and says where its particles are. The step is committed to the emitter only once the kernel has run it; an emitter already queued this frame is not queued twice.
bool wantsDepth () const
 An emitter collided with the depth last frame, so the scene must draw into a target whose depth can be read.
void declareDepthCopy (rg::RenderGraph &graph, rg::ResourceId scene, u32 sceneW, u32 sceneH, const glm::mat4 &clip)
 Copies the scene's depth for next frame's kernel, once a frame. clip is the view that drew it, in the device's clip range.
rg::ResourceId declare (rg::RenderGraph &graph)
 Adds the compute pass for what was submitted. The resource it writes must be named by the pass that draws the result.
void release ()
u32 slotCount () const
 Slots live right now, for the stats.
u32 lastDispatches () const
u32 drawnSlots () const
 Particle slots handed to a draw this frame, over every emitter and camera: what the GPU is asked to draw.
void setDepthGridMax (u32 texels)
u32 depthGridWidth () const

Detailed Description

Definition at line 42 of file GpuParticles.hpp.

Constructor & Destructor Documentation

◆ GpuParticles() [1/2]

esengine::GpuParticles::GpuParticles ( GfxDevice & device)
explicit

Definition at line 715 of file GpuParticles.cpp.

References release().

Referenced by GpuParticles(), and operator=().

◆ ~GpuParticles()

esengine::GpuParticles::~GpuParticles ( )

Definition at line 717 of file GpuParticles.cpp.

◆ GpuParticles() [2/2]

esengine::GpuParticles::GpuParticles ( const GpuParticles & )
delete

References GpuParticles().

Member Function Documentation

◆ available()

bool esengine::GpuParticles::available ( ) const

Whether the device can run the kernel at all.

Definition at line 721 of file GpuParticles.cpp.

◆ beginFrame()

void esengine::GpuParticles::beginFrame ( )

A new frame: the previous frame's jobs are gone, and a slot nobody asked for in a while is given back.

Definition at line 759 of file GpuParticles.cpp.

◆ declare()

rg::ResourceId esengine::GpuParticles::declare ( rg::RenderGraph & graph)

Adds the compute pass for what was submitted. The resource it writes must be named by the pass that draws the result.

Definition at line 1082 of file GpuParticles.cpp.

References esengine::RGBA8.

◆ declareDepthCopy()

void esengine::GpuParticles::declareDepthCopy ( rg::RenderGraph & graph,
rg::ResourceId scene,
u32 sceneW,
u32 sceneH,
const glm::mat4 & clip )

Copies the scene's depth for next frame's kernel, once a frame. clip is the view that drew it, in the device's clip range.

Definition at line 1021 of file GpuParticles.cpp.

References esengine::RGBA8.

◆ depthGridWidth()

u32 esengine::GpuParticles::depthGridWidth ( ) const
inline

Definition at line 87 of file GpuParticles.hpp.

◆ drawnSlots()

u32 esengine::GpuParticles::drawnSlots ( ) const
inline

Particle slots handed to a draw this frame, over every emitter and camera: what the GPU is asked to draw.

Definition at line 84 of file GpuParticles.hpp.

◆ lastDispatches()

u32 esengine::GpuParticles::lastDispatches ( ) const
inline

Definition at line 82 of file GpuParticles.hpp.

◆ operator=()

GpuParticles & esengine::GpuParticles::operator= ( const GpuParticles & )
delete

References GpuParticles().

◆ release()

void esengine::GpuParticles::release ( )

Definition at line 735 of file GpuParticles.cpp.

References esengine::Invalid.

Referenced by GpuParticles().

◆ setDepthGridMax()

void esengine::GpuParticles::setDepthGridMax ( u32 texels)

Definition at line 1078 of file GpuParticles.cpp.

◆ slotCount()

u32 esengine::GpuParticles::slotCount ( ) const
inline

Slots live right now, for the stats.

Definition at line 81 of file GpuParticles.hpp.

◆ submit()

bool esengine::GpuParticles::submit ( Entity entity,
const ecs::ParticleEmitter & emitter,
const ecs::Transform & transform,
particle::ParticleSystem & system,
const particle::GpuStep & step,
const glm::vec4 & eye,
BufferHandle & instances,
BufferHandle & segments,
u32 & segmentCount )

Queues the step an emitter needs and says where its particles are. The step is committed to the emitter only once the kernel has run it; an emitter already queued this frame is not queued twice.

Parameters
drawCountHow many slots may hold a live particle once the step has run.
eyeWhere the frame is seen from, as FrameConstants::camera has it: what a trail's quads are turned to face.
instancesThe buffer to draw them from.
segmentsThe buffer to draw its trails from, and how many; untouched where it has none.
Returns
false when there is nothing to draw (no compute, no memory).

Definition at line 863 of file GpuParticles.cpp.

References esengine::ecs::Birth, esengine::GpuParticles::Job::block, esengine::ecs::Collision, esengine::ecs::Death, esengine::math::DEG_TO_RAD, esengine::ecs::Depth, esengine::particle::ForceFieldInstance::direction, ES_LOG_ERROR, esengine::GpuParticles::Job::eventCapacity, esengine::particle::ForceFieldInstance::falloff, esengine::ecs::Floor, esengine::GpuParticles::Job::inheritVelocity, esengine::Invalid, esengine::particle::kMaxTrailPoints, esengine::ecs::Local, esengine::ecs::Physics2D, esengine::ecs::Physics3D, esengine::particle::ForceFieldInstance::position, esengine::particle::ForceFieldInstance::radius, esengine::renderOrigin(), esengine::GpuParticles::Job::reportEvents, esengine::ecs::Sdf, esengine::Storage, esengine::particle::ForceFieldInstance::strength, esengine::GpuParticles::Job::subEmitter, esengine::GfxContent::transient(), and esengine::particle::ForceFieldInstance::type.

Referenced by esengine::ParticlePlugin::collect().

◆ wantsDepth()

bool esengine::GpuParticles::wantsDepth ( ) const
inline

An emitter collided with the depth last frame, so the scene must draw into a target whose depth can be read.

Definition at line 70 of file GpuParticles.hpp.


The documentation for this class was generated from the following files: