pub struct DmaBufHandle {
pub width: u32,
pub height: u32,
pub format: SurfaceFormatKind,
pub modifier: u64,
pub planes: SmallVec<[DmaBufPlane; 2]>,
pub acquire_fence: Option<Arc<OwnedFd>>,
pub release: Option<Arc<OwnedFd>>,
pub chroma: ChromaReconstruction,
pub color_space: YuvColorSpace,
}Expand description
A dma-buf a producer hands the renderer to composite as a surface.
See the module documentation for the producer’s contract — uncompressed, linear across vendors, dedicated when the planes are split.
Fields§
§width: u32The surface width, in pixels.
height: u32The surface height, in pixels.
format: SurfaceFormatKindThe pixel layout.
modifier: u64The DRM format modifier (tiling/compression layout); Self::LINEAR for a linear buffer.
planes: SmallVec<[DmaBufPlane; 2]>One plane per SurfaceFormatKind::plane_count.
acquire_fence: Option<Arc<OwnedFd>>An optional sync_file fence the renderer waits on before sampling the buffer; a fence that
does not signal in time drops the surface for that frame rather than blocking the frame.
release: Option<Arc<OwnedFd>>An optional descriptor the renderer signals once it has finished sampling the buffer — the
mirror of acquire_fence, which the renderer waits on. A producer that
recycles surfaces waits on this before returning one to its pool.
It is not a sync_file: wgpu owns its queue and offers no way to export one, so what carries
the signal is an eventfd the producer makes, which the renderer writes to once the submission
that sampled the buffer has completed.
chroma: ChromaReconstructionHow the renderer should reconstruct chroma; the producer’s hint for a YCbCr buffer, and ignored for an RGB one.
color_space: YuvColorSpaceThe colour space this buffer’s YCbCr bytes are in; ignored for an RGB one, whose bytes are already RGB.
Implementations§
Source§impl DmaBufHandle
impl DmaBufHandle
Sourcepub const LINEAR: u64 = 0
pub const LINEAR: u64 = 0
DRM_FORMAT_MOD_LINEAR: the only modifier meaningful across GPU vendors.
Sourcepub fn new(
width: u32,
height: u32,
format: SurfaceFormatKind,
modifier: u64,
planes: impl IntoIterator<Item = DmaBufPlane>,
acquire_fence: Option<OwnedFd>,
) -> DmaBufHandle
pub fn new( width: u32, height: u32, format: SurfaceFormatKind, modifier: u64, planes: impl IntoIterator<Item = DmaBufPlane>, acquire_fence: Option<OwnedFd>, ) -> DmaBufHandle
Build a handle from its planes.
planes is collected, so a caller need not name SmallVec to construct a handle (see
SurfaceFormatKind::plane_count for how many a format needs); acquire_fence is the producer’s
optional sync_file.
Sourcepub fn with_chroma(self, chroma: ChromaReconstruction) -> DmaBufHandle
pub fn with_chroma(self, chroma: ChromaReconstruction) -> DmaBufHandle
Ask the renderer to reconstruct this buffer’s chroma LumaGuided
rather than bilinearly. A hint: a renderer may ignore it.
Sourcepub fn with_color_space(self, color_space: YuvColorSpace) -> DmaBufHandle
pub fn with_color_space(self, color_space: YuvColorSpace) -> DmaBufHandle
Declare the colour space this buffer’s YCbCr bytes are in. A hint: a renderer that does not understand the matrix or range falls back to its default (BT.601 full range).
Sourcepub fn with_release(self, release: OwnedFd) -> DmaBufHandle
pub fn with_release(self, release: OwnedFd) -> DmaBufHandle
Give the renderer a descriptor to signal once it has finished with this buffer, so a producer
that recycles the surface behind it can wait rather than guess. See Self::release.
Sourcepub fn signal_release(&self)
pub fn signal_release(&self)
Signal the release descriptor, telling the producer the buffer is finished with — what the renderer does once it has sampled the buffer, for a consumer that took a frame and then dropped it without ever painting it.
A no-op where the handle carries no descriptor. The descriptor is shared, so the signal goes through a duplicate rather than consuming it.
Sourcepub fn plane_count(&self) -> usize
pub fn plane_count(&self) -> usize
The number of planes the handle carries, which SurfaceFormatKind::plane_count should agree
with.
Trait Implementations§
Source§impl Clone for DmaBufHandle
impl Clone for DmaBufHandle
Source§fn clone(&self) -> DmaBufHandle
fn clone(&self) -> DmaBufHandle
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 DmaBufHandle
impl Debug for DmaBufHandle
impl Eq for DmaBufHandle
Source§impl From<DmaBufHandle> for SurfaceSource
Available on Linux only.
impl From<DmaBufHandle> for SurfaceSource
Source§fn from(handle: DmaBufHandle) -> SurfaceSource
fn from(handle: DmaBufHandle) -> SurfaceSource
Auto Trait Implementations§
impl Freeze for DmaBufHandle
impl RefUnwindSafe for DmaBufHandle
impl Send for DmaBufHandle
impl Sync for DmaBufHandle
impl Unpin for DmaBufHandle
impl UnsafeUnpin for DmaBufHandle
impl UnwindSafe for DmaBufHandle
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,
Source§impl<T> CustomStyleProperty for T
impl<T> CustomStyleProperty for T
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any so CustomStyles::get can recover the concrete type.Source§fn eq_property(&self, other: &(dyn CustomStyleProperty + 'static)) -> bool
fn eq_property(&self, other: &(dyn CustomStyleProperty + 'static)) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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