# SDL_GPUCommandBuffer

A command buffer that accumulates rendering, copy, and compute operations. Freed after submission or GC.


### render_pass(passDesc) <sub>function</sub>

Begin a render pass with color/depth attachments. Provide an object with
'color_targets' and optional 'depth_stencil'. Returns an SDL_GPURenderPass handle.



**passDesc**: {color_targets:[...], depth_stencil:...}


**Returns**: SDL_GPURenderPass


### compute_pass(storageTextures, storageBuffers) <sub>function</sub>

Begin a compute pass reading/writing given arrays of textures and buffers.



**storageTextures**: array of read/write textures

**storageBuffers**: array of read/write buffers


**Returns**: SDL_GPUComputePass


### swapchain_pass(clearColor) <sub>function</sub>

Begin a render pass that directly targets the swapchain (the window). Clears
with the specified color.



**clearColor**: [r,g,b,a]


**Returns**: SDL_GPURenderPass


### acquire_swapchain() <sub>function</sub>

Acquire the current swapchain texture from the window. Internal usage.



**Returns**: SDL_GPUTexture handle


### bind_vertex_buffer(slot, buffer) <sub>function</sub>

Bind a GPU buffer as the vertex buffer at a given slot.



**slot**: Integer slot index.

**buffer**: The SDL_GPUBuffer.


**Returns**: None


### bind_index_buffer(buffer, offset) <sub>function</sub>

Bind a GPU buffer as the index buffer (16-bit or 32-bit).



**buffer**: The SDL_GPUBuffer.

**offset**: Optional offset in bytes.


**Returns**: None


### bind_fragment_sampler(slot, texture, sampler) <sub>function</sub>

Bind a texture+sampler pair to a particular fragment shader slot.



**slot**: Index of the sampler binding.

**texture**: The SDL_GPUTexture

**sampler**: The SDL_GPUSampler


**Returns**: None


### push_vertex_uniform_data(slot, data) <sub>function</sub>

Push raw data to a vertex shader uniform block.



**slot**: The uniform buffer slot.

**data**: An ArrayBuffer with the data to upload.


**Returns**: None


### push_fragment_uniform_data(slot, data) <sub>function</sub>

Push raw data to a fragment shader uniform block.



**slot**: The uniform buffer slot index.

**data**: An ArrayBuffer with uniform data.


**Returns**: None


### push_compute_uniform_data(slot, data) <sub>function</sub>

Push raw data to a compute shader uniform buffer.



**slot**: The uniform buffer slot.

**data**: An ArrayBuffer with the data.


**Returns**: None


### submit() <sub>function</sub>

Submit this command buffer to the GPU and return a fence for synchronization.



**Returns**: An SDL_GPUFence


### cancel() <sub>function</sub>

Cancel (discard) this command buffer without submitting.



**Returns**: None


### camera(cameraTransform, uniformSlot) <sub>function</sub>

Write a camera transform (projection/view) to a uniform slot for 3D or 2D usage.



**cameraTransform**: A camera object or transform with .pos, fov, etc.

**uniformSlot**: The integer uniform buffer slot to which data is pushed.


**Returns**: None


### hud(sizeVec2, uniformSlot) <sub>function</sub>

Write an orthographic full-screen "HUD" matrix to a uniform slot. Typically used
for 2D overlays.



**sizeVec2**: [width, height] of the viewport area.

**uniformSlot**: The integer uniform buffer slot.


**Returns**: None


### push_debug_group(name) <sub>function</sub>

Push a named debug group marker onto the GPU command list (for debuggers/profilers).



**name**: The debug label string.


**Returns**: None


### pop_debug_group() <sub>function</sub>

Pop the most recent debug group marker.



**Returns**: None


### debug_label(label) <sub>function</sub>

Insert a one-off debug label at the current spot in the command list.



**label**: The debug label string


**Returns**: None


### blit(blitDesc) <sub>function</sub>

Blit one GPU texture to another with optional flip mode, filter, and clear operations.



**blitDesc**: { src:{texture,mip_level, etc}, dst:{texture,...}, load_op, flip, filter, clear_color:[r,g,b,a] }


**Returns**: None

