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

Describes, and backs, a single Framebuffer attachment (color or depth). More...

#include <Framebuffer.h>

Data Fields

SDL_GPUTextureFormat format
 The attachment format, or SDL_GPU_TEXTUREFORMAT_INVALID to omit (depth only).
 
union { 
 
   SDL_FColor   clearColor 
 The clear color, for color attachments. More...
 
   float   clearDepth 
 The clear depth value, for the depth attachment. More...
 
};  
 
bool doubleBuffered
 If true, this attachment is double-buffered; see above.
 
Uint32 layerCount
 The number of array layers, or 0 or 1 for a plain 2D attachment.
 

Detailed Description

Describes, and backs, a single Framebuffer attachment (color or depth).

format, the clear value, and doubleBuffered are the input description: set them in GPU_FramebufferCreateInfo with a designated initializer. textures and resolveTextures are live state, populated by Framebuffer::resize and owned by the Framebuffer – leave them zeroed in a GPU_FramebufferCreateInfo.

When doubleBuffered is true, the attachment allocates both texture slots and Framebuffer::swap alternates which slot is the current frame's write target, so the other slot remains valid to sample as last frame's contents – e.g. a depth copy sampled by soft particles – without a same-frame write-then-read hazard. Single-buffered attachments (doubleBuffered false) only ever use slot 0.

Field Documentation

◆ [union]

◆ clearColor

SDL_FColor GPU_FramebufferAttachment::clearColor

The clear color, for color attachments.

Used by Framebuffer::colorTargetInfo and CommandBuffer::beginRenderPassWithFramebuffer.

◆ clearDepth

float GPU_FramebufferAttachment::clearDepth

The clear depth value, for the depth attachment.

Used by CommandBuffer::beginRenderPassWithFramebuffer.

◆ doubleBuffered

bool GPU_FramebufferAttachment::doubleBuffered

If true, this attachment is double-buffered; see above.

◆ format

SDL_GPUTextureFormat GPU_FramebufferAttachment::format

The attachment format, or SDL_GPU_TEXTUREFORMAT_INVALID to omit (depth only).

◆ layerCount

Uint32 GPU_FramebufferAttachment::layerCount

The number of array layers, or 0 or 1 for a plain 2D attachment.

When greater than 1, the attachment is backed by a 2D array texture and a render pass targets one layer at a time via Framebuffer::colorTargetInfoForLayer. Framebuffer::resolveColorTexture returns the whole array, to be sampled with a layer index – e.g. several off-screen views rendered into one texture and sampled by one binding. Layer count is fixed for the life of the Framebuffer; Framebuffer::resize preserves it. Color attachments only; a render pass has a single depth target.

Remarks
A layered attachment MAY be multisampled, but its layers then share one multisample target and each pass MUST clear rather than load; see textures.

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