|
ObjectivelyGPU
Object oriented graphics framework for SDL3 and C
|
An off-screen render target grouping a color and/or depth texture. More...
#include <Framebuffer.h>
Public Member Functions | |
| SDL_GPUColorTargetInfo | colorTargetInfo (const Framebuffer *self, Uint32 index, SDL_GPULoadOp loadOp, SDL_GPUStoreOp storeOp, const SDL_FColor *clearColor) |
Returns a populated SDL_GPUColorTargetInfo for color attachment index. | |
| SDL_GPUDepthStencilTargetInfo | depthTargetInfo (const Framebuffer *self, SDL_GPULoadOp loadOp, SDL_GPUStoreOp storeOp, float clearDepth) |
Returns a populated SDL_GPUDepthStencilTargetInfo for this framebuffer's depth attachment. | |
| Framebuffer * | initWithDevice (Framebuffer *self, RenderDevice *device, const GPU_FramebufferCreateInfo *info) |
| Initializes this Framebuffer and allocates its GPU textures. | |
| bool | resize (Framebuffer *self, const SDL_Size *size) |
Releases the existing GPU textures and recreates them at size. | |
| Texture * | resolveColorTexture (const Framebuffer *self, Uint32 index) |
Returns the single-sample, sampleable color texture for attachment index, to sample, blit, or present. | |
| Texture * | resolveDepthTexture (const Framebuffer *self) |
| Returns the single-sample, sampleable depth texture, to read scene depth (e.g. soft particles). | |
| Class * | _Framebuffer (void) |
| The Framebuffer archetype. | |
Data Fields | |
| Object | object |
| The superclass. | |
| SDL_Size | size |
| The framebuffer dimensions. | |
| SDL_GPUSampleCount | sampleCount |
| The MSAA sample count of all attachments. | |
| Uint32 | numColorTargets |
The number of color attachments; indices [0, numColorTargets) are valid. | |
| SDL_GPUTextureFormat | colorFormats [GPU_MAX_COLOR_TARGETS] |
The color attachment texture formats, indices [0, numColorTargets). | |
| Texture * | colorTextures [GPU_MAX_COLOR_TARGETS] |
The color attachment textures, indices [0, numColorTargets). | |
| Texture * | resolveTextures [GPU_MAX_COLOR_TARGETS] |
The single-sample resolve targets, or all NULL unless sampleCount > SDL_GPU_SAMPLECOUNT_1. | |
| SDL_GPUTextureFormat | depthFormat |
The depth attachment texture format, or SDL_GPU_TEXTUREFORMAT_INVALID if none. | |
| ident | data |
| User data. | |
Protected Attributes | |
| FramebufferInterface * | interface |
| The interface. | |
An off-screen render target grouping a color and/or depth texture.
Framebuffer owns a pair of SDL_GPUTexture objects (color and/or depth) and provides helpers that produce the SDL_GPUColorTargetInfo and SDL_GPUDepthStencilTargetInfo values required by CommandBuffer::beginRenderPass.
Use SDL_GPU_TEXTUREFORMAT_INVALID for either format to omit that attachment. Call resize whenever the window dimensions change; it releases the existing textures and recreates them at the new size.
| Class * _Framebuffer | ( | void | ) |
The Framebuffer archetype.
| SDL_GPUColorTargetInfo colorTargetInfo | ( | const Framebuffer * | self, |
| Uint32 | index, | ||
| SDL_GPULoadOp | loadOp, | ||
| SDL_GPUStoreOp | storeOp, | ||
| const SDL_FColor * | clearColor | ||
| ) |
Returns a populated SDL_GPUColorTargetInfo for color attachment index.
Assemble an array of these (one per color target) and pass it to CommandBuffer::beginRenderPass. When multisampled, the resolve target and a RESOLVE_AND_STORE store op are wired in automatically. asserts index is valid.
| self | The Framebuffer. |
| index | The color attachment index, in [0, numColorTargets). |
| loadOp | Load operation at the start of the pass. |
| storeOp | Store operation at the end of the pass. |
| clearColor | Clear color used when loadOp is SDL_GPU_LOADOP_CLEAR, or NULL for black. |
SDL_GPUColorTargetInfo. | SDL_GPUDepthStencilTargetInfo depthTargetInfo | ( | const Framebuffer * | self, |
| SDL_GPULoadOp | loadOp, | ||
| SDL_GPUStoreOp | storeOp, | ||
| float | clearDepth | ||
| ) |
Returns a populated SDL_GPUDepthStencilTargetInfo for this framebuffer's depth attachment.
Pass the result directly to CommandBuffer::beginRenderPass. asserts that depthTexture is non-NULL.
| self | The Framebuffer. |
| loadOp | Load operation at the start of the pass. |
| storeOp | Store operation at the end of the pass. |
| clearDepth | Clear depth value used when loadOp is SDL_GPU_LOADOP_CLEAR. |
SDL_GPUDepthStencilTargetInfo. | Framebuffer * initWithDevice | ( | Framebuffer * | self, |
| RenderDevice * | device, | ||
| const GPU_FramebufferCreateInfo * | info | ||
| ) |
Initializes this Framebuffer and allocates its GPU textures.
| self | The Framebuffer. |
| device | The RenderDevice used to allocate and release textures. |
| info | Framebuffer creation parameters (size, formats, sample count). |
| bool resize | ( | Framebuffer * | self, |
| const SDL_Size * | size | ||
| ) |
Releases the existing GPU textures and recreates them at size.
Call this when the window is resized. Returns false if size matches the current size and no reallocation is needed.
| self | The Framebuffer. |
| size | The new framebuffer dimensions. |
true if textures were reallocated; false if the size was unchanged. | Texture * resolveColorTexture | ( | const Framebuffer * | self, |
| Uint32 | index | ||
| ) |
Returns the single-sample, sampleable color texture for attachment index, to sample, blit, or present.
Returns resolveTextures[index] when multisampled, otherwise colorTextures[index].
| self | The Framebuffer. |
| index | The color attachment index, in [0, numColorTargets). |
NULL if index has no attachment. | Texture * resolveDepthTexture | ( | const Framebuffer * | self | ) |
Returns the single-sample, sampleable depth texture, to read scene depth (e.g. soft particles).
Single-sample: the depth attachment itself (created with SAMPLER). Multisampled: the separate resolveDepthTexture, which must first be populated by a resolve pass (SDL has no depth store-op resolve). Returns NULL if the framebuffer has no depth attachment.
| self | The Framebuffer. |
NULL if there is no depth attachment. | SDL_GPUTextureFormat Framebuffer::colorFormats[GPU_MAX_COLOR_TARGETS] |
The color attachment texture formats, indices [0, numColorTargets).
| Texture* Framebuffer::colorTextures[GPU_MAX_COLOR_TARGETS] |
The color attachment textures, indices [0, numColorTargets).
Multisampled when sampleCount > SDL_GPU_SAMPLECOUNT_1; in that case sample/blit/present the corresponding resolveTextures entry, not these.
| ident Framebuffer::data |
User data.
| SDL_GPUTextureFormat Framebuffer::depthFormat |
The depth attachment texture format, or SDL_GPU_TEXTUREFORMAT_INVALID if none.
|
protected |
The interface.
| Uint32 Framebuffer::numColorTargets |
The number of color attachments; indices [0, numColorTargets) are valid.
| Object Framebuffer::object |
The superclass.
| Texture* Framebuffer::resolveTextures[GPU_MAX_COLOR_TARGETS] |
The single-sample resolve targets, or all NULL unless sampleCount > SDL_GPU_SAMPLECOUNT_1.
Render passes resolve colorTextures[i] into resolveTextures[i]; that is the texture to sample, blit, or present. See resolveColorTexture.
| SDL_GPUSampleCount Framebuffer::sampleCount |
The MSAA sample count of all attachments.
SDL_GPU_SAMPLECOUNT_1 for no multisampling. When greater, every color attachment and the depth attachment are multisampled (a render pass requires a single sample count across all attachments); each color attachment also gets a single-sample resolve target in resolveTextures.
| SDL_Size Framebuffer::size |
The framebuffer dimensions.