Skip to main content

OverlaySurface

Struct OverlaySurface 

Source
pub struct OverlaySurface { /* private fields */ }
Expand description

A translucent swapchain above a hosted native view, drawing one command range of the frame — see the module docs for the host contract.

Implementations§

Source§

impl OverlaySurface

Source

pub unsafe fn new( ctx: &mut RenderContext, main: Option<&SurfaceRenderer>, target: OverlayTarget, width: u32, height: u32, ) -> Result<Self, OverlayError>

Creates the overlay’s swapchain on target, configured translucent at width x height physical pixels, sharing ctx’s device and queue.

main is the main surface’s renderer when there is one; the overlay then compiles its pipelines through the same persisted driver cache.

§Safety

The one unsafe crossing of this module (a sanctioned zone, like frust_gpu::lifecycle::create_android_surface): target must name a valid, live platform object — an acquired ANativeWindow* behind an Android NDK handle, a valid display/window pair, or a live CAMetalLayer* — that outlives the returned OverlaySurface and every frame it acquires. Drop the OverlaySurface before releasing the window or tearing down the layer.

§Errors

OverlayError::NoDevice before the main surface created the device; OverlayError::Surface when the platform object yields no surface or the swapchain cannot be configured; OverlayError::UnsupportedSurface when the shared adapter cannot present to it; OverlayError::NoTranslucentMode/OverlayError::StraightAlpha for an alpha mode the overlay cannot use; OverlayError::Engine when the overlay’s renderer cannot be built.

Source

pub fn size(&self) -> (u32, u32)

The swapchain’s (width, height) in physical pixels.

Source

pub fn resize(&mut self, width: u32, height: u32)

Resizes the swapchain (physical pixels); a zero extent is ignored, and an un-presented frame of the old size is dropped.

Source

pub fn record( &mut self, encoder: &mut CommandEncoder, scene: &Scene, range: Range<usize>, ) -> Result<OverlayFrame, OverlayError>

Acquires the overlay’s next frame and records the commands of scene in range into it over a transparent clear — into the caller’s encoder, so the overlay’s passes land in the same command buffer as the main frame’s and one queue submit carries both (the segmented frame, SurfaceRenderer::submit_segmented).

Nothing is submitted and nothing is presentable yet: the acquired frame waits, recorded, until Self::end_frame is told whether the encoder was submitted — then (and only then) it becomes the frame Self::present/Self::take_deferred_present hand out. A frame still waiting from an earlier call (presentable or merely recorded) is dropped un-presented first (latest wins).

OverlayFrame::Reconfigured/OverlayFrame::Skipped recorded nothing and leave nothing for Self::end_frame to close.

§Errors

OverlayError::Engine when the engine refuses the frame: the acquired frame is dropped and the renderer’s frame already closed, so there is nothing for Self::end_frame to do (the previous overlay frame stays on screen). Shader-quad pre-passes the overlay recorded ahead of the refusal stay in encoder, harmlessly — their targets are the overlay’s own.

Source

pub fn end_frame(&mut self, submitted: bool) -> bool

Closes the frame Self::record recorded, once the encoder it was recorded into has been submitted (submitted) or dropped: the renderer’s end-of-frame maintenance, and — when submitted — the recorded frame becomes the one Self::present presents. Answers whether a frame is now waiting to be presented; a no-op answering false when nothing was recorded.

Source

pub fn render( &mut self, scene: &Scene, range: Range<usize>, ) -> Result<OverlayFrame, OverlayError>

The spike’s path only — Self::record into an encoder of the overlay’s own, submitted on its own: a second queue submit per frame, which the segmented frame exists to remove (SurfaceRenderer::submit_segmented records every overlay into the main frame’s encoder and submits once). Kept for the single-cut spike host (FRUST_OVERLAY_SPIKE), which renders its overlay ahead of the main frame.

Leaves the frame un-presented until Self::present (or Self::take_deferred_present), so the host can land it right beside the main frame’s present. A frame still waiting from the last call is dropped un-presented first (latest wins).

§Errors

OverlayError::Engine when the engine refuses the frame (nothing is presented; the previous overlay frame stays on screen).

Source

pub fn present(&mut self) -> bool

Presents the frame Self::render (or a submitted Self::record) left waiting, on the calling thread; false when there was none.

Source

pub fn take_deferred_present(&mut self) -> Option<DeferredPresent>

Hands the waiting frame out as a DeferredPresent, for a host that presents the main frame and the overlay inside one platform transaction (iOS presentsWithTransaction); None when there was none.

Source

pub fn renderer(&self) -> &OverlayRenderer

The overlay’s renderer — its cut report, refusal count and GPU time.

Trait Implementations§

Source§

impl Debug for OverlaySurface

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,