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 that code is 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 an SDL_GPUShaderFormat.
  • stage β€” the stage the shader program corresponds to, as an SDL_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 be 0 if 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