Renders batched HUD geometry to an offscreen RGBA8 texture.
More...
#include <HudRenderer.hpp>
|
| bool | init (SDL_GPUDevice *device, SDL_GPUShaderFormat shaderFormat, const SdfAtlas &sdfAtlas, uint32_t screenW, uint32_t screenH) |
| | Initialise GPU resources.
|
| void | quit () |
| | Release all GPU resources.
|
| void | resize (uint32_t newW, uint32_t newH) |
| | Recreate the offscreen target on window resize.
|
| void | render (std::span< const HudVertex > vertices, std::span< const std::array< float, 6 > > clipRects) |
| | Upload vertex data, execute the HUD render pass, and submit.
|
| SDL_GPUTexture * | getOutputTexture () const |
| | The offscreen texture to be blitted by the renderer.
|
| uint32_t | width () const |
| | Current target width.
|
| uint32_t | height () const |
| | Current target height.
|
Renders batched HUD geometry to an offscreen RGBA8 texture.
Owns the GPU pipeline, offscreen render target, dynamic vertex buffer, and sampler bindings. The renderer (legacy/new) reads getOutputTexture() and blits it after tone mapping.
◆ createOffscreenTarget()
| bool HudRenderer::createOffscreenTarget |
( |
uint32_t | w, |
|
|
uint32_t | h ) |
|
private |
◆ createPipeline()
| bool HudRenderer::createPipeline |
( |
| ) |
|
|
private |
◆ ensureVertexBuffer()
| bool HudRenderer::ensureVertexBuffer |
( |
uint32_t | requiredVertices | ) |
|
|
private |
◆ getOutputTexture()
| SDL_GPUTexture * HudRenderer::getOutputTexture |
( |
| ) |
const |
|
inlinenodiscard |
The offscreen texture to be blitted by the renderer.
◆ height()
| uint32_t HudRenderer::height |
( |
| ) |
const |
|
inlinenodiscard |
◆ init()
| bool HudRenderer::init |
( |
SDL_GPUDevice * | device, |
|
|
SDL_GPUShaderFormat | shaderFormat, |
|
|
const SdfAtlas & | sdfAtlas, |
|
|
uint32_t | screenW, |
|
|
uint32_t | screenH ) |
Initialise GPU resources.
- Parameters
-
| device | Shared SDL GPU device. |
| shaderFormat | SPIR-V, MSL, or DXIL. |
| sdfAtlas | Font atlas for SDF text rendering. |
| screenW | Initial viewport width. |
| screenH | Initial viewport height. |
- Returns
- true on success.
◆ loadShader()
| SDL_GPUShader * HudRenderer::loadShader |
( |
const char * | name, |
|
|
SDL_GPUShaderStage | stage, |
|
|
uint32_t | samplerCount, |
|
|
uint32_t | uniformBufferCount ) |
|
private |
Load a compiled shader from the shaders/ directory.
◆ quit()
| void HudRenderer::quit |
( |
| ) |
|
Release all GPU resources.
◆ render()
| void HudRenderer::render |
( |
std::span< const HudVertex > | vertices, |
|
|
std::span< const std::array< float, 6 > > | clipRects ) |
Upload vertex data, execute the HUD render pass, and submit.
Acquires its own command buffer, clears the offscreen target to transparent black, draws all batched quads, and submits.
- Parameters
-
| vertices | Flat vertex array produced by HudContext. |
| clipRects | Parallel array of clip rects for scissor state changes. Each entry is {startVertex, vertexCount, x, y, w, h}. |
◆ resize()
| void HudRenderer::resize |
( |
uint32_t | newW, |
|
|
uint32_t | newH ) |
Recreate the offscreen target on window resize.
◆ width()
| uint32_t HudRenderer::width |
( |
| ) |
const |
|
inlinenodiscard |
◆ device_
| SDL_GPUDevice* HudRenderer::device_ = nullptr |
|
private |
◆ height_
| uint32_t HudRenderer::height_ = 0 |
|
private |
◆ iconAtlasSamp_
| SDL_GPUSampler* HudRenderer::iconAtlasSamp_ = nullptr |
|
private |
◆ iconAtlasTex_
| SDL_GPUTexture* HudRenderer::iconAtlasTex_ = nullptr |
|
private |
Owning: 1x1 white fallback until real atlas.
◆ offscreenTarget_
| SDL_GPUTexture* HudRenderer::offscreenTarget_ = nullptr |
|
private |
◆ pipeline_
| SDL_GPUGraphicsPipeline* HudRenderer::pipeline_ = nullptr |
|
private |
◆ sdfAtlasSamp_
| SDL_GPUSampler* HudRenderer::sdfAtlasSamp_ = nullptr |
|
private |
◆ sdfAtlasTex_
| SDL_GPUTexture* HudRenderer::sdfAtlasTex_ = nullptr |
|
private |
◆ shaderFormat_
| SDL_GPUShaderFormat HudRenderer::shaderFormat_ = SDL_GPU_SHADERFORMAT_INVALID |
|
private |
◆ transferBuffer_
| SDL_GPUTransferBuffer* HudRenderer::transferBuffer_ = nullptr |
|
private |
◆ vertexBuffer_
| SDL_GPUBuffer* HudRenderer::vertexBuffer_ = nullptr |
|
private |
◆ vertexCapacity_
| uint32_t HudRenderer::vertexCapacity_ = 0 |
|
private |
Current buffer capacity in vertices.
◆ width_
| uint32_t HudRenderer::width_ = 0 |
|
private |
The documentation for this class was generated from the following files: