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
impl DisplayHdrInfo
Sourcepub fn tone_map_headroom(&self) -> Option<f32>
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:
- Apple EDR:
DisplayHeadroom::current(already a multiplier). Some(1.0)whenDisplayCoarseRange::high_dynamic_rangeisSome(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.- Absolute nits:
max_nits / sdr_white_nits, when both are known andsdr_white_nits > 0.0. - Otherwise
None: the available figures don’t pin a multiplier (e.g.max_nitsknown butsdr_white_nitsunknown).
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
impl Clone for DisplayHdrInfo
Source§fn clone(&self) -> DisplayHdrInfo
fn clone(&self) -> DisplayHdrInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DisplayHdrInfo
impl Debug for DisplayHdrInfo
Source§impl Default for DisplayHdrInfo
impl Default for DisplayHdrInfo
Source§fn default() -> DisplayHdrInfo
fn default() -> DisplayHdrInfo
Source§impl<'de> Deserialize<'de> for DisplayHdrInfo
impl<'de> Deserialize<'de> for DisplayHdrInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for DisplayHdrInfo
impl PartialEq for DisplayHdrInfo
Source§fn eq(&self, other: &DisplayHdrInfo) -> bool
fn eq(&self, other: &DisplayHdrInfo) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for DisplayHdrInfo
impl Serialize for DisplayHdrInfo
impl StructuralPartialEq for DisplayHdrInfo
Auto Trait Implementations§
impl Freeze for DisplayHdrInfo
impl RefUnwindSafe for DisplayHdrInfo
impl Send for DisplayHdrInfo
impl Sync for DisplayHdrInfo
impl Unpin for DisplayHdrInfo
impl UnsafeUnpin for DisplayHdrInfo
impl UnwindSafe for DisplayHdrInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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