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 πŸŽ€


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