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

An SDL_GPUFence, signaled once a submitted CommandBuffer's GPU work completes. More...

#include <Fence.h>

Inheritance diagram for Fence:

Public Member Functions

FenceinitWithDevice (Fence *self, RenderDevice *device, SDL_GPUFence *fence)
 Initializes this Fence, wrapping an SDL_GPUFence returned by CommandBuffer::submitAndFence.
 
bool query (const Fence *self)
 Non-blocking query of whether this fence has been signaled.
 
bool wait (const Fence *self)
 Blocks the calling thread until this fence is signaled.
 
Class * _Fence (void)
 The Fence archetype.
 

Data Fields

Object object
 The superclass.
 
SDL_GPUFence * fence
 The underlying SDL fence.
 

Protected Attributes

FenceInterface * interface
 The interface.
 

Detailed Description

An SDL_GPUFence, signaled once a submitted CommandBuffer's GPU work completes.

Fence owns its underlying SDL_GPUFence and releases it in dealloc, so a Fence is freed with release like any other Objectively object – e.g. by storing pending fences in an Array, which releases each element automatically as it's removed:

Fence *fence = $(commands, submitAndFence);
$(pending, addObject, fence);
release(fence);
...
if ($((Fence *) $(pending, objectAtIndex, 0), query)) {
$(pending, removeObjectAtIndex, 0); // releases the Fence
}
static Fence * submitAndFence(CommandBuffer *self)
Definition CommandBuffer.c:258
An SDL_GPUFence, signaled once a submitted CommandBuffer's GPU work completes.
Definition Fence.h:55
bool query(const Fence *self)
Non-blocking query of whether this fence has been signaled.
Definition Fence.c:74
SDL_GPUFence * fence
The underlying SDL fence.
Definition Fence.h:71

Member Function Documentation

◆ _Fence()

Class * _Fence ( void  )

The Fence archetype.

Returns
The Fence Class.

◆ initWithDevice()

Fence * initWithDevice ( Fence self,
RenderDevice device,
SDL_GPUFence *  fence 
)

Initializes this Fence, wrapping an SDL_GPUFence returned by CommandBuffer::submitAndFence.

This is the designated initializer.

Parameters
selfThe Fence.
deviceThe RenderDevice used to query, wait on, and release the fence. Retained.
fenceThe SDL_GPUFence to wrap. Owned by the returned Fence.
Returns
The initialized Fence, or NULL on error.

◆ query()

bool query ( const Fence self)

Non-blocking query of whether this fence has been signaled.

Parameters
selfThe Fence.
Returns
true if signaled (the GPU work it guards has completed); false otherwise.

◆ wait()

bool wait ( const Fence self)

Blocks the calling thread until this fence is signaled.

Parameters
selfThe Fence.
Returns
true on success, false on error.

Field Documentation

◆ fence

SDL_GPUFence* Fence::fence

The underlying SDL fence.

◆ interface

FenceInterface* Fence::interface
protected

The interface.

◆ object

Object Fence::object

The superclass.


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