SDL_GPUShaderCreateInfo(3type)
β¨ SDL_GPUShaderCreateInfo β¨
okay bestie, gather round, because this one lives in the SDL3 DATATYPES section of the manual and it's literally the lil' info packet you hand over when you want a shader object to exist. it's giving "application form but for GPU shaders" π
it's a structure specifying code and metadata for creating a shader object. that's the whole vibe. no cap.
πΈ SYNOPSIS πΈ
first, the summoning ritual:
#include <SDL3/SDL_gpu.h>
and here's the struct itself, every field exactly as it is, don't touch anything:
typedef struct SDL_GPUShaderCreateInfo
{
size_t code_size; /**< The size in bytes of the code pointed to. */
const Uint8 *code; /**< A pointer to shader code. */
const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */
SDL_GPUShaderFormat format; /**< The format of the shader code. */
SDL_GPUShaderStage stage; /**< The stage the shader program corresponds to. */
Uint32 num_samplers; /**< The number of samplers defined in the shader. */
Uint32 num_storage_textures; /**< The number of storage textures defined in the shader. */
Uint32 num_storage_buffers; /**< The number of storage buffers defined in the shader. */
Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */
SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
} SDL_GPUShaderCreateInfo;
π DESCRIPTION π
so like, let's go field by field, because every single one of these matters and i am NOT letting you skip any π«Ά
code_sizeβ the size, in bytes, of the code thatcodeis pointing at. yes, you have to know how big your own shader is. it's fine.codeβ a pointer to the shader code. the actual goods. the main character of the whole struct honestly.entrypointβ a pointer to a null-terminated UTF-8 string with the name of the entry point function for the shader. aka "which function do we start at, bestie?" πformatβ the format of the shader code, as anSDL_GPUShaderFormat.stageβ the stage the shader program corresponds to, as anSDL_GPUShaderStage. vertex? fragment? you tell it.num_samplersβ the number of samplers defined in the shader. count them. all of them. π’num_storage_texturesβ the number of storage textures defined in the shader.num_storage_buffersβ the number of storage buffers defined in the shader.num_uniform_buffersβ the number of uniform buffers defined in the shader.propsβ a properties ID for extensions. Should be0if no extensions are needed. this is the important one, don't be out here passing random garbage when you're not even using extensions, that's not the vibe π
fr fr: fill in the counts honestly. they're metadata, and metadata lying is a whole situation. π
π AVAILABILITY π
this struct is available since SDL 3.2.0. she's been here a minute, she's iconic, she's settled. β¨
π SEE ALSO π
go read these next, they're the whole friend group:
and that's the page, babe π
brought to you by Simple Directmedia Layer, version SDL 3.4.18, living its life as SDL_GPUShaderCreateInfo(3type). go build a shader, you've got this π¦πΈπ
π¦ 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