Skip to main content

DisplayHdrInfo

Struct DisplayHdrInfo 

Source
pub struct DisplayHdrInfo {
    pub luminance: Option<DisplayLuminance>,
    pub headroom: Option<DisplayHeadroom>,
    pub chromaticity: Option<DisplayChromaticity>,
    pub coarse: Option<DisplayCoarseRange>,
    pub bits_per_color: Option<u8>,
}
Expand description

HDR and luminance characteristics of the display backing a Surface, as reported by the platform at query time.

This describes the display; it does not configure it. Set the output color space through SurfaceConfiguration::color_space; wgpu does not write HDR metadata (vkSetHdrMetadataEXT / DXGI SetHDRMetaData).

Use it for tone mapping, not to decide whether to enable HDR - that is a capability question for SurfaceCapabilities, and holds even when the panel has no headroom right now. The live highlight multiplier is tone_map_headroom.

The values change as the display does, so re-query after the surface moves or resizes or the display configuration changes.

Every field is Option and no platform reports them all; None means unknown, never zero and never SDR (Windows reports nits, macOS only a headroom multiplier). The numbers are advisory hints, not contracts: OS/EDID figures run optimistic and report the panel’s claim, not what survives the compositor.

Fields§

§luminance: Option<DisplayLuminance>

Absolute-nit luminance levels. Some only on platforms that report absolute nits (Windows, via DXGI). None on Apple EDR, the web, Vulkan on non-Windows, and GLES.

§headroom: Option<DisplayHeadroom>

Relative EDR-headroom multipliers. Some only on Apple. None elsewhere.

§chromaticity: Option<DisplayChromaticity>

Chromaticity of the display’s primaries and white point (CIE 1931 xy). Some only on Windows (via DXGI). None on Apple (which exposes no primaries), the web (boolean-only), Vulkan on non-Windows, and GLES. Advisory (often EDID-sourced).

§coarse: Option<DisplayCoarseRange>

Coarse, boolean dynamic-range + gamut bucket. The only luminance-adjacent data the web exposes (CSS dynamic-range / color-gamut), and a useful cross-check elsewhere. None only when nothing at all is known.

§bits_per_color: Option<u8>

Output signal bit depth, e.g. 8 / 10 / 12 (DXGI BitsPerColor). Advisory and often unreliable (may report 8 on a 10-bit panel). None if unreported.

Implementations§

Source§

impl DisplayHdrInfo

Source

pub fn tone_map_headroom(&self) -> Option<f32>

Best-effort tone-map headroom: the linear multiplier of SDR white the display can drive before clipping. This is the single value most tone-mappers want, with the subjective parts left to the application.

Resolution order, first match wins:

  1. Apple EDR: DisplayHeadroom::current (already a multiplier).
  2. Some(1.0) when DisplayCoarseRange::high_dynamic_range is Some(false) — a definitively-SDR display (Windows and the web both set this flag for an SDR output). Its panel peak may sit above its SDR white, but that ratio isn’t headroom you can drive, so it isn’t reported as such.
  3. Absolute nits: max_nits / sdr_white_nits, when both are known and sdr_white_nits > 0.0.
  4. Otherwise None: the available figures don’t pin a multiplier (e.g. max_nits known but sdr_white_nits unknown).

Use unwrap_or(1.0) on the result for the SDR fallback. Never returns a non-finite value.

Trait Implementations§

Source§

impl Clone for DisplayHdrInfo

Source§

fn clone(&self) -> DisplayHdrInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DisplayHdrInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DisplayHdrInfo

Source§

fn default() -> DisplayHdrInfo

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DisplayHdrInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DisplayHdrInfo

Source§

fn eq(&self, other: &DisplayHdrInfo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DisplayHdrInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DisplayHdrInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.