SDL_GPUINDIRECTDRAWCOMMAND(3type)

πŸ’– SDL_GPUIndirectDrawCommand πŸ’–

okay bestie, welcome to the SDL3 datatypes section of the manual, and today's main character is SDL_GPUIndirectDrawCommand β€” literally the glow-up struct you hand to the GPU when you want it to draw stuff indirectly. no cap. ✨


✨ NAME ✨

SDL_GPUIndirectDrawCommand β€” a structure specifying the parameters of an indirect draw command. it's giving "here's the recipe, GPU, you do the cooking" πŸ“


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gpu.h>

typedef struct SDL_GPUIndirectDrawCommand
{
    Uint32 num_vertices;   /**< The number of vertices to draw. */
    Uint32 num_instances;  /**< The number of instances to draw. */
    Uint32 first_vertex;   /**< The index of the first vertex to draw. */
    Uint32 first_instance; /**< The ID of the first instance to draw. */
} SDL_GPUIndirectDrawCommand;

look at her. four little Uint32s, zero drama, maximum power. πŸ‘‘


πŸ’… DESCRIPTION πŸ’…

okay so here's the tea you actually need, and it's important, so sit down 🫢

the first_vertex and first_instance parameters are NOT compatible with the built-in vertex/instance ID variables in shaders (think stuff like SV_VertexID, iykyk). like, at all. not even a little.

the reason is so unserious: GPU APIs and shader languages just do not define these built-in variables consistently across the board. so if your shader is out here depending on them, the only way to keep behavior consistent and portable is to always pass 0 for the correlating parameter in the draw calls. always. no exceptions, bestie. 😭

fr fr, this is one of those "it works on my machine" traps that will absolutely humble you on a different backend. pass 0 and stay safe. πŸ’€

⭐ AVAILABILITY ⭐

this struct is available since SDL 3.2.0. she's not new new, but she's not ancient either. a modern icon. πŸŽ€


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page!! mwah πŸ’‹

Simple Directmedia Layer wrote this one, it's from SDL 3.4.18, and it lives in the SDL_GPUIndi...DrawCommand(3type) corner of the manual β€” okay bye, go pass 0 in your draw calls, ily!! πŸŒˆβœ¨πŸ’–

πŸ“¦ where this page comes from