SDL_GPUBufferUsageFlags(3type)
π SDL_GPUBufferUsageFlags π
okay bestie, welcome to the SDL3 DATATYPES corner of the manual, where we're talking about SDL_GPUBufferUsageFlags β aka the little flag salad that tells SDL how your buffer is intended to be used by the client. no cap, that's literally the whole NAME section. π«Ά
β¨ SYNOPSIS β¨
#include <SDL3/SDL_gpu.h>
typedef Uint32 SDL_GPUBufferUsageFlags;
#define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0) /**< Buffer is a vertex buffer. */
#define SDL_GPU_BUFFERUSAGE_INDEX (1u << 1) /**< Buffer is an index buffer. */
#define SDL_GPU_BUFFERUSAGE_INDIRECT (1u << 2) /**< Buffer is an indirect buffer. */
#define SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Buffer supports storage reads in graphics stages. */
#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Buffer supports storage reads in the compute stage. */
#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Buffer supports storage writes in the compute stage. */
so yeah, it's just a Uint32 underneath, and each of these defines is one lil' bit you can flip on. here's the breakdown, one by one, no skipping, i promise:
SDL_GPU_BUFFERUSAGE_VERTEXβ(1u << 0)β this buffer is a vertex buffer. it's giving β¨ vertices β¨.SDL_GPU_BUFFERUSAGE_INDEXβ(1u << 1)β this buffer is an index buffer.SDL_GPU_BUFFERUSAGE_INDIRECTβ(1u << 2)β this buffer is an indirect buffer.SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READβ(1u << 3)β buffer supports storage reads in graphics stages.SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READβ(1u << 4)β buffer supports storage reads in the compute stage.SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITEβ(1u << 5)β buffer supports storage writes in the compute stage. yes queen, we're writing now π
πΈ DESCRIPTION πΈ
first things first, and this one's a hard rule bestie: a buffer must have at least one usage flag. not zero. one. minimum. periodt.
now, if a buffer has multiple read usages, that may lead to a performance penalty, because of more conservative memory barriers. but alsoβ¦ it may not necessarily affect the performance. π so like, it's a maybe. the manpage said it, i'm just relaying it, don't shoot the messenger.
lowkey the most important glow-up here: unlike textures, READ | WRITE can be used for simultaneous read-write usage. the same data synchronization concerns as textures apply though, so don't get cocky. π
and if you use a STORAGE flag, the data in the buffer must respect std140 layout conventions. in practical terms that means you must ensure that vec3 and vec4 fields are 16-byte aligned. no vibes-based alignment, actual bytes. π
β AVAILABILITY β
this datatype has been available since SDL 3.2.0. she's not ancient, she's not brand new, she's just right. π¦
π SEE ALSO π
SDL_CreateGPUBuffer(3)β go make one, iykyk π«Ά
okay that's the whole page, you ate it fr fr. this was Simple Directmedia Layer, running SDL 3.4.18, and the page is SDL_GPUBufferUsageFlags(3type) β mwah, slay, bye bestie πβ¨π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms