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

The RenderDevice encapsulates an SDL_GPUDevice and provides methods for allocating GPU resources, managing compute, copy and render passes, and . More...

#include <RenderDevice.h>

Inheritance diagram for RenderDevice:

Public Member Functions

CommandBufferacquireCommandBuffer (const RenderDevice *self)
 Acquires a new CommandBuffer for recording GPU commands this frame.
 
CommandBufferbeginFrame (RenderDevice *self)
 Begins a frame: acquires a command buffer and the swapchain, and prepares the framebuffer.
 
FenceendFrameAndFence (RenderDevice *self)
 Ends the frame begun by beginFrame, as endFrame, but returns a Fence.
 
void endFrame (RenderDevice *self)
 Ends the frame begun by beginFrame: presents the framebuffer and submits.
 
BuffercreateBuffer (RenderDevice *self, const SDL_GPUBufferCreateInfo *info)
 Creates a Buffer (vertex, index, indirect, storage, etc.).
 
BuffercreateBufferWithConstMem (RenderDevice *self, SDL_GPUBufferUsageFlags usage, const void *mem, Uint32 size)
 Creates a Buffer and uploads mem in a single call.
 
BuffercreateBufferWithData (RenderDevice *self, SDL_GPUBufferUsageFlags usage, const Data *data)
 Creates a Buffer and uploads the contents of an Objectively Data object.
 
ComputePipelinecreateComputePipeline (RenderDevice *self, const SDL_GPUComputePipelineCreateInfo *info)
 Creates a ComputePipeline from a compiled compute shader.
 
FramebuffercreateFramebuffer (RenderDevice *self, const GPU_FramebufferCreateInfo *info)
 Creates a Framebuffer aggregating color/depth attachments (and an MSAA resolve target).
 
GraphicsPipelinecreateGraphicsPipeline (RenderDevice *self, const SDL_GPUGraphicsPipelineCreateInfo *info)
 Creates a GraphicsPipeline from vertex and fragment shaders plus render state.
 
QueryPoolcreateQueryPool (RenderDevice *self, const SDL_GPUQueryPoolCreateInfo *info)
 Creates a QueryPool for occlusion or timestamp queries.
 
SamplercreateSampler (RenderDevice *self, const SDL_GPUSamplerCreateInfo *info)
 Creates a Sampler describing filter and address modes.
 
SamplercreateSamplerLinearRepeat (RenderDevice *self)
 Creates a trilinear, wrapping Sampler – the common preset for tiled surface textures.
 
SamplercreateSamplerLinearClamp (RenderDevice *self)
 Creates a trilinear, edge-clamped Sampler – the common preset for continuously-sampled volumes and non-tiling images (ambient/voxel volumes, cubemaps, post-process targets, UI images).
 
SamplercreateSamplerNearestClamp (RenderDevice *self)
 Creates a point-filtered, edge-clamped Sampler – the common preset for data textures fetched by integer coordinate (voxel light data, depth-attachment copies) rather than sampled for appearance.
 
SamplercreateSamplerShadowCompare (RenderDevice *self)
 Creates a hardware-PCF comparison Sampler for shadow map sampling.
 
ShadercreateShader (RenderDevice *self, const SDL_GPUShaderCreateInfo *info)
 Creates a Shader from a fully-filled SDL_GPUShaderCreateInfo.
 
TexturecreateTexture (RenderDevice *self, const SDL_GPUTextureCreateInfo *info, const void *pixels)
 Creates a Texture, optionally uploading initial pixel data.
 
TransferBuffercreateTransferBuffer (RenderDevice *self, const SDL_GPUTransferBufferCreateInfo *info)
 Creates a CPU-accessible transfer buffer for staging data to or from the GPU.
 
TexturecreateTextureFromSurface (RenderDevice *self, SDL_Surface *surface, SDL_GPUTextureUsageFlags usage, bool generateMipmaps)
 Creates a Texture from an SDL_Surface, uploading pixel data immediately.
 
TexturecreateSolidColorTexture (RenderDevice *self, SDL_GPUTextureType type, Uint32 layerCount, Uint32 rgba)
 Creates a small, solid-color Texture – the common "placeholder" pattern for a sampler slot a shader declares but a given draw never actually reads.
 
SDL_GPUTextureFormat getSwapchainTextureFormat (const RenderDevice *self)
 Returns the pixel format of this device's swapchain.
 
RenderDeviceinit (RenderDevice *self)
 Initialises a RenderDevice, creating an SDL_GPUDevice with no window claimed.
 
RenderDeviceinitWithWindow (RenderDevice *self, SDL_Window *window)
 Initialises a RenderDevice and immediately claims window for rendering.
 
ShaderloadShader (RenderDevice *self, const char *name, const SDL_GPUShaderCreateInfo *info)
 Loads a shader blob via the Resource system and creates a Shader.
 
ComputePipelineloadComputePipeline (RenderDevice *self, const char *name, const SDL_GPUComputePipelineCreateInfo *info)
 Loads a compiled compute shader blob via the Resource system and creates a ComputePipeline.
 
GraphicsPipelineloadGraphicsPipeline (RenderDevice *self, const char *vertexShaderName, const SDL_GPUShaderCreateInfo *vertexShaderInfo, const char *fragmentShaderName, const SDL_GPUShaderCreateInfo *fragmentShaderInfo, SDL_GPUGraphicsPipelineCreateInfo *info)
 Loads a vertex/fragment shader pair and creates a GraphicsPipeline from them.
 
bool setAllowedFramesInFlight (const RenderDevice *self, Uint32 allowed)
 Sets the maximum number of GPU frames that may be in flight concurrently.
 
void setFramebuffer (RenderDevice *self, Framebuffer *framebuffer)
 Sets the present-target Framebuffer driven by beginFrame/endFrame.
 
bool setSwapchainParameters (const RenderDevice *self, SDL_Window *window, SDL_GPUSwapchainComposition composition, SDL_GPUPresentMode mode)
 
void setWindow (RenderDevice *self, SDL_Window *window)
 Claims window for this device, releasing any previously claimed window.
 
bool supportsPresentMode (const RenderDevice *self, SDL_GPUPresentMode mode)
 Queries whether this device's swapchain supports the given present mode.
 
bool supportsSwapchainComposition (const RenderDevice *self, SDL_GPUSwapchainComposition composition)
 Queries whether this device's swapchain supports the given composition (colour space / HDR mode).
 
bool textureSupportsFormat (const RenderDevice *self, SDL_GPUTextureFormat format, SDL_GPUTextureType type, SDL_GPUTextureUsageFlags usage)
 Queries whether a texture format is supported for a given type and usage.
 
bool textureSupportsSampleCount (const RenderDevice *self, SDL_GPUTextureFormat format, SDL_GPUSampleCount sample_count)
 Queries whether a texture format supports a given MSAA sample count.
 
bool waitForIdle (const RenderDevice *self)
 Blocks until the GPU has finished all submitted work.
 
bool waitForSwapchain (const RenderDevice *self)
 Blocks until this device's swapchain is available for the next frame.
 
Class * _RenderDevice (void)
 The RenderDevice archetype.
 
bool setSwapchainParameters (const RenderDevice *self, SDL_GPUSwapchainComposition composition, SDL_GPUPresentMode mode)
 Configures swapchain composition and present mode for this device's window.
 

Data Fields

Object object
 The superclass.
 
SDL_GPUDevice * device
 The SDL_GPUDevice.
 
SDL_Window * window
 The SDL_Window associated with device.
 
SDL_GPUShaderFormat shaderFormats
 
float maxAnisotropy
 The anisotropic filtering level applied by createSamplerLinearRepeat and createSamplerLinearClamp. Defaults to 0 (anisotropic filtering disabled). Assign directly; only affects Samplers created afterward, since SDL_gpu Samplers are immutable once created.
 
Framebufferframebuffer
 The present-target Framebuffer driven by beginFrame/endFrame, or NULL.
 
ident data
 User data.
 

Protected Attributes

RenderDeviceInterface * interface
 The interface.
 

Detailed Description

The RenderDevice encapsulates an SDL_GPUDevice and provides methods for allocating GPU resources, managing compute, copy and render passes, and .

Member Function Documentation

◆ _RenderDevice()

Class * _RenderDevice ( void  )

The RenderDevice archetype.

Returns
The RenderDevice Class.

◆ acquireCommandBuffer()

CommandBuffer * acquireCommandBuffer ( const RenderDevice self)

Acquires a new CommandBuffer for recording GPU commands this frame.

Wraps SDL_AcquireGPUCommandBuffer. The returned CommandBuffer is owned by the caller and must be submitted via submit or submitAndFence and then released with release.

Parameters
selfThe RenderDevice.
Returns
A new, retained CommandBuffer. GPU_Asserts on failure.

◆ beginFrame()

CommandBuffer * beginFrame ( RenderDevice self)

Begins a frame: acquires a command buffer and the swapchain, and prepares the framebuffer.

Convenience over the manual acquire→wait-swapchain→resize boilerplate. Acquires a CommandBuffer, blocks for the swapchain texture, resizes the framebuffer set via setFramebuffer to the swapchain dimensions, and returns the command buffer so the caller can record passes into framebuffer. Returns NULL when the swapchain is unavailable (e.g. the window is minimised); the command buffer is cancelled and the frame should be skipped. Pair every non-NULL return with endFrame. The returned CommandBuffer is owned by the device; do not release it. Applications that render directly to the swapchain can ignore beginFrame/endFrame and drive the command buffer themselves.

Parameters
selfThe RenderDevice.
Returns
The frame's CommandBuffer (borrowed), or NULL to skip the frame.

◆ createBuffer()

Buffer * createBuffer ( RenderDevice self,
const SDL_GPUBufferCreateInfo *  info 
)

Creates a Buffer (vertex, index, indirect, storage, etc.).

Convenience factory for Buffer::initWithDevice. The buffer's contents are uninitialised; use Buffer::upload to populate it.

Parameters
selfThe RenderDevice.
infoBuffer creation parameters (usage flags, size).
Returns
A new, retained Buffer. GPU_Asserts on failure. Free with release.

◆ createBufferWithConstMem()

Buffer * createBufferWithConstMem ( RenderDevice self,
SDL_GPUBufferUsageFlags  usage,
const void *  mem,
Uint32  size 
)

Creates a Buffer and uploads mem in a single call.

Convenience factory for Buffer::initWithConstMem. The returned buffer is immediately GPU-resident.

Parameters
selfThe RenderDevice.
usageBuffer usage flags (e.g. SDL_GPU_BUFFERUSAGE_VERTEX).
memCPU pointer to the source data. Must not be NULL.
sizeNumber of bytes to allocate and upload.
Returns
A new, retained Buffer populated with mem. GPU_Asserts on failure. Free with release.

◆ createBufferWithData()

Buffer * createBufferWithData ( RenderDevice self,
SDL_GPUBufferUsageFlags  usage,
const Data *  data 
)

Creates a Buffer and uploads the contents of an Objectively Data object.

Convenience factory for Buffer::initWithData, for data loaded via the Objectively Resource system.

Parameters
selfThe RenderDevice.
usageBuffer usage flags (e.g. SDL_GPU_BUFFERUSAGE_VERTEX).
dataSource data object. Must not be NULL.
Returns
A new, retained Buffer populated with data. GPU_Asserts on failure. Free with release.

◆ createComputePipeline()

ComputePipeline * createComputePipeline ( RenderDevice self,
const SDL_GPUComputePipelineCreateInfo *  info 
)

Creates a ComputePipeline from a compiled compute shader.

Convenience factory for ComputePipeline::initWithDevice. Prefer loadComputePipeline to load a compiled blob from the Resource system.

Parameters
selfThe RenderDevice.
infoCompute pipeline creation parameters, including the shader.
Returns
A new, retained ComputePipeline. GPU_Asserts on failure. Free with release.

◆ createFramebuffer()

Framebuffer * createFramebuffer ( RenderDevice self,
const GPU_FramebufferCreateInfo info 
)

Creates a Framebuffer aggregating color/depth attachments (and an MSAA resolve target).

Convenience factory for Framebuffer::initWithDevice. Pair with setFramebuffer to drive it via beginFrame/endFrame.

Parameters
selfThe RenderDevice.
infoFramebuffer creation parameters (size, formats, sample count).
Returns
A new, retained Framebuffer. GPU_Asserts on failure. Free with release.

◆ createGraphicsPipeline()

GraphicsPipeline * createGraphicsPipeline ( RenderDevice self,
const SDL_GPUGraphicsPipelineCreateInfo *  info 
)

Creates a GraphicsPipeline from vertex and fragment shaders plus render state.

Convenience factory for GraphicsPipeline::initWithDevice.

Parameters
selfThe RenderDevice.
infoGraphics pipeline creation parameters (shaders, vertex layout, blend state, rasteriser state, depth/stencil state, colour target formats).
Returns
A new, retained GraphicsPipeline. GPU_Asserts on failure. Free with release.

◆ createQueryPool()

QueryPool * createQueryPool ( RenderDevice self,
const SDL_GPUQueryPoolCreateInfo info 
)

Creates a QueryPool for occlusion or timestamp queries.

Convenience factory for QueryPool::initWithDevice. Always succeeds, even when occlusion queries are unsupported by the linked SDL3 – see QueryPool.

Parameters
selfThe RenderDevice.
infoQuery pool creation parameters (query type, query count).
Returns
A new, retained QueryPool. GPU_Asserts on failure. Free with release.

◆ createSampler()

Sampler * createSampler ( RenderDevice self,
const SDL_GPUSamplerCreateInfo *  info 
)

Creates a Sampler describing filter and address modes.

Convenience factory for Sampler::initWithDevice. For the common filtering presets below, prefer createSamplerLinearRepeat et al.

Parameters
selfThe RenderDevice.
infoSampler creation parameters (min/mag filter, mip mode, address modes, anisotropy, etc.).
Returns
A new, retained Sampler. GPU_Asserts on failure. Free with release.

◆ createSamplerLinearClamp()

Sampler * createSamplerLinearClamp ( RenderDevice self)

Creates a trilinear, edge-clamped Sampler – the common preset for continuously-sampled volumes and non-tiling images (ambient/voxel volumes, cubemaps, post-process targets, UI images).

Linear min/mag filter, linear mipmap mode, CLAMP_TO_EDGE addressing on all three axes. Anisotropic filtering is enabled when self->maxAnisotropy is greater than 0.

Parameters
selfThe RenderDevice.
Returns
A new, retained Sampler. GPU_Asserts on failure. Free with release.

◆ createSamplerLinearRepeat()

Sampler * createSamplerLinearRepeat ( RenderDevice self)

Creates a trilinear, wrapping Sampler – the common preset for tiled surface textures.

Linear min/mag filter, linear mipmap mode, REPEAT addressing on all three axes. Anisotropic filtering is enabled when self->maxAnisotropy is greater than 0.

Parameters
selfThe RenderDevice.
Returns
A new, retained Sampler. GPU_Asserts on failure. Free with release.

◆ createSamplerNearestClamp()

Sampler * createSamplerNearestClamp ( RenderDevice self)

Creates a point-filtered, edge-clamped Sampler – the common preset for data textures fetched by integer coordinate (voxel light data, depth-attachment copies) rather than sampled for appearance.

Nearest min/mag filter, nearest mipmap mode, CLAMP_TO_EDGE addressing on all three axes.

Parameters
selfThe RenderDevice.
Returns
A new, retained Sampler. GPU_Asserts on failure. Free with release.

◆ createSamplerShadowCompare()

Sampler * createSamplerShadowCompare ( RenderDevice self)

Creates a hardware-PCF comparison Sampler for shadow map sampling.

Linear min/mag filter, nearest mipmap mode, CLAMP_TO_EDGE addressing, depth comparison enabled with SDL_GPU_COMPAREOP_LESS_OR_EQUAL.

Parameters
selfThe RenderDevice.
Returns
A new, retained Sampler. GPU_Asserts on failure. Free with release.

◆ createShader()

Shader * createShader ( RenderDevice self,
const SDL_GPUShaderCreateInfo *  info 
)

Creates a Shader from a fully-filled SDL_GPUShaderCreateInfo.

Convenience factory for Shader::initWithDevice. All fields of info, including code, code_size, and format, must be set by the caller. Prefer loadShader to load compiled blobs from the Resource system with automatic format selection.

Parameters
selfThe RenderDevice.
infoShader creation parameters with all fields populated.
Returns
A new, retained Shader. GPU_Asserts on failure. Free with release.

◆ createSolidColorTexture()

Texture * createSolidColorTexture ( RenderDevice self,
SDL_GPUTextureType  type,
Uint32  layerCount,
Uint32  rgba 
)

Creates a small, solid-color Texture – the common "placeholder" pattern for a sampler slot a shader declares but a given draw never actually reads.

type may be SDL_GPU_TEXTURETYPE_2D (layerCount ignored, treated as 1) or SDL_GPU_TEXTURETYPE_CUBE (layerCount must be 6); every texel of every layer is filled with rgba. Always 1x1 per layer/face, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, one mip level, SAMPLER usage only.

Parameters
selfThe RenderDevice.
typeSDL_GPU_TEXTURETYPE_2D or SDL_GPU_TEXTURETYPE_CUBE.
layerCountThe layer/face count (6 for _CUBE, otherwise ignored).
rgbaThe fill color, packed as 0xAABBGGRR (i.e. red in the lowest byte).
Returns
A new, retained Texture. GPU_Asserts on failure. Free with release.

◆ createTexture()

Texture * createTexture ( RenderDevice self,
const SDL_GPUTextureCreateInfo *  info,
const void *  pixels 
)

Creates a Texture, optionally uploading initial pixel data.

Convenience factory for Texture::initWithDevice. When pixels is non-NULL, the pixel data is uploaded immediately so the texture is GPU-resident before returning.

Parameters
selfThe RenderDevice.
infoTexture creation parameters (format, type, dimensions, usage, etc.).
pixelsInitial pixel data to upload, or NULL to leave the texture uninitialised.
Returns
A new, retained Texture. GPU_Asserts on failure. Free with release.

◆ createTextureFromSurface()

Texture * createTextureFromSurface ( RenderDevice self,
SDL_Surface *  surface,
SDL_GPUTextureUsageFlags  usage,
bool  generateMipmaps 
)

Creates a Texture from an SDL_Surface, uploading pixel data immediately.

Convenience factory for Texture::initWithSurface. Converts surface to SDL_PIXELFORMAT_RGBA32 if needed and uploads it as SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM. The surface is not modified or freed.

Parameters
selfThe RenderDevice.
surfaceThe source surface. Must not be NULL.
usageTexture usage flags (e.g. SDL_GPU_TEXTUREUSAGE_SAMPLER).
mipmapsIf true, a full mip chain is allocated and generated; see Texture::initWithSurface.
Returns
A new, retained Texture. GPU_Asserts on failure. Free with release.

◆ createTransferBuffer()

TransferBuffer * createTransferBuffer ( RenderDevice self,
const SDL_GPUTransferBufferCreateInfo *  info 
)

Creates a CPU-accessible transfer buffer for staging data to or from the GPU.

Parameters
selfThe RenderDevice.
infoTransfer buffer creation parameters (usage: upload or download, size).
Returns
A new, retained TransferBuffer. GPU_Asserts on failure. Free with release.

◆ endFrame()

void endFrame ( RenderDevice self)

Ends the frame begun by beginFrame: presents the framebuffer and submits.

Blits the framebuffer's resolved color (Framebuffer::resolveColorTexture, the resolve target when multisampled) into the acquired swapchain texture, submits the frame's command buffer, and releases it. Must be paired with a non-NULL beginFrame return.

Parameters
selfThe RenderDevice.

◆ endFrameAndFence()

Fence * endFrameAndFence ( RenderDevice self)

Ends the frame begun by beginFrame, as endFrame, but returns a Fence.

Identical to endFrame, except the frame's command buffer is submitted via CommandBuffer::submitAndFence, so callers may track when the frame's GPU work has completed, e.g. to safely read back data written during the frame. The returned Fence is retained; release it when no longer needed.

Parameters
selfThe RenderDevice.
Returns
A new, retained Fence, or NULL on error.

◆ getSwapchainTextureFormat()

SDL_GPUTextureFormat getSwapchainTextureFormat ( const RenderDevice self)

Returns the pixel format of this device's swapchain.

Useful for configuring render-pass colour target formats or creating pipelines that write to the swapchain. The device must have a window claimed.

Parameters
selfThe RenderDevice.
Returns
The SDL_GPUTextureFormat of the window's swapchain.

◆ init()

RenderDevice * init ( RenderDevice self)

Initialises a RenderDevice, creating an SDL_GPUDevice with no window claimed.

Creates the device supporting MSL, SPIR-V, and DXIL shader formats. Use setWindow or initWithWindow to associate a window after init.

Parameters
selfThe RenderDevice.
Returns
The initialised RenderDevice, or NULL on failure.

◆ initWithWindow()

RenderDevice * initWithWindow ( RenderDevice self,
SDL_Window *  window 
)

Initialises a RenderDevice and immediately claims window for rendering.

Parameters
selfThe RenderDevice.
windowThe SDL_Window to claim for this device.
Returns
The initialised RenderDevice, or NULL on failure.

◆ loadComputePipeline()

ComputePipeline * loadComputePipeline ( RenderDevice self,
const char *  name,
const SDL_GPUComputePipelineCreateInfo *  info 
)

Loads a compiled compute shader blob via the Resource system and creates a ComputePipeline.

Parallel to loadShader for compute stages. Appends each supported format's extension to name and resolves it via Objectively's ResourceProvider chain:

  • Metal (macOS/iOS): .metallib, then .metal
  • Vulkan (Linux/Android): .spv
  • D3D12 (Windows): .dxil The caller fills in entrypoint, thread counts, and binding counts in info. code, code_size, format, and a default entrypoint are filled in for you, then the completed info is passed to ComputePipeline::initWithDevice. Shader blobs are produced offline by sdl-shadercross.
    Parameters
    selfThe RenderDevice.
    nameShader base name without extension, e.g. "HelloCompute.comp".
    infoCompute pipeline creation parameters. code, code_size, and format are ignored; all other fields must be set by the caller.
    Returns
    A new, retained ComputePipeline. GPU_Asserts on failure. Free with release.

◆ loadGraphicsPipeline()

GraphicsPipeline * loadGraphicsPipeline ( RenderDevice self,
const char *  vertexShaderName,
const SDL_GPUShaderCreateInfo *  vertexShaderInfo,
const char *  fragmentShaderName,
const SDL_GPUShaderCreateInfo *  fragmentShaderInfo,
SDL_GPUGraphicsPipelineCreateInfo *  info 
)

Loads a vertex/fragment shader pair and creates a GraphicsPipeline from them.

Convenience over the load-both/assign/create/release-both boilerplate every graphics pipeline needs: calls loadShader for vertexShaderName and fragmentShaderName, assigns the results to info's vertex_shader/ fragment_shader fields, calls createGraphicsPipeline, then releases both Shaders (they're retained by the pipeline internally; the caller never sees or owns them). info must otherwise be fully populated (vertex layout, blend/rasterizer/depth-stencil state, colour target formats) by the caller.

Parameters
selfThe RenderDevice.
vertexShaderNameVertex shader base name, e.g. "shaders/bsp_vs".
vertexShaderInfoVertex shader creation parameters (see loadShader).
fragmentShaderNameFragment shader base name, e.g. "shaders/bsp_fs".
fragmentShaderInfoFragment shader creation parameters (see loadShader).
infoGraphics pipeline creation parameters; vertex_shader/fragment_shader are overwritten, all other fields must already be set.
Returns
A new, retained GraphicsPipeline. GPU_Asserts on failure. Free with release.

◆ loadShader()

Shader * loadShader ( RenderDevice self,
const char *  name,
const SDL_GPUShaderCreateInfo *  info 
)

Loads a shader blob via the Resource system and creates a Shader.

Appends each supported format's extension to name and resolves it via Objectively's ResourceProvider chain:

  • Metal (macOS/iOS): .metallib, then .metal
  • Vulkan (Linux/Android): .spv
  • D3D12 (Windows): .dxil The caller fills in stage, entrypoint, and binding counts in info. code, code_size, format, and a default entrypoint are filled in for you, then the completed info is passed to Shader::initWithDevice. Shader blobs are produced offline by sdl-shadercross.
    Parameters
    selfThe RenderDevice.
    nameShader base name without extension, e.g. "shaders/Renderer.vert".
    infoShader creation parameters. code, code_size, and format are ignored; all other fields must be set by the caller.
    Returns
    A new, retained Shader. GPU_Asserts on failure. Free with release.

◆ setAllowedFramesInFlight()

bool setAllowedFramesInFlight ( const RenderDevice self,
Uint32  allowed 
)

Sets the maximum number of GPU frames that may be in flight concurrently.

Lower values reduce latency; higher values improve throughput. The default is determined by SDL. Takes effect on the next frame.

Parameters
selfThe RenderDevice.
allowedMaximum concurrent in-flight frames (1–3 are typical values).
Returns
true on success, false if the value is unsupported.

◆ setFramebuffer()

void setFramebuffer ( RenderDevice self,
Framebuffer framebuffer 
)

Sets the present-target Framebuffer driven by beginFrame/endFrame.

The device retains framebuffer and releases any previously set one. Construct the Framebuffer with the desired color/depth formats and MSAA sample count; beginFrame resizes it to the swapchain each frame. Pass NULL to clear.

Parameters
selfThe RenderDevice.
framebufferThe Framebuffer to present each frame, or NULL.

◆ setSwapchainParameters() [1/2]

bool setSwapchainParameters ( const RenderDevice self,
SDL_GPUSwapchainComposition  composition,
SDL_GPUPresentMode  mode 
)

Configures swapchain composition and present mode for this device's window.

Use supportsSwapchainComposition and supportsPresentMode to guard against unsupported combinations before calling this.

Parameters
selfThe RenderDevice.
compositionColour space / HDR composition mode.
modePresentation mode (vsync, mailbox, immediate, etc.).
Returns
true on success, false if the combination is unsupported.

◆ setSwapchainParameters() [2/2]

bool setSwapchainParameters ( const RenderDevice self,
SDL_Window *  window,
SDL_GPUSwapchainComposition  composition,
SDL_GPUPresentMode  mode 
)

◆ setWindow()

void setWindow ( RenderDevice self,
SDL_Window *  window 
)

Claims window for this device, releasing any previously claimed window.

If a different window is already claimed it is released via SDL_ReleaseWindowFromGPUDevice first. Passing NULL releases the current window without claiming a new one.

Parameters
selfThe RenderDevice.
windowThe SDL_Window to claim, or NULL to release the current window.

◆ supportsPresentMode()

bool supportsPresentMode ( const RenderDevice self,
SDL_GPUPresentMode  mode 
)

Queries whether this device's swapchain supports the given present mode.

Parameters
selfThe RenderDevice.
modeThe present mode to test.
Returns
true if the present mode is supported.

◆ supportsSwapchainComposition()

bool supportsSwapchainComposition ( const RenderDevice self,
SDL_GPUSwapchainComposition  composition 
)

Queries whether this device's swapchain supports the given composition (colour space / HDR mode).

Parameters
selfThe RenderDevice.
compositionThe swapchain composition to test.
Returns
true if the composition is supported.

◆ textureSupportsFormat()

bool textureSupportsFormat ( const RenderDevice self,
SDL_GPUTextureFormat  format,
SDL_GPUTextureType  type,
SDL_GPUTextureUsageFlags  usage 
)

Queries whether a texture format is supported for a given type and usage.

Parameters
selfThe RenderDevice.
formatThe texture format to query.
typeThe texture dimensionality (2D, cube, 3D, etc.).
usageBitmask of intended usages (sampler, colour target, storage, etc.).
Returns
true if the format/type/usage combination is supported.

◆ textureSupportsSampleCount()

bool textureSupportsSampleCount ( const RenderDevice self,
SDL_GPUTextureFormat  format,
SDL_GPUSampleCount  sample_count 
)

Queries whether a texture format supports a given MSAA sample count.

Parameters
selfThe RenderDevice.
formatThe texture format to query.
sample_countThe MSAA sample count to test.
Returns
true if the format supports the requested sample count.

◆ waitForIdle()

bool waitForIdle ( const RenderDevice self)

Blocks until the GPU has finished all submitted work.

Use sparingly — typically only at shutdown or before releasing GPU resources that may still be in use.

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

◆ waitForSwapchain()

bool waitForSwapchain ( const RenderDevice self)

Blocks until this device's swapchain is available for the next frame.

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

Field Documentation

◆ data

ident RenderDevice::data

User data.

◆ device

SDL_GPUDevice* RenderDevice::device

The SDL_GPUDevice.

◆ framebuffer

Framebuffer* RenderDevice::framebuffer

The present-target Framebuffer driven by beginFrame/endFrame, or NULL.

Set via setFramebuffer (retained). beginFrame resizes it to the swapchain each frame and endFrame blits its resolved color to the swapchain.

◆ interface

RenderDeviceInterface* RenderDevice::interface
protected

The interface.

◆ maxAnisotropy

float RenderDevice::maxAnisotropy

The anisotropic filtering level applied by createSamplerLinearRepeat and createSamplerLinearClamp. Defaults to 0 (anisotropic filtering disabled). Assign directly; only affects Samplers created afterward, since SDL_gpu Samplers are immutable once created.

◆ object

Object RenderDevice::object

The superclass.

◆ shaderFormats

SDL_GPUShaderFormat RenderDevice::shaderFormats

The bitmask of supported shader formats.

◆ window

SDL_Window* RenderDevice::window

The SDL_Window associated with device.


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