GPU: device & frameSDL 3.2

SDL_AcquireGPUCommandBuffer

Gets a command buffer: a list you record GPU work into, then submit all at once.

Signature

SDL_GPUCommandBuffer * SDL_AcquireGPUCommandBuffer(SDL_GPUDevice *device);

How it works

Modern GPU APIs do not run each call immediately. You RECORD commands (copy this, draw that) into a command buffer, then SUBMIT the whole buffer; the GPU works through it while your CPU moves on to the next frame.

The usual frame acquires one command buffer, records the passes, and submits it. Use it only on the thread that acquired it, and always submit it (or cancel it with SDL_CancelGPUCommandBuffer). You never free it yourself.

Parameters

deviceSDL_GPUDevice *

The device.

Return value

A command buffer, or NULL on failure.

Example

example.cpp
1SDL_GPUCommandBuffer* cmd = SDL_AcquireGPUCommandBuffer(device);
2// ... record copy passes and render passes ...
3SDL_SubmitGPUCommandBuffer(cmd);
Official SDL wiki