Skip to main content

Module hdr

Module hdr 

Source
Expand description

HDR and wide-gamut surface format selection for the wgpu backend.

This module provides:

  • SurfaceColorFormat — an enumeration of supported colour formats with their metadata (bits per channel, colour gamut, HDR capability).
  • HdrGpuContext — a headless GPU context that uses Rgba16Float (wide-gamut / HDR) instead of the default Rgba8Unorm.
  • select_surface_format — a heuristic that picks the best available format from a list of adapter-supported formats, preferring HDR variants when available and the caller opts in.

§Colour-space handling in the fragment shader

Rgba8Unorm stores gamma-encoded sRGB values; Rgba16Float stores linear light values in the Rec.2020 or Display-P3 colour space (depending on the OS colour management layer). When rendering into an Rgba16Float target the fragment shader should output linear light values; the display pipeline applies the appropriate OETF (transfer function) on presentation.

For headless / offscreen rendering (HdrGpuContext) the application reads back raw f16 values; it is the caller’s responsibility to apply any tone-mapping required before displaying or saving the image.

Structs§

HdrGpuContext
A headless GPU context backed by an Rgba16Float offscreen texture.

Enums§

SurfaceColorFormat
A supported colour surface format.

Constants§

HDR_FORMAT
The HDR offscreen format.

Functions§

select_surface_format
Choose the best format from supported_formats given a preference.