![]() |
XII Release 0.1.0
|
Persistent GPU runtime for one particle system. Owns large buffers and registers graph passes. More...
#include <ParticleSystem.h>
Public Member Functions | |
| XII_ALWAYS_INLINE xiiUInt32 | GetParticleCapacity () const |
| Returns the current capacity of the particle system, which is determined by the size of the allocated GPU buffers and the limits defined in the descriptor. This can be used for debugging or for making decisions about how to configure emitters or other aspects of the particle graph based on the available capacity. | |
| XII_ALWAYS_INLINE xiiUInt32 | GetEventCapacity () const |
| Returns the current capacity for events in the particle system, which is determined by the size of the allocated GPU buffers and the limits defined in the descriptor. This can be used for debugging or for making decisions about how to configure event emitters or other aspects of the particle graph based on the available capacity for events. | |
| XII_ALWAYS_INLINE xiiUInt32 | GetNeighborPairCapacity () const |
| Returns the current capacity for neighbor pairs in the particle system, which is determined by the size of the allocated GPU buffers and the limits defined in the descriptor. This can be used for debugging or for making decisions about how to configure particle interactions or other aspects of the particle graph based on the available capacity for neighbor pairs. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetCurrentParticleStateBuffer () const |
| Returns the current particle state buffer for reading, which contains the state of all particles at the start of the current frame. This buffer is updated by the GPU during simulation passes and should be used for rendering or readback operations that need to access the current state of particles. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for rendering and simulation. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetNextParticleStateBuffer () const |
| Returns the next particle state buffer for writing, which is used for updating the state of all particles during simulation passes. This buffer is updated by the GPU during simulation passes and should be used for rendering or readback operations that need to access the updated state of particles after simulation. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for rendering and simulation. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetAliveIndexBuffer () const |
| Returns the alive index buffer, which contains the indices of currently alive particles. This buffer is updated by the GPU during simulation passes and should be used for rendering or readback operations that need to access the list of active particles. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for rendering and simulation. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetDeadIndexBuffer () const |
| Returns the dead index buffer, which contains the indices of currently dead particles. This buffer is updated by the GPU during simulation passes and can be used for debugging or for implementing features such as emitter throttling based on available capacity. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for rendering and simulation. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetCountersBuffer () const |
| Returns the counters buffer, which contains various counters related to the particle system (e.g., alive count, dead count, spawn request count, event count). This buffer is updated by the GPU during simulation passes and can be read by the renderer for rendering or debugging purposes. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for rendering and simulation. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetEventBuffer () const |
| Returns the event buffer, which contains events emitted by particles during simulation passes. This buffer is updated by the GPU during simulation passes when event support is enabled, and can be read by the renderer or by game logic for processing events. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for simulation and event processing. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetSortKeyBuffer () const |
| Returns the sort key buffer, which contains keys used for sorting particles (e.g., by depth or by ID). This buffer is updated by the GPU during simulation passes when sorting is enabled, and can be read by the renderer for rendering or debugging purposes. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for simulation and rendering. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetGridCellBuffer () const |
| Returns the grid cell buffer, which contains the spatial partitioning of particles into grid cells when GPU-based neighbor searching is enabled. This buffer is updated by the GPU during simulation passes when neighbor searching is enabled, and can be read by the renderer or by game logic for processing particle interactions. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for simulation and neighbor searching. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetGridCellRangeBuffer () const |
| Returns the grid cell range buffer, which contains the start and end indices of particles in each grid cell when GPU-based neighbor searching is enabled. This buffer is updated by the GPU during simulation passes when neighbor searching is enabled, and can be read by the renderer or by game logic for processing particle interactions. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for simulation and neighbor searching. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetNeighborPairBuffer () const |
| Returns the neighbor pair buffer, which contains pairs of neighboring particles when GPU-based neighbor searching is enabled. This buffer is updated by the GPU during simulation passes when neighbor searching is enabled, and can be read by the renderer or by game logic for processing particle interactions. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for simulation and neighbor searching. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetDrawIndirectBuffer () const |
| Returns the draw indirect buffer, which contains the arguments for indirect draw calls. This buffer is updated by the GPU during simulation passes when indirect drawing is enabled, and can be read by the renderer for rendering. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for simulation and rendering. | |
| XII_ALWAYS_INLINE xiiSharedPtr< xiiGALBuffer > | GetDispatchIndirectBuffer () const |
| Returns the dispatch indirect buffer, which contains the arguments for indirect dispatch calls (e.g., for culling or sorting). This buffer is updated by the GPU during simulation passes when async compute or GPU culling is enabled, and can be read by the renderer for rendering or by game logic for processing. The exact layout of this buffer is defined by the particle graph and should be compatible with the shader code used for simulation and any compute passes that use it. | |
| xiiResult | Initialize (xiiSharedPtr< xiiGALDevice > pDevice, const xiiParticleSystemDescriptor &descriptor) |
| Initializes the runtime with the given device and descriptor, creating necessary GPU resources. Returns failure if initialization fails (e.g., due to insufficient GPU resources or invalid descriptor parameters), in which case the runtime should not be used. | |
| void | Shutdown () |
| Shuts down the runtime and releases all GPU resources. After calling this, the runtime should not be used unless it is re-initialized. | |
| xiiResult | EnsureCapacity (const xiiParticleSystemDescriptor &descriptor) |
| Ensures that the runtime has sufficient capacity for the given descriptor, resizing GPU buffers if necessary. Returns failure if resizing fails (e.g., due to insufficient GPU resources), in which case the runtime may be left in a valid but potentially under-provisioned state. | |
| bool | IsInitialized () const |
| Returns whether the runtime has been successfully initialized and is ready for use. This checks whether necessary GPU resources have been created and are valid, but does not guarantee that the runtime is fully provisioned for a specific descriptor (e.g., if EnsureCapacity has not been called or has failed). | |
| void | ResetSimulationState (xiiGALCommandList *pCommandList=nullptr) |
| Resets the simulation state, clearing all particles and events. This can be used to restart the simulation or to clear out any existing state before starting a new effect. If a command list is provided, the reset operations will be recorded on that command list; otherwise, they will be executed immediately on the current context. | |
| void | SwapParticleStateBuffers () |
| Swaps the current and next particle state buffers, typically called at the end of a simulation pass to prepare for the next frame. This should be called after all simulation passes have been executed for the current frame, and before any rendering or readback operations that need to access the updated particle state. If double buffering is not enabled, this function may have no effect. | |
| void | SetNodeExecutor (xiiParticleGraphNodeExecutor executor) |
| Sets the node executor delegate, which is responsible for executing the logic of each particle graph node during simulation passes. This delegate will be called for each node in the graph that needs to be executed during a simulation pass, and should contain the logic for setting up shader parameters, dispatching compute shaders, and any other necessary operations to execute the node's behavior. The exact semantics of this delegate (e.g., how it's called and what it should do) are defined by the particle graph and may depend on the enabled features of the particle system. | |
| xiiResult | AddSimulationPasses (xiiRenderGraph &ref_graph, xiiStringView sNamePrefix, const xiiParticleSystemDescriptor &descriptor) |
| Adds the necessary simulation passes to the given render graph for executing the particle graph defined in the descriptor. This should be called during render graph construction, and will set up passes for emitting, simulating, and processing particles according to the logic defined in the particle graph resource. The sNamePrefix parameter can be used to give unique names to the passes for debugging purposes. Returns failure if adding the passes fails (e.g., due to invalid graph resources or issues with the render graph), in which case the render graph may be left in a valid but incomplete state. | |
Friends | |
| class | xiiParticleSystemManager |
Persistent GPU runtime for one particle system. Owns large buffers and registers graph passes.