pub struct Gpu { /* private fields */ }Expand description
wgpu device + surface bundle for one OS window.
Implementations§
Source§impl Gpu
impl Gpu
Sourcepub fn new(
target: impl Into<SurfaceTarget<'static>>,
size: (u32, u32),
config: GpuConfig,
) -> Result<Self, GpuInitError>
pub fn new( target: impl Into<SurfaceTarget<'static>>, size: (u32, u32), config: GpuConfig, ) -> Result<Self, GpuInitError>
Create the surface, adapter, device and queue for target (typically an
Arc<winit::window::Window>) and configure the swap chain at
size physical pixels, clamped by clamp_surface_size.
A non-sRGB surface format is preferred so the renderer’s colour maths — which writes linear-space values — isn’t gamma-corrected twice by the surface.
pub fn device(&self) -> &Arc<Device> ⓘ
pub fn queue(&self) -> &Arc<Queue> ⓘ
pub fn surface(&self) -> &Surface<'static>
pub fn surface_format(&self) -> TextureFormat
Sourcepub fn config(&self) -> &SurfaceConfiguration
pub fn config(&self) -> &SurfaceConfiguration
The live swap-chain configuration — width / height are the clamped
physical pixel size the shell should hand to layout and WgpuGfxCtx.
Sourcepub fn resize(&mut self, w: u32, h: u32)
pub fn resize(&mut self, w: u32, h: u32)
Reconfigure the swap chain for a new physical size. A zero-sized (minimized) window is ignored — there is no presentable surface then, and wgpu rejects a zero extent.
Sourcepub fn acquire_frame(&self, request_redraw: impl Fn()) -> Option<SurfaceTexture>
pub fn acquire_frame(&self, request_redraw: impl Fn()) -> Option<SurfaceTexture>
Acquire the next surface texture, recovering from a stale swapchain by reconfiguring and retrying once.
Returns None when the frame must be skipped. request_redraw is
invoked for the skip cases that can still recover on their own, so a
reactive event loop (ControlFlow::Wait) wakes up to try again instead
of idling forever; pass a closure that calls Window::request_redraw.
Auto Trait Implementations§
impl !Freeze for Gpu
impl !RefUnwindSafe for Gpu
impl !UnwindSafe for Gpu
impl Send for Gpu
impl Sync for Gpu
impl Unpin for Gpu
impl UnsafeUnpin for Gpu
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> 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