Skip to main content

HalFence

Trait HalFence 

Source
pub trait HalFence:
    Send
    + Sync
    + 'static {
    // Required methods
    fn is_signaled(&self) -> Result<bool>;
    fn wait(&self, timeout: Duration) -> Result<bool>;

    // Provided method
    fn export_sync_file(&self) -> Result<OwnedFd> { ... }
}
Expand description

A signal that GPU work has completed.

This is the second of the two requirements that exist in the HAL from day one for the sake of the DRM path. Explicit sync is the design center of the frame loop: on the DRM path the render-done primitive is exported as a sync_file fd and attached to the atomic commit as IN_FENCE_FD, so the kernel latches the flip when the fence signals. Neither glFinish nor vkDeviceWaitIdle belongs in the frame loop on any path.

Backing primitives differ per backend — Vulkan fences, GLsync objects, sync_file fds — and the fence waiter thread retires all of them uniformly.

Required Methods§

Source

fn is_signaled(&self) -> Result<bool>

Whether the fence has signaled, without blocking.

Source

fn wait(&self, timeout: Duration) -> Result<bool>

Block until the fence signals or the timeout elapses.

Returns Ok(true) on signal and Ok(false) on timeout, so an expected timeout is not an error. A caller that treats timeout as fatal checks the returned value.

Provided Methods§

Source

fn export_sync_file(&self) -> Result<OwnedFd>

Export as a sync_file fd for a consumer outside this process.

Returns crate::Error::Unsupported where the driver cannot export. Callers check crate::SyncSupport::export_sync_file first and fall back to a CPU-side wait before commit — correct, slower, and worth logging loudly, since on Tier-1 hardware it is a driver bug to chase rather than a state to settle into.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl HalFence for Infallible

A fence for a backend that cannot submit without waiting.

Uninhabited, so every method is unreachable: no value can exist to call one on. That is a stronger statement than a type whose methods return errors, which would be constructible and could reach a caller expecting a real fence.

Source§

fn is_signaled(&self) -> Result<bool>

Source§

fn wait(&self, _timeout: Duration) -> Result<bool>

Implementors§