SDL_BeginGPUComputePass(3)

โœจ SDL_BeginGPUComputePass โœจ

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're gonna talk about SDL_BeginGPUComputePass โ€” the girl whose whole job is starting a compute pass on a command buffer. she's the opening act. the main character energy is real. ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

SDL_BeginGPUComputePass โ€” begins a compute pass on a command buffer. no cap, that's literally it. ๐ŸŽ€


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <SDL3/SDL_gpu.h>

SDL_GPUComputePass * SDL_BeginGPUComputePass(
    SDL_GPUCommandBuffer *command_buffer,
    const SDL_GPUStorageTextureReadWriteBinding *storage_texture_bindings,
    Uint32 num_storage_texture_bindings,
    const SDL_GPUStorageBufferReadWriteBinding *storage_buffer_bindings,
    Uint32 num_storage_buffer_bindings);

look at her. five parameters. iconic. ๐Ÿซถ


๐Ÿ’– DESCRIPTION ๐Ÿ’–

so a compute pass is defined by a set of texture subresources and buffers that compute pipelines are allowed to write to. and these textures and buffers? they must have been created with the COMPUTE_STORAGE_WRITE bit or the COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE bit. no bit, no entry. ๐Ÿšซ

and here's the thing: if you do not create a texture with COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE, then you must not read from that texture inside the compute pass. like, at all. periodt.

every single operation related to compute pipelines has to happen inside a compute pass. that's the whole vibe. and you must not begin another compute pass, or a render pass, or a copy pass before ending the compute pass. one at a time, bestie, we are not multitasking here. ๐Ÿ˜ญ

๐Ÿšจ A VERY IMPORTANT NOTE ๐Ÿšจ โ€” Reads and writes in compute passes are NOT implicitly synchronized. ngl this is the scary part. this means you may cause data races by both reading and writing a resource region in a compute pass, or by writing multiple times to a resource region. ๐Ÿ˜ฑ if your compute work depends on reading the completed output from a previous dispatch, you MUST end the current compute pass and begin a new one before you can safely access the data. otherwise you will receive unexpected results. fr fr, don't skip this step. ๐Ÿ’€

also: reading and writing a texture in the same compute pass is only supported by specific texture formats. make sure you check the format support! ๐Ÿ”


๐ŸŽ€ FUNCTION PARAMETERS ๐ŸŽ€

  • command_buffer โ€” a command buffer. that's it, that's the whole description. she's lowkey mysterious like that. โœจ
  • storage_texture_bindings โ€” an array of writeable storage texture binding structs. ๐ŸŒธ
  • num_storage_texture_bindings โ€” the number of storage textures to bind from the array. count 'em. ๐Ÿงฎ
  • storage_buffer_bindings โ€” an array of writeable storage buffer binding structs. ๐Ÿ’œ
  • num_storage_buffer_bindings โ€” the number of storage buffers to bind from the array. again: count 'em. ๐Ÿงฎ

๐Ÿ‘‘ RETURN VALUE ๐Ÿ‘‘

Returns a compute pass handle. slay. ๐Ÿซถ


๐ŸŒˆ AVAILABILITY ๐ŸŒˆ

This function is available since SDL 3.2.0. she's not new new, she's established. ๐Ÿ’…


โญ SEE ALSO โญ

  • SDL_EndGPUComputePass(3) โ€” the other half of the story. you will be calling her, bestie. no skipping the ending. ๐ŸŽฌ

and that's the whole page!! go forth and synchronize your reads and writes properly, i'm begging you. ๐Ÿ™ˆ๐Ÿ’–

โ€” with love from the Simple Directmedia Layer girlies, SDL 3.4.18 edition** ๐ŸŽ€โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from