27 bool init(SDL_GPUDevice* dev, SDL_GPUTextureFormat colorFmt, SDL_GPUShaderFormat shaderFmt);
95 void drawAll(SDL_GPURenderPass* pass, SDL_GPUCommandBuffer* cmd,
float screenW,
float screenH);
98 [[nodiscard]] SDL_GPUTexture*
smokeNoiseTex()
const {
return smokeNoise_; }
99 [[nodiscard]] SDL_GPUSampler*
smokeSampler()
const {
return smokeSampler_; }
106 sdfAtlasSamp_ = samp;
110 SDL_GPUDevice* device_ =
nullptr;
111 SDL_GPUShaderFormat shaderFmt_ = SDL_GPU_SHADERFORMAT_INVALID;
112 SDL_GPUTextureFormat colorFmt_ = SDL_GPU_TEXTUREFORMAT_INVALID;
115 SDL_GPUGraphicsPipeline* billboardPipeline_ =
nullptr;
116 SDL_GPUGraphicsPipeline* tracerPipeline_ =
nullptr;
117 SDL_GPUGraphicsPipeline* ribbonPipeline_ =
nullptr;
118 SDL_GPUGraphicsPipeline* hitscanPipeline_ =
nullptr;
119 SDL_GPUGraphicsPipeline* arcPipeline_ =
nullptr;
120 SDL_GPUGraphicsPipeline* smokePipeline_ =
nullptr;
121 SDL_GPUGraphicsPipeline* decalPipeline_ =
nullptr;
122 SDL_GPUGraphicsPipeline* sdfWorldPipeline_ =
nullptr;
123 SDL_GPUGraphicsPipeline* sdfHudPipeline_ =
nullptr;
126 SDL_GPUBuffer* quadIndexBuf_ =
nullptr;
127 static constexpr uint32_t k_maxQuadInstances = 4096;
141 SDL_GPUTexture* smokeNoise_ =
nullptr;
142 SDL_GPUSampler* smokeSampler_ =
nullptr;
145 SDL_GPUTexture* decalTex_ =
nullptr;
146 SDL_GPUSampler* decalSamp_ =
nullptr;
149 SDL_GPUTexture* sdfAtlasTex_ =
nullptr;
150 SDL_GPUSampler* sdfAtlasSamp_ =
nullptr;
155 [[nodiscard]]
bool buildPipelines();
167 [[nodiscard]] SDL_GPUGraphicsPipeline*
168 makeStoragePipeline(
const char* vertName,
169 const char* fragName,
170 uint32_t storageBufs,
172 SDL_GPUColorTargetBlendState blend,
176 SDL_GPUPrimitiveType prim = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST);
187 [[nodiscard]] SDL_GPUGraphicsPipeline*
188 makeVertexPipeline(
const char* vertName,
189 const char* fragName,
190 SDL_GPUVertexInputState vertexInput,
191 SDL_GPUColorTargetBlendState blend,
194 SDL_GPUPrimitiveType prim = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST);
197 void buildQuadIndexBuffer();
200 void buildSmokeNoise();
203 void buildDecalTexture();
206 static SDL_GPUColorTargetBlendState additiveBlend();
209 static SDL_GPUColorTargetBlendState premulAlphaBlend();
212 static SDL_GPUColorTargetBlendState alphaBlend();
GPU storage/vertex buffer paired with a CPU transfer buffer for particle uploads.
Fixed-capacity particle pool with O(1) swap-remove.
GPU-uploadable particle structs for all effect categories.
Manages a GPU storage buffer + CPU-side transfer buffer pair for particle data.
Definition GpuParticleBuffer.hpp:26
Owns all particle GPU pipelines and per-category GPU buffers.
Definition ParticleRenderer.hpp:20
void setSdfAtlas(SDL_GPUTexture *tex, SDL_GPUSampler *samp)
Register the SDF glyph atlas so drawAll() can bind it before drawing text.
Definition ParticleRenderer.hpp:103
bool init(SDL_GPUDevice *dev, SDL_GPUTextureFormat colorFmt, SDL_GPUShaderFormat shaderFmt)
Initialise GPU pipelines, buffers, and procedural textures.
Definition ParticleRenderer.cpp:463
void quit()
Release all GPU pipelines, buffers, and textures.
Definition ParticleRenderer.cpp:579
void uploadSmoke(SDL_GPUCommandBuffer *cmd, const SmokeParticle *data, uint32_t count)
Upload smoke particle data to the GPU.
Definition ParticleRenderer.cpp:662
void uploadHitscan(SDL_GPUCommandBuffer *cmd, const HitscanBeam *data, uint32_t count)
Upload hitscan beam data to the GPU.
Definition ParticleRenderer.cpp:652
void uploadRibbon(SDL_GPUCommandBuffer *cmd, const RibbonVertex *data, uint32_t count)
Upload ribbon vertex data to the GPU.
Definition ParticleRenderer.cpp:647
void uploadDecals(SDL_GPUCommandBuffer *cmd, const DecalInstance *data, uint32_t count)
Upload decal instance data to the GPU.
Definition ParticleRenderer.cpp:667
SDL_GPUSampler * smokeSampler() const
Definition ParticleRenderer.hpp:99
void uploadArcs(SDL_GPUCommandBuffer *cmd, const ArcVertex *data, uint32_t count)
Upload lightning arc vertex data to the GPU.
Definition ParticleRenderer.cpp:657
void uploadSdfHud(SDL_GPUCommandBuffer *cmd, const SdfGlyphGPU *data, uint32_t count)
Upload HUD SDF glyph data to the GPU.
Definition ParticleRenderer.cpp:677
void uploadTracers(SDL_GPUCommandBuffer *cmd, const TracerParticle *data, uint32_t count)
Upload tracer particle data to the GPU.
Definition ParticleRenderer.cpp:642
SDL_GPUTexture * smokeNoiseTex() const
Definition ParticleRenderer.hpp:98
void uploadBillboards(SDL_GPUCommandBuffer *cmd, const BillboardParticle *data, uint32_t count)
Upload billboard particle data to the GPU.
Definition ParticleRenderer.cpp:637
void uploadSdfWorld(SDL_GPUCommandBuffer *cmd, const SdfGlyphGPU *data, uint32_t count)
Upload world-space SDF glyph data to the GPU.
Definition ParticleRenderer.cpp:672
void drawAll(SDL_GPURenderPass *pass, SDL_GPUCommandBuffer *cmd, float screenW, float screenH)
Issue all particle draw calls in the correct blend/depth order.
Definition ParticleRenderer.cpp:699
Lightning arc vertex (pre-expanded triangle strip, uploaded as flat stream).
Definition ParticleTypes.hpp:58
Single billboard particle (sparks, impact flash, shockwave ring).
Definition ParticleTypes.hpp:12
World-space decal instance (bullet hole, scorch mark).
Definition ParticleTypes.hpp:80
Hitscan energy beam (main glowing quad).
Definition ParticleTypes.hpp:46
Ribbon vertex (pre-expanded on CPU, uploaded as flat vertex stream).
Definition ParticleTypes.hpp:37
SDF glyph quad (world-space or screen-space HUD).
Definition ParticleTypes.hpp:94
Smoke / fire billboard (uses noise texture for volumetric look).
Definition ParticleTypes.hpp:67
Oriented capsule streak for fast-bullet tracers (R301 style).
Definition ParticleTypes.hpp:23