|
ObjectivelyGPU
Object oriented graphics framework for SDL3 and C
|
An SDL_GPUBuffer (vertex, index, indirect, storage, etc.) and its metadata.
More...
#include <Buffer.h>
Public Member Functions | |
| Buffer * | initWithConstMem (Buffer *self, RenderDevice *device, SDL_GPUBufferUsageFlags usage, const void *mem, Uint32 size) |
Initializes this Buffer and uploads mem in a single call. | |
| Buffer * | initWithData (Buffer *self, RenderDevice *device, SDL_GPUBufferUsageFlags usage, const Data *data) |
Initializes this Buffer and uploads the contents of an Objectively Data. | |
| Buffer * | initWithDevice (Buffer *self, RenderDevice *device, const SDL_GPUBufferCreateInfo *info) |
Initializes this Buffer, creating its SDL_GPUBuffer. | |
| void | setName (Buffer *self, const char *name) |
| Assigns a debug label to this buffer, visible in GPU capture tools. | |
| void | upload (Buffer *self, const void *data, Uint32 size, Uint32 offset, bool cycle) |
| Uploads raw CPU data into this buffer. | |
| Class * | _Buffer (void) |
| The Buffer archetype. | |
Data Fields | |
| Object | object |
| The superclass. | |
| SDL_GPUBuffer * | buffer |
| The underlying SDL buffer. | |
| SDL_GPUBufferUsageFlags | usage |
| The usage flags the buffer was created with. | |
| Uint32 | size |
| The size of the buffer, in bytes. | |
| ident | data |
| User data. | |
Protected Attributes | |
| BufferInterface * | interface |
| The interface. | |
An SDL_GPUBuffer (vertex, index, indirect, storage, etc.) and its metadata.
Buffer owns its underlying SDL_GPUBuffer and releases it in dealloc, so a Buffer is freed with release like any other Objectively object — there is no separate device-level release call:
Use upload to re-populate a dynamic buffer (sprites, UI, particles) each frame.
| Buffer * initWithConstMem | ( | Buffer * | self, |
| RenderDevice * | device, | ||
| SDL_GPUBufferUsageFlags | usage, | ||
| const void * | mem, | ||
| Uint32 | size | ||
| ) |
Initializes this Buffer and uploads mem in a single call.
Convenience initializer that creates a buffer sized to size via initWithDevice, then uploads mem with upload. The returned buffer is immediately GPU-resident.
| self | The Buffer. |
| device | The RenderDevice used to create and release the buffer. Retained. |
| usage | Buffer usage flags (e.g. SDL_GPU_BUFFERUSAGE_VERTEX). |
| mem | CPU pointer to the source data. Must not be NULL. |
| size | Number of bytes to allocate and upload. |
NULL on failure. | Buffer * initWithData | ( | Buffer * | self, |
| RenderDevice * | device, | ||
| SDL_GPUBufferUsageFlags | usage, | ||
| const Data * | data | ||
| ) |
Initializes this Buffer and uploads the contents of an Objectively Data.
Convenience initializer over initWithConstMem for data loaded via the Objectively Resource system.
| self | The Buffer. |
| device | The RenderDevice used to create and release the buffer. Retained. |
| usage | Buffer usage flags (e.g. SDL_GPU_BUFFERUSAGE_VERTEX). |
| data | Source data object. Must not be NULL. |
NULL on failure. | Buffer * initWithDevice | ( | Buffer * | self, |
| RenderDevice * | device, | ||
| const SDL_GPUBufferCreateInfo * | info | ||
| ) |
Initializes this Buffer, creating its SDL_GPUBuffer.
This is the designated initializer. The buffer's contents are uninitialised; use upload to populate it.
| self | The Buffer. |
| device | The RenderDevice used to create and release the buffer. Retained. |
| info | Buffer creation parameters (usage flags, size). |
NULL on failure. | void setName | ( | Buffer * | self, |
| const char * | name | ||
| ) |
Assigns a debug label to this buffer, visible in GPU capture tools.
| self | The Buffer. |
| name | A null-terminated debug name string. |
| void upload | ( | Buffer * | self, |
| const void * | data, | ||
| Uint32 | size, | ||
| Uint32 | offset, | ||
| bool | cycle | ||
| ) |
Uploads raw CPU data into this buffer.
Acquires a command buffer, creates a temporary transfer buffer, records a copy pass, submits, and releases the transfer buffer. Use this for dynamic buffers re-uploaded each frame. To batch multiple uploads into one command buffer, use CopyPass::uploadData instead.
| self | The Buffer. |
| data | CPU pointer to the source data. Must not be NULL. |
| size | Number of bytes to upload. |
| offset | Byte offset into this buffer where the data is written. |
| cycle | When true, the buffer is cycled to avoid pipeline stalls. |
| SDL_GPUBuffer* Buffer::buffer |
The underlying SDL buffer.
| ident Buffer::data |
User data.
|
protected |
The interface.
| Object Buffer::object |
The superclass.
| Uint32 Buffer::size |
The size of the buffer, in bytes.
| SDL_GPUBufferUsageFlags Buffer::usage |
The usage flags the buffer was created with.