Skip to main content

AcquiredBuffer

Struct AcquiredBuffer 

Source
pub struct AcquiredBuffer {
    pub fb_id: u32,
    pub token: u64,
    pub acquire_fence: Option<SyncFence>,
    pub damage: Vec<DamageRect>,
}
Expand description

A buffer handed over by LayerBufferSource::acquire, valid until the matching release.

Move-only, because it carries an owned fence. That is load-bearing: it means the two-deep release queue cannot hand a buffer back early by accident — doing so is a move, and using it afterwards does not compile. Invariant 1’s ownership half is enforced by the type; only its timing half needs a test.

Releasing a buffer and then using it is a compile error, which is the whole point:

ⓘ
fn release(_buffer: AcquiredBuffer) {}

let buffer = AcquiredBuffer { fb_id: 1, ..AcquiredBuffer::default() };
release(buffer);
// The buffer is back with its source now; the display engine may already
// have stopped scanning it out. Reading it here would be exactly the
// use-after-release invariant 1 exists to prevent.
assert_eq!(buffer.fb_id, 1);

Ordinary moves are of course fine:

let buffer = AcquiredBuffer { fb_id: 1, ..AcquiredBuffer::default() };
let moved = buffer;
assert_eq!(moved.fb_id, 1);

Fields§

§fb_id: u32

The DRM framebuffer the scene will write to the plane’s FB_ID.

Non-zero for a BindingModel::SceneSubmitsFbId source. Zero for BindingModel::DriverOwnsBinding, where the scene skips the write.

§token: u64

A source-private token echoed back verbatim to release — typically a slot index in a ring.

The C++ carries a void* here. A u64 covers every in-tree use (all of them store an index) without inviting a raw pointer into a type that crosses the source boundary.

§acquire_fence: Option<SyncFence>

An optional render-done fence: the pixels are valid only once it signals.

Set it when the producer renders asynchronously rather than CPU-blocking before returning. The scene takes ownership: where the assigned plane advertises IN_FENCE_FD it hands the descriptor to KMS so the kernel waits before scanout; otherwise it waits on the CPU before committing. Either way the fence rides this buffer’s lifecycle and closes on release or drop — the kernel does not take ownership of IN_FENCE_FD.

Sources that produce ready buffers synchronously leave this None.

§damage: Vec<DamageRect>

Per-frame dirty regions.

Empty means full-frame — the scene emits no FB_DAMAGE_CLIPS and assumes everything changed, which is correct but not power-optimal. A non-empty list names the changed regions; the scene falls back to full-frame above 16 rectangles, clips each to the buffer and drops any left empty, and omits the blob entirely on planes or drivers without the property.

Trait Implementations§

Source§

impl Debug for AcquiredBuffer

Source§

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

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

impl Default for AcquiredBuffer

Source§

fn default() -> Self

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

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.