SDL_DispatchGPUCompute(3)

SDL_DispatchGPUCompute(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we make your GPU do homework for you ✨ this one's from <SDL3/SDL_gpu.h> and it's giving compute dispatch energy, no cap.


✨ NAME ✨

SDL_DispatchGPUCompute β€” dispatches compute work. that's it, that's the whole vibe 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gpu.h>

void SDL_DispatchGPUCompute(
    SDL_GPUComputePass *compute_pass,
    Uint32 groupcount_x,
    Uint32 groupcount_y,
    Uint32 groupcount_z);

look at her. four params, returns void, zero drama. iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, this function sends your compute work off to do its little thing. but there's a RULE, bestie, and it's non-negotiable:

You must not call this function before binding a compute pipeline.

fr fr. bind the pipeline first. the pipeline is the main character here and you cannot skip her intro 😭

πŸŽ€ A VERY IMPORTANT NOTE πŸŽ€

not me putting this in its own section because it's genuinely that serious:

If you dispatch multiple times in a compute pass, and the dispatches write to the same resource region as each other, there is no guarantee of which order the writes will occur. If the write order matters, you MUST end the compute pass and begin another one.

translating for the group chat: multiple dispatches in one pass + overlapping writes = chaos. nobody knows who wrote what first, not even the driver, not even god. if the order actually matters to you? end the compute pass, start a fresh one, and suddenly everything is deterministic again. do not fight this. she is not asking πŸ’€


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • compute_pass β€” a compute pass handle. this is your little ticket into the pass, your backstage lanyard 🎟️
  • groupcount_x β€” number of local workgroups to dispatch in the X dimension. the horizontal girly ✨
  • groupcount_y β€” number of local workgroups to dispatch in the Y dimension. the vertical girly ✨
  • groupcount_z β€” number of local workgroups to dispatch in the Z dimension. the depth girly, the one who goes into the screen 🌈

all three are Uint32, so keep it positive and keep it whole, bestie πŸ“


⭐ AVAILABILITY ⭐

she's been around since SDL 3.2.0 β€” so if you're on anything older than that, this function simply does not exist for you, sorry bestie 😭


and that's the whole page!! stay hydrated, bind your pipeline, and don't dispatch twice into the same region unless you're ready for the consequences πŸ™ˆ

cute little sign-off: this page comes from Simple Directmedia Layer, documented as of version SDL 3.4.18, and it's the SDL_DispatchGPUCompute(3) page β€” love her, obsessed with her, periodt πŸ‘‘πŸ’–βœ¨
πŸ“¦ where this page comes from