SDL_PUSHGPUCOMPUTEUNIFORMDATA(3)

πŸ’– SDL_PushGPUComputeUniformData(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_PushGPUComputeUniformData 🫢


✨ NAME ✨

SDL_PushGPUComputeUniformData β€” pushes data to a uniform slot on the command buffer. that's it, that's the job, and she does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gpu.h>

void SDL_PushGPUComputeUniformData(
    SDL_GPUCommandBuffer *command_buffer,
    Uint32 slot_index,
    const void *data,
    Uint32 length);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: subsequent draw calls in this command buffer will use this uniform data. like, once you push it, it's locked in for everything that comes after in that command buffer. no cap. ✨

now the important part, and I need you to actually read this one bestie, not just skim it like the group chat: the data being pushed must respect std140 layout conventions. in practical terms this means you must ensure that vec3 and vec4 fields are 16-byte aligned. yes, for real. if you don't, the vibes will be off and the GPU will simply not understand you. it's giving misaligned struct, and not in a cute way 😭


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • command_buffer β€” a command buffer. your little vessel of compute destiny πŸš€
  • slot_index β€” the uniform slot to push data to. pick your slot, queen πŸ‘‘
  • data β€” client data to write. the actual payload, the substance, the content πŸ’–
  • length β€” the length of the data to write. how much of the data you're sending. be precise, fr fr πŸ“

⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on anything older, sorry babe, she's not there yet πŸ™ˆ


heads up bestie: the std140 + 16-byte alignment thing for vec3 and vec4 is not a suggestion, it's the rules. respect the layout or respect the consequences πŸ’€

and that's the whole page, you ate it, you understood it, you're iconic 🌈

Simple Directmedia Layer made this, this doc is for SDL 3.4.18, and the page is literally just SDL_PushGPUComputeUniformData(3) β€” so go push some uniform data and slay πŸ’…βœ¨πŸ¦‹πŸŽ€πŸ’–

πŸ“¦ where this page comes from