32 bool init(SDL_GPUDevice* device,
33 SDL_GPUShaderFormat shaderFormat,
43 void resize(uint32_t newW, uint32_t newH);
52 void render(std::span<const HudVertex> vertices, std::span<
const std::array<float, 6>> clipRects);
75 static constexpr SDL_GPUSampleCount
k_sampleCount = SDL_GPU_SAMPLECOUNT_4;
106 loadShader(
const char* name, SDL_GPUShaderStage stage, uint32_t samplerCount, uint32_t uniformBufferCount);
Shared types for the HUD system.
Renders batched HUD geometry to an offscreen RGBA8 texture.
Definition HudRenderer.hpp:23
uint32_t vertexCapacity_
Current buffer capacity in vertices.
Definition HudRenderer.hpp:91
SDL_GPUSampler * iconAtlasSamp_
Owning.
Definition HudRenderer.hpp:86
uint32_t width() const
Current target width.
Definition HudRenderer.hpp:58
SDL_GPUSampler * sdfAtlasSamp_
Non-owning: from SdfAtlas.
Definition HudRenderer.hpp:83
bool init(SDL_GPUDevice *device, SDL_GPUShaderFormat shaderFormat, const SdfAtlas &sdfAtlas, const HudSvgAtlas *svgAtlas, uint32_t screenW, uint32_t screenH)
Initialise GPU resources.
Definition HudRenderer.cpp:17
SDL_GPUGraphicsPipeline * pipeline_
Definition HudRenderer.hpp:78
SDL_GPUShader * loadShader(const char *name, SDL_GPUShaderStage stage, uint32_t samplerCount, uint32_t uniformBufferCount)
Load a compiled shader from the shaders/ directory.
Definition HudRenderer.cpp:436
bool ensureVertexBuffer(uint32_t requiredVertices)
Definition HudRenderer.cpp:404
SDL_GPUTexture * getOutputTexture() const
The offscreen texture to be blitted by the renderer.
Definition HudRenderer.hpp:55
SDL_GPUTexture * offscreenTarget_
1×, COLOR_TARGET | SAMPLER (resolve dst).
Definition HudRenderer.hpp:72
SDL_GPUTexture * sdfAtlasTex_
Non-owning: from SdfAtlas.
Definition HudRenderer.hpp:82
SDL_GPUTexture * iconAtlasTex_
Owning: 1x1 white fallback until real atlas.
Definition HudRenderer.hpp:85
SDL_GPUBuffer * vertexBuffer_
Definition HudRenderer.hpp:89
uint32_t width_
Definition HudRenderer.hpp:73
SDL_GPUDevice * device_
Definition HudRenderer.hpp:64
static constexpr SDL_GPUSampleCount k_sampleCount
Definition HudRenderer.hpp:75
SDL_GPUTransferBuffer * transferBuffer_
Definition HudRenderer.hpp:90
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.
Definition HudRenderer.cpp:130
void quit()
Release all GPU resources.
Definition HudRenderer.cpp:89
SDL_GPUShaderFormat shaderFormat_
Definition HudRenderer.hpp:65
uint32_t height_
Definition HudRenderer.hpp:74
bool createPipeline()
Definition HudRenderer.cpp:305
bool createOffscreenTarget(uint32_t w, uint32_t h)
Definition HudRenderer.cpp:258
const HudSvgAtlas * svgAtlas_
Non-owning: LunaSVG HUD sprite atlas.
Definition HudRenderer.hpp:84
SDL_GPUTexture * msaaTarget_
4× multisampled, COLOR_TARGET only.
Definition HudRenderer.hpp:71
SDL_GPUGraphicsPipeline * erasePipeline_
Definition HudRenderer.hpp:79
void resize(uint32_t newW, uint32_t newH)
Recreate the offscreen target on window resize.
Definition HudRenderer.cpp:117
uint32_t height() const
Current target height.
Definition HudRenderer.hpp:61
Definition HudSvgAtlas.hpp:26
Loads a TTF font, bakes an SDF glyph atlas, and uploads it to the GPU.
Definition SdfAtlas.hpp:18