pub struct WgpuRenderer { /* private fields */ }Implementations§
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn new<W>(
gpu_context: GpuContext,
window: &W,
config: WgpuSurfaceConfig,
compositor_gpu: Option<CompositorGpuHint>,
) -> Result<Self>
pub fn new<W>( gpu_context: GpuContext, window: &W, config: WgpuSurfaceConfig, compositor_gpu: Option<CompositorGpuHint>, ) -> Result<Self>
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.
pub fn update_drawable_size(&mut self, size: Size<DevicePixels>)
pub fn set_subpixel_layout(&mut self, is_bgr: bool)
pub fn update_transparency(&mut self, transparent: bool)
pub fn viewport_size(&self) -> Size<DevicePixels>
pub fn sprite_atlas(&self) -> &Arc<WgpuAtlas> ⓘ
pub fn supports_dual_source_blending(&self) -> bool
pub fn gpu_specs(&self) -> GpuSpecs
pub fn max_texture_size(&self) -> u32
pub fn draw(&mut self, scene: &Scene) -> bool
Sourcepub fn unconfigure_surface(&mut self)
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.
Sourcepub fn replace_surface<W: HasWindowHandle>(
&mut self,
window: &W,
config: WgpuSurfaceConfig,
instance: &Instance,
) -> Result<()>
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.
pub fn destroy(&mut self)
Sourcepub fn device_lost(&self) -> bool
pub fn device_lost(&self) -> bool
Returns true if the GPU device was lost and recovery is needed.
Sourcepub fn needs_redraw(&mut self) -> bool
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.
Sourcepub fn recover<W>(&mut self, window: &W) -> Result<()>
pub fn recover<W>(&mut self, window: &W) -> Result<()>
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§
impl !Freeze for WgpuRenderer
impl !RefUnwindSafe for WgpuRenderer
impl !Send for WgpuRenderer
impl !Sync for WgpuRenderer
impl !UnwindSafe for WgpuRenderer
impl Unpin for WgpuRenderer
impl UnsafeUnpin for WgpuRenderer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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