ObjectivelyGPU
Object oriented graphics framework for SDL3 and C
Loading...
Searching...
No Matches
ComputePass Struct Reference

A scoped compute pass for recording GPU compute dispatches. More...

#include <ComputePass.h>

Inheritance diagram for ComputePass:

Public Member Functions

void bindPipeline (ComputePass *self, ComputePipeline *pipeline)
 Binds a compute pipeline for subsequent dispatches.
 
void bindSamplers (const ComputePass *self, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *bindings, Uint32 num)
 Binds texture-sampler pairs for the compute stage.
 
void bindStorageBuffers (const ComputePass *self, Uint32 firstSlot, SDL_GPUBuffer *const *buffers, Uint32 num)
 Binds read-only storage buffers for the compute stage.
 
void bindStorageTextures (const ComputePass *self, Uint32 firstSlot, SDL_GPUTexture *const *textures, Uint32 num)
 Binds read-only storage textures for the compute stage.
 
void dispatchCompute (const ComputePass *self, Uint32 groupCountX, Uint32 groupCountY, Uint32 groupCountZ)
 Dispatches a compute workload.
 
void dispatchComputeIndirect (const ComputePass *self, SDL_GPUBuffer *buffer, Uint32 offset)
 Dispatches a compute workload with parameters sourced from a GPU buffer.
 
ComputePassinit (ComputePass *self, CommandBuffer *commands, SDL_GPUComputePass *pass)
 Initializes this ComputePass wrapping the given SDL compute pass.
 
Class * _ComputePass (void)
 The ComputePass archetype.
 

Data Fields

Object object
 The superclass.
 
ComputePipelinepipeline
 The currently bound pipeline, or NULL.
 
ident data
 User data.
 

Protected Attributes

ComputePassInterface * interface
 The interface.
 

Detailed Description

A scoped compute pass for recording GPU compute dispatches.

Obtain a ComputePass from CommandBuffer::beginComputePass. When all dispatches have been recorded, release the pass — dealloc calls SDL_EndGPUComputePass automatically so no explicit end is required:

ComputePass *compute = $(commands, beginComputePass, NULL, 0, storageBuffers, 1);
$(compute, bindPipeline, pipeline);
$(compute, dispatchCompute, groupsX, groupsY, 1);
release(compute); // ends the pass
static ComputePass * beginComputePass(CommandBuffer *self, const SDL_GPUStorageTextureReadWriteBinding *storageTextures, Uint32 numStorageTextures, const SDL_GPUStorageBufferReadWriteBinding *storageBuffers, Uint32 numStorageBuffers)
Definition CommandBuffer.c:78
A scoped compute pass for recording GPU compute dispatches.
Definition ComputePass.h:56
ComputePipeline * pipeline
The currently bound pipeline, or NULL.
Definition ComputePass.h:85
void dispatchCompute(const ComputePass *self, Uint32 groupCountX, Uint32 groupCountY, Uint32 groupCountZ)
Dispatches a compute workload.
Definition ComputePass.c:94
void bindPipeline(ComputePass *self, ComputePipeline *pipeline)
Binds a compute pipeline for subsequent dispatches.
Definition ComputePass.c:57

Member Function Documentation

◆ _ComputePass()

Class * _ComputePass ( void  )

The ComputePass archetype.

Returns
The ComputePass Class.

◆ bindPipeline()

void bindPipeline ( ComputePass self,
ComputePipeline pipeline 
)

Binds a compute pipeline for subsequent dispatches.

◆ bindSamplers()

void bindSamplers ( const ComputePass self,
Uint32  firstSlot,
const SDL_GPUTextureSamplerBinding *  bindings,
Uint32  num 
)

Binds texture-sampler pairs for the compute stage.

◆ bindStorageBuffers()

void bindStorageBuffers ( const ComputePass self,
Uint32  firstSlot,
SDL_GPUBuffer *const *  buffers,
Uint32  num 
)

Binds read-only storage buffers for the compute stage.

◆ bindStorageTextures()

void bindStorageTextures ( const ComputePass self,
Uint32  firstSlot,
SDL_GPUTexture *const *  textures,
Uint32  num 
)

Binds read-only storage textures for the compute stage.

◆ dispatchCompute()

void dispatchCompute ( const ComputePass self,
Uint32  groupCountX,
Uint32  groupCountY,
Uint32  groupCountZ 
)

Dispatches a compute workload.

Parameters
selfThe ComputePass.
groupCountXNumber of workgroups in the X dimension.
groupCountYNumber of workgroups in the Y dimension.
groupCountZNumber of workgroups in the Z dimension.

◆ dispatchComputeIndirect()

void dispatchComputeIndirect ( const ComputePass self,
SDL_GPUBuffer *  buffer,
Uint32  offset 
)

Dispatches a compute workload with parameters sourced from a GPU buffer.

◆ init()

ComputePass * init ( ComputePass self,
CommandBuffer commands,
SDL_GPUComputePass *  pass 
)

Initializes this ComputePass wrapping the given SDL compute pass.

Parameters
selfThe ComputePass.
commandsThe CommandBuffer that created this pass.
passThe SDL compute pass to wrap. Must not be NULL.
Returns
The initialized ComputePass, or NULL on failure.

Field Documentation

◆ data

ident ComputePass::data

User data.

◆ interface

ComputePassInterface* ComputePass::interface
protected

The interface.

◆ object

Object ComputePass::object

The superclass.

◆ pipeline

ComputePipeline* ComputePass::pipeline

The currently bound pipeline, or NULL.


The documentation for this struct was generated from the following files: