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
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms