SDL_CreateGPUBuffer(3)
β¨ NAME β¨
okay so bestie, we're doing SDL_CreateGPUBuffer today β it's a function from the SDL3 FUNCTIONS corner of the SDL3 manual, and it literally just creates a buffer object to be used in graphics or compute workflows. that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_gpu.h>
SDL_GPUBuffer * SDL_CreateGPUBuffer(
SDL_GPUDevice *device,
const SDL_GPUBufferCreateInfo *createinfo);
yes it's giving "two arguments and a dream". π«Ά
π DESCRIPTION π
so like. the contents of this buffer are undefined until data is written to the buffer. not "empty", not "zeroed" β undefined. do not go reading it and expecting anything cute. π
also not all usage flag combos are valid, bestie. for example, a buffer cannot have both the VERTEX and INDEX flags. it's giving "pick a lane". β
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. the alignment gods do not negotiate. π
and if you wanna actually understand the underlying concepts and memory management with the SDL GPU API, there's a blog post for that:
https://moonside.games/posts/sdl-gpu-concepts-cycling/
(it's a whole read, highly recommend, iykyk. π)
there are optional properties you can hand over through props. these are the supported properties:
SDL_PROP_GPU_BUFFER_CREATE_NAME_STRINGβ a name that can be displayed in debugging tools. give ur buffer a little name tag, she deserves it π
π¦ FUNCTION PARAMETERS π¦
deviceβ a GPU Context. (the whole GPU situation, basically π)createinfoβ a struct describing the state of the buffer to create. (tell me everything about her. what she is. what she's for. β¨)
π RETURN VALUE π
returns a buffer object on success, or NULL on failure. and if it fails? call SDL_GetError() for more info, because she will tell you what went wrong, no cap. π
β AVAILABILITY β
this function is available since SDL 3.2.0. so if ur on something older, sorry bestie, no buffer for you. π
π SEE ALSO π
the whole friend group, obviously:
SDL_UploadToGPUBuffer(3)SDL_DownloadFromGPUBuffer(3)SDL_CopyGPUBufferToBuffer(3)SDL_BindGPUVertexBuffers(3)SDL_BindGPUIndexBuffer(3)SDL_BindGPUVertexStorageBuffers(3)SDL_BindGPUFragmentStorageBuffers(3)SDL_DrawGPUPrimitivesIndirect(3)SDL_DrawGPUIndexedPrimitivesIndirect(3)SDL_BindGPUComputeStorageBuffers(3)SDL_DispatchGPUComputeIndirect(3)SDL_ReleaseGPUBuffer(3)
pspsps β don't forget SDL_ReleaseGPUBuffer(3) when ur done. memory doesn't clean itself up, and that's not the vibe we're going for. π§
Simple Directmedia Layer β SDL 3.4.18. mwah, that's the whole page, go forth and allocate responsibly ππβ¨
π¦ 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