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,
pub transfer: TransferFunction,
}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.
transfer: TransferFunctionHow this buffer’s values relate to light. An RGB producer declares whether its bytes are sRGB-encoded or linear; for YCbCr it follows the matrix, and the default is the video curve.
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>,
) -> Self
pub fn new( width: u32, height: u32, format: SurfaceFormatKind, modifier: u64, planes: impl IntoIterator<Item = DmaBufPlane>, acquire_fence: Option<OwnedFd>, ) -> Self
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) -> Self
pub fn with_chroma(self, chroma: ChromaReconstruction) -> Self
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) -> Self
pub fn with_color_space(self, color_space: YuvColorSpace) -> Self
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_transfer(self, transfer: TransferFunction) -> Self
pub fn with_transfer(self, transfer: TransferFunction) -> Self
Declare how this buffer’s values relate to light. A hint, like the colour space: an RGB producer whose bytes are linear says so here, and the renderer encodes them for its sRGB-encoded targets. The default follows the format (sRGB for RGB, the video curve for YCbCr), so a producer with sRGB-encoded bytes need not call this.
Sourcepub fn with_release(self, release: OwnedFd) -> Self
pub fn with_release(self, release: OwnedFd) -> Self
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§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) -> Self
fn from(handle: DmaBufHandle) -> Self
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<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.