|
group2 0.1.0
CSE 125 Group 2
|
Owns all particle GPU pipelines and per-category GPU buffers. More...
#include <ParticleRenderer.hpp>
Public Member Functions | |
| bool | init (SDL_GPUDevice *dev, SDL_GPUTextureFormat colorFmt, SDL_GPUShaderFormat shaderFmt) |
| Initialise GPU pipelines, buffers, and procedural textures. | |
| void | quit () |
| Release all GPU pipelines, buffers, and textures. | |
| void | uploadBillboards (SDL_GPUCommandBuffer *cmd, const BillboardParticle *data, uint32_t count) |
| Upload billboard particle data to the GPU. | |
| void | uploadTracers (SDL_GPUCommandBuffer *cmd, const TracerParticle *data, uint32_t count) |
| Upload tracer particle data to the GPU. | |
| void | uploadRibbon (SDL_GPUCommandBuffer *cmd, const RibbonVertex *data, uint32_t count) |
| Upload ribbon vertex data to the GPU. | |
| void | uploadHitscan (SDL_GPUCommandBuffer *cmd, const HitscanBeam *data, uint32_t count) |
| Upload hitscan beam data to the GPU. | |
| void | uploadArcs (SDL_GPUCommandBuffer *cmd, const ArcVertex *data, uint32_t count) |
| Upload lightning arc vertex data to the GPU. | |
| void | uploadSmoke (SDL_GPUCommandBuffer *cmd, const SmokeParticle *data, uint32_t count) |
| Upload smoke particle data to the GPU. | |
| void | uploadDecals (SDL_GPUCommandBuffer *cmd, const DecalInstance *data, uint32_t count) |
| Upload decal instance data to the GPU. | |
| void | uploadSdfWorld (SDL_GPUCommandBuffer *cmd, const SdfGlyphGPU *data, uint32_t count) |
| Upload world-space SDF glyph data to the GPU. | |
| void | uploadSdfHud (SDL_GPUCommandBuffer *cmd, const SdfGlyphGPU *data, uint32_t count) |
| Upload HUD SDF glyph data to the GPU. | |
| void | drawAll (SDL_GPURenderPass *pass, SDL_GPUCommandBuffer *cmd, float screenW, float screenH) |
| Issue all particle draw calls in the correct blend/depth order. | |
| SDL_GPUTexture * | smokeNoiseTex () const |
| SDL_GPUSampler * | smokeSampler () const |
| void | setSdfAtlas (SDL_GPUTexture *tex, SDL_GPUSampler *samp) |
| Register the SDF glyph atlas so drawAll() can bind it before drawing text. | |
Private Member Functions | |
| bool | buildPipelines () |
| Create all graphics pipelines for each particle category. | |
| SDL_GPUGraphicsPipeline * | makeStoragePipeline (const char *vertName, const char *fragName, uint32_t storageBufs, uint32_t samplers, SDL_GPUColorTargetBlendState blend, bool depthTest, bool depthWrite, bool depthBias, SDL_GPUPrimitiveType prim=SDL_GPU_PRIMITIVETYPE_TRIANGLELIST) |
| Create a pipeline that reads particle data from a storage buffer. | |
| SDL_GPUGraphicsPipeline * | makeVertexPipeline (const char *vertName, const char *fragName, SDL_GPUVertexInputState vertexInput, SDL_GPUColorTargetBlendState blend, bool depthTest, bool depthWrite, SDL_GPUPrimitiveType prim=SDL_GPU_PRIMITIVETYPE_TRIANGLELIST) |
| Create a pipeline that reads particle data from a vertex buffer. | |
| void | buildQuadIndexBuffer () |
| Build the shared quad index buffer ({0,1,2,2,3,0} x N). | |
| void | buildSmokeNoise () |
| Generate and upload the procedural smoke noise texture. | |
| void | buildDecalTexture () |
| Generate and upload the procedural bullet-hole decal texture. | |
Static Private Member Functions | |
| static SDL_GPUColorTargetBlendState | additiveBlend () |
| Return an additive blend state (src*alpha + dst*1). | |
| static SDL_GPUColorTargetBlendState | premulAlphaBlend () |
| Return a pre-multiplied alpha blend state (src*1 + dst*(1-srcAlpha)). | |
| static SDL_GPUColorTargetBlendState | alphaBlend () |
| Return a standard alpha blend state (src*alpha + dst*(1-srcAlpha)). | |
Private Attributes | |
| SDL_GPUDevice * | device_ = nullptr |
| SDL_GPUShaderFormat | shaderFmt_ = SDL_GPU_SHADERFORMAT_INVALID |
| SDL_GPUTextureFormat | colorFmt_ = SDL_GPU_TEXTUREFORMAT_INVALID |
| SDL_GPUGraphicsPipeline * | billboardPipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | tracerPipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | ribbonPipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | hitscanPipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | arcPipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | smokePipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | decalPipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | sdfWorldPipeline_ = nullptr |
| SDL_GPUGraphicsPipeline * | sdfHudPipeline_ = nullptr |
| SDL_GPUBuffer * | quadIndexBuf_ = nullptr |
| GpuParticleBuffer | billboardBuf_ |
| GpuParticleBuffer | tracerBuf_ |
| GpuParticleBuffer | ribbonBuf_ |
| GpuParticleBuffer | hitscanBuf_ |
| GpuParticleBuffer | arcBuf_ |
| GpuParticleBuffer | smokeBuf_ |
| GpuParticleBuffer | decalBuf_ |
| GpuParticleBuffer | sdfWorldBuf_ |
| GpuParticleBuffer | sdfHudBuf_ |
| SDL_GPUTexture * | smokeNoise_ = nullptr |
| SDL_GPUSampler * | smokeSampler_ = nullptr |
| SDL_GPUTexture * | decalTex_ = nullptr |
| SDL_GPUSampler * | decalSamp_ = nullptr |
| SDL_GPUTexture * | sdfAtlasTex_ = nullptr |
| SDL_GPUSampler * | sdfAtlasSamp_ = nullptr |
Static Private Attributes | |
| static constexpr uint32_t | k_maxQuadInstances = 4096 |
Owns all particle GPU pipelines and per-category GPU buffers.
ParticleSystem calls uploadAll() (before render pass) and drawAll() (inside render pass).
|
staticprivate |
Return an additive blend state (src*alpha + dst*1).
|
staticprivate |
Return a standard alpha blend state (src*alpha + dst*(1-srcAlpha)).
|
private |
Generate and upload the procedural bullet-hole decal texture.
|
nodiscardprivate |
Create all graphics pipelines for each particle category.
|
private |
Build the shared quad index buffer ({0,1,2,2,3,0} x N).
|
private |
Generate and upload the procedural smoke noise texture.
| void ParticleRenderer::drawAll | ( | SDL_GPURenderPass * | pass, |
| SDL_GPUCommandBuffer * | cmd, | ||
| float | screenW, | ||
| float | screenH ) |
Issue all particle draw calls in the correct blend/depth order.
| pass | The active render pass. |
| cmd | The command buffer (for push uniforms). |
| screenW | Window width in pixels for HUD uniform. |
| screenH | Window height in pixels for HUD uniform. |
| bool ParticleRenderer::init | ( | SDL_GPUDevice * | dev, |
| SDL_GPUTextureFormat | colorFmt, | ||
| SDL_GPUShaderFormat | shaderFmt ) |
Initialise GPU pipelines, buffers, and procedural textures.
| dev | The SDL GPU device. |
| colorFmt | Swapchain colour format. |
| shaderFmt | Shader binary format (SPIRV or MSL). |
|
nodiscardprivate |
Create a pipeline that reads particle data from a storage buffer.
| vertName | Vertex shader filename (without path/extension). |
| fragName | Fragment shader filename (without path/extension). |
| storageBufs | Number of storage buffers bound to the vertex stage. |
| samplers | Number of texture samplers bound to the fragment stage. |
| blend | Colour target blend state. |
| depthTest | Enable depth testing. |
| depthWrite | Enable depth writes. |
| depthBias | Enable depth bias (for decals). |
| prim | Primitive topology. |
|
nodiscardprivate |
Create a pipeline that reads particle data from a vertex buffer.
| vertName | Vertex shader filename (without path/extension). |
| fragName | Fragment shader filename (without path/extension). |
| vertexInput | Vertex input layout description. |
| blend | Colour target blend state. |
| depthTest | Enable depth testing. |
| depthWrite | Enable depth writes. |
| prim | Primitive topology. |
|
staticprivate |
Return a pre-multiplied alpha blend state (src*1 + dst*(1-srcAlpha)).
| void ParticleRenderer::quit | ( | ) |
Release all GPU pipelines, buffers, and textures.
|
inline |
Register the SDF glyph atlas so drawAll() can bind it before drawing text.
Call this once after SdfAtlas::init() succeeds.
|
inlinenodiscard |
|
inlinenodiscard |
| void ParticleRenderer::uploadArcs | ( | SDL_GPUCommandBuffer * | cmd, |
| const ArcVertex * | data, | ||
| uint32_t | count ) |
Upload lightning arc vertex data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to arc vertex array. |
| count | Number of vertices to upload. |
| void ParticleRenderer::uploadBillboards | ( | SDL_GPUCommandBuffer * | cmd, |
| const BillboardParticle * | data, | ||
| uint32_t | count ) |
Upload billboard particle data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to billboard particle array. |
| count | Number of particles to upload. |
| void ParticleRenderer::uploadDecals | ( | SDL_GPUCommandBuffer * | cmd, |
| const DecalInstance * | data, | ||
| uint32_t | count ) |
Upload decal instance data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to decal instance array. |
| count | Number of instances to upload. |
| void ParticleRenderer::uploadHitscan | ( | SDL_GPUCommandBuffer * | cmd, |
| const HitscanBeam * | data, | ||
| uint32_t | count ) |
Upload hitscan beam data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to hitscan beam array. |
| count | Number of beams to upload. |
| void ParticleRenderer::uploadRibbon | ( | SDL_GPUCommandBuffer * | cmd, |
| const RibbonVertex * | data, | ||
| uint32_t | count ) |
Upload ribbon vertex data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to ribbon vertex array. |
| count | Number of vertices to upload. |
| void ParticleRenderer::uploadSdfHud | ( | SDL_GPUCommandBuffer * | cmd, |
| const SdfGlyphGPU * | data, | ||
| uint32_t | count ) |
Upload HUD SDF glyph data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to SDF glyph array. |
| count | Number of glyphs to upload. |
| void ParticleRenderer::uploadSdfWorld | ( | SDL_GPUCommandBuffer * | cmd, |
| const SdfGlyphGPU * | data, | ||
| uint32_t | count ) |
Upload world-space SDF glyph data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to SDF glyph array. |
| count | Number of glyphs to upload. |
| void ParticleRenderer::uploadSmoke | ( | SDL_GPUCommandBuffer * | cmd, |
| const SmokeParticle * | data, | ||
| uint32_t | count ) |
Upload smoke particle data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to smoke particle array. |
| count | Number of particles to upload. |
| void ParticleRenderer::uploadTracers | ( | SDL_GPUCommandBuffer * | cmd, |
| const TracerParticle * | data, | ||
| uint32_t | count ) |
Upload tracer particle data to the GPU.
| cmd | Active command buffer. |
| data | Pointer to tracer particle array. |
| count | Number of particles to upload. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexprprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |