|
group2 0.1.0
CSE 125 Group 2
|
Manages a GPU storage buffer + CPU-side transfer buffer pair for particle data. More...
#include <GpuParticleBuffer.hpp>
Public Types | |
| enum class | Mode { Storage , Vertex } |
Public Member Functions | |
| void | init (SDL_GPUDevice *dev, uint32_t maxBytes, Mode mode=Mode::Storage) |
| Allocate GPU + transfer buffers of maxBytes each. | |
| void | quit () |
| Release all GPU resources. | |
| void | upload (SDL_GPUCommandBuffer *cmd, const void *data, uint32_t count, uint32_t stride) |
| Upload count * stride bytes from data to the GPU buffer. | |
| void | bindAsVertexStorage (SDL_GPURenderPass *pass, uint32_t slot) const |
| Bind as a vertex storage buffer at the given slot. | |
| void | bindAsVertex (SDL_GPURenderPass *pass) const |
| Bind as a vertex buffer at binding index 0. | |
| uint32_t | liveCount () const |
| uint32_t | capacityBytes () const |
Manages a GPU storage buffer + CPU-side transfer buffer pair for particle data.
Two usage modes are supported:
Storage mode (default): GPU buffer created with SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ. Vertex shaders read particle data as a readonly storage buffer via gl_InstanceIndex. Bound with bindAsVertexStorage().
Vertex mode: GPU buffer created with SDL_GPU_BUFFERUSAGE_VERTEX. Used for pre-expanded flat vertex streams (ribbon trails, lightning arcs). Bound with bindAsVertex().
In both cases upload() must be called inside a copy pass, BEFORE the render pass begins.
|
strong |
| void GpuParticleBuffer::bindAsVertex | ( | SDL_GPURenderPass * | pass | ) | const |
Bind as a vertex buffer at binding index 0.
| void GpuParticleBuffer::bindAsVertexStorage | ( | SDL_GPURenderPass * | pass, |
| uint32_t | slot | ||
| ) | const |
Bind as a vertex storage buffer at the given slot.
|
inline |
| void GpuParticleBuffer::init | ( | SDL_GPUDevice * | dev, |
| uint32_t | maxBytes, | ||
| Mode | mode = Mode::Storage |
||
| ) |
Allocate GPU + transfer buffers of maxBytes each.
|
inline |
| void GpuParticleBuffer::quit | ( | ) |
Release all GPU resources.
| void GpuParticleBuffer::upload | ( | SDL_GPUCommandBuffer * | cmd, |
| const void * | data, | ||
| uint32_t | count, | ||
| uint32_t | stride | ||
| ) |
Upload count * stride bytes from data to the GPU buffer.
Opens and closes its own SDL_GPUCopyPass internally. Must be called BEFORE SDL_BeginGPURenderPass.