Skip to main content

WgpuRenderer

Struct WgpuRenderer 

Source
pub struct WgpuRenderer { /* private fields */ }

Implementations§

Source§

impl WgpuRenderer

Source

pub fn new<W>( gpu_context: GpuContext, window: &W, config: WgpuSurfaceConfig, compositor_gpu: Option<CompositorGpuHint>, ) -> Result<Self>
where W: HasWindowHandle + HasDisplayHandle + Debug + Send + Sync + Clone + 'static,

Creates a new WgpuRenderer from raw window handles.

The gpu_context is a shared reference that coordinates GPU context across multiple windows. The first window to create a renderer will initialize the context; subsequent windows will share it.

§Safety

The caller must ensure that the window handle remains valid for the lifetime of the returned renderer.

Source

pub fn update_drawable_size(&mut self, size: Size<DevicePixels>)

Source

pub fn set_subpixel_layout(&mut self, is_bgr: bool)

Source

pub fn update_transparency(&mut self, transparent: bool)

Source

pub fn viewport_size(&self) -> Size<DevicePixels>

Source

pub fn sprite_atlas(&self) -> &Arc<WgpuAtlas>

Source

pub fn supports_dual_source_blending(&self) -> bool

Source

pub fn gpu_specs(&self) -> GpuSpecs

Source

pub fn max_texture_size(&self) -> u32

Source

pub fn draw(&mut self, scene: &Scene) -> bool

Source

pub fn unconfigure_surface(&mut self)

Mark the surface as unconfigured so rendering is skipped until a new surface is provided via replace_surface.

This does not drop the renderer — the device, queue, atlas, and pipelines stay alive. Use this when the native window is destroyed (e.g. Android TerminateWindow) but you intend to re-create the surface later without losing cached atlas textures.

Source

pub fn replace_surface<W: HasWindowHandle>( &mut self, window: &W, config: WgpuSurfaceConfig, instance: &Instance, ) -> Result<()>

Replace the wgpu surface with a new one (e.g. after Android destroys and recreates the native window). Keeps the device, queue, atlas, and all pipelines intact so cached AtlasTextureIds remain valid.

The instance must be the same wgpu::Instance that was used to create the adapter and device (i.e. from the WgpuContext). Using a different instance will cause a “Device does not exist” panic because the wgpu device is bound to its originating instance.

Source

pub fn destroy(&mut self)

Source

pub fn device_lost(&self) -> bool

Returns true if the GPU device was lost and recovery is needed.

Source

pub fn needs_redraw(&mut self) -> bool

Returns true if a redraw is needed because GPU state was cleared. Calling this method clears the flag.

Source

pub fn recover<W>(&mut self, window: &W) -> Result<()>
where W: HasWindowHandle + HasDisplayHandle + Debug + Send + Sync + Clone + 'static,

Recovers from a lost GPU device by recreating the renderer with a new context.

Call this after detecting device_lost() returns true.

This method coordinates recovery across multiple windows:

  • The first window to call this will recreate the shared context
  • Subsequent windows will adopt the already-recovered context

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more