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

A scoped copy pass for uploading CPU data and copying GPU resources. More...

#include <CopyPass.h>

Inheritance diagram for CopyPass:

Public Member Functions

void copyBufferToBuffer (const CopyPass *self, const SDL_GPUBufferLocation *src, const SDL_GPUBufferLocation *dst, Uint32 size, bool cycle)
 Copies a region of one GPU buffer to another.
 
void copyTextureToTexture (const CopyPass *self, const SDL_GPUTextureLocation *src, const SDL_GPUTextureLocation *dst, Uint32 w, Uint32 h, Uint32 d, bool cycle)
 Copies a region of one GPU texture to another.
 
void downloadBuffer (const CopyPass *self, const SDL_GPUBufferRegion *src, const SDL_GPUTransferBufferLocation *dst)
 Downloads a GPU buffer region to a CPU-accessible transfer buffer.
 
void downloadTexture (const CopyPass *self, const SDL_GPUTextureRegion *src, const SDL_GPUTextureTransferInfo *dst)
 Downloads a GPU texture region to a CPU-accessible transfer buffer.
 
void downloadQueryResults (const CopyPass *self, QueryPool *pool, Uint32 firstQuery, Uint32 count, const SDL_GPUTransferBufferLocation *dst)
 Downloads a range of query results to a CPU-accessible transfer buffer.
 
CopyPassinit (CopyPass *self, CommandBuffer *commands, SDL_GPUCopyPass *pass)
 Initializes this CopyPass wrapping the given SDL copy pass.
 
void uploadBuffer (const CopyPass *self, const SDL_GPUTransferBufferLocation *src, const SDL_GPUBufferRegion *dst, bool cycle)
 Uploads data from a CPU transfer buffer to a GPU buffer.
 
void uploadData (const CopyPass *self, SDL_GPUBuffer *dst, const void *data, Uint32 size, Uint32 offset, bool cycle)
 Uploads raw CPU data to a GPU buffer, managing the transfer buffer internally.
 
void uploadTexture (const CopyPass *self, const SDL_GPUTextureTransferInfo *src, const SDL_GPUTextureRegion *dst, bool cycle)
 Uploads data from a CPU transfer buffer to a GPU texture.
 
Class * _CopyPass (void)
 The CopyPass archetype.
 

Data Fields

Object object
 The superclass.
 
ident data
 User data.
 

Protected Attributes

CopyPassInterface * interface
 The interface.
 

Detailed Description

A scoped copy pass for uploading CPU data and copying GPU resources.

Obtain a CopyPass from CommandBuffer::beginCopyPass. When all transfers are complete, release the pass — dealloc calls SDL_EndGPUCopyPass automatically so no explicit end is required:

CopyPass *copy = $(commands, beginCopyPass);
$(copy, uploadBuffer, &src, &dst, false);
release(copy); // ends the pass
static CopyPass * beginCopyPass(CommandBuffer *self)
Definition CommandBuffer.c:96
A scoped copy pass for uploading CPU data and copying GPU resources.
Definition CopyPass.h:55
void uploadBuffer(const CopyPass *self, const SDL_GPUTransferBufferLocation *src, const SDL_GPUBufferRegion *dst, bool cycle)
Uploads data from a CPU transfer buffer to a GPU buffer.
Definition CopyPass.c:136

Member Function Documentation

◆ _CopyPass()

Class * _CopyPass ( void  )

The CopyPass archetype.

Returns
The CopyPass Class.

◆ copyBufferToBuffer()

void copyBufferToBuffer ( const CopyPass self,
const SDL_GPUBufferLocation *  src,
const SDL_GPUBufferLocation *  dst,
Uint32  size,
bool  cycle 
)

Copies a region of one GPU buffer to another.

◆ copyTextureToTexture()

void copyTextureToTexture ( const CopyPass self,
const SDL_GPUTextureLocation *  src,
const SDL_GPUTextureLocation *  dst,
Uint32  w,
Uint32  h,
Uint32  d,
bool  cycle 
)

Copies a region of one GPU texture to another.

◆ downloadBuffer()

void downloadBuffer ( const CopyPass self,
const SDL_GPUBufferRegion *  src,
const SDL_GPUTransferBufferLocation *  dst 
)

Downloads a GPU buffer region to a CPU-accessible transfer buffer.

◆ downloadQueryResults()

void downloadQueryResults ( const CopyPass self,
QueryPool pool,
Uint32  firstQuery,
Uint32  count,
const SDL_GPUTransferBufferLocation *  dst 
)

Downloads a range of query results to a CPU-accessible transfer buffer.

Each result is a Uint64, laid out contiguously starting at dst. When pool is backed by an unsupported SDL3 build, every result is reported as "not occluded" (nonzero) rather than left uninitialized; see QueryPool.

◆ downloadTexture()

void downloadTexture ( const CopyPass self,
const SDL_GPUTextureRegion *  src,
const SDL_GPUTextureTransferInfo *  dst 
)

Downloads a GPU texture region to a CPU-accessible transfer buffer.

◆ init()

CopyPass * init ( CopyPass self,
CommandBuffer commands,
SDL_GPUCopyPass *  pass 
)

Initializes this CopyPass wrapping the given SDL copy pass.

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

◆ uploadBuffer()

void uploadBuffer ( const CopyPass self,
const SDL_GPUTransferBufferLocation *  src,
const SDL_GPUBufferRegion *  dst,
bool  cycle 
)

Uploads data from a CPU transfer buffer to a GPU buffer.

Parameters
selfThe CopyPass.
srcSource location in the CPU-side transfer buffer.
dstDestination region in the GPU buffer.
cycleWhen true, the GPU buffer is cycled to avoid pipeline stalls.

◆ uploadData()

void uploadData ( const CopyPass self,
SDL_GPUBuffer *  dst,
const void *  data,
Uint32  size,
Uint32  offset,
bool  cycle 
)

Uploads raw CPU data to a GPU buffer, managing the transfer buffer internally.

Allocates a temporary transfer buffer, copies data into it, records the upload, and releases the transfer buffer — all within this call. Use this to batch multiple buffer uploads into a single copy pass without manual transfer buffer management.

Parameters
selfThe CopyPass.
dstThe GPU buffer to upload into.
dataCPU pointer to the source data.
sizeNumber of bytes to upload.
offsetByte offset into dst where the data is written.
cycleWhen true, the GPU buffer is cycled to avoid pipeline stalls.

◆ uploadTexture()

void uploadTexture ( const CopyPass self,
const SDL_GPUTextureTransferInfo *  src,
const SDL_GPUTextureRegion *  dst,
bool  cycle 
)

Uploads data from a CPU transfer buffer to a GPU texture.

Parameters
selfThe CopyPass.
srcSource transfer info describing the CPU-side data layout.
dstDestination region in the GPU texture.
cycleWhen true, the GPU texture is cycled to avoid pipeline stalls.

Field Documentation

◆ data

ident CopyPass::data

User data.

◆ interface

CopyPassInterface* CopyPass::interface
protected

The interface.

◆ object

Object CopyPass::object

The superclass.


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