Struct RenderContext
pub struct RenderContext {
pub instance: Instance,
pub devices: Vec<DeviceHandle>,
/* private fields */
}Expand description
wgpu state for one process, with a memory hint that fits a shared GPU.
Fields§
§instance: Instance§devices: Vec<DeviceHandle>Implementations§
§impl RenderContext
impl RenderContext
pub fn new() -> RenderContext
pub fn new() -> RenderContext
A context on the backends WGPU_BACKEND names, or this platform’s
default_backends. WGPU_BACKEND stays available for explicit
diagnostics and alternate drivers, and is never second-guessed.
pub async fn device(
&mut self,
compatible_surface: Option<&Surface<'_>>,
) -> Option<usize>
pub async fn device( &mut self, compatible_surface: Option<&Surface<'_>>, ) -> Option<usize>
Index of a device that can present to compatible_surface, opening one
if none of the existing devices can.
pub async fn create_surface<'w>(
&mut self,
window: impl Into<SurfaceTarget<'w>>,
width: u32,
height: u32,
present_mode: PresentMode,
) -> Result<RenderSurface<'w>, CreateSurfaceError>
pub async fn create_surface<'w>( &mut self, window: impl Into<SurfaceTarget<'w>>, width: u32, height: u32, present_mode: PresentMode, ) -> Result<RenderSurface<'w>, CreateSurfaceError>
A surface for window, rendered at width x height.
§Errors
Returns CreateSurfaceError::Surface if wgpu cannot create a surface for
window, CreateSurfaceError::NoCompatibleDevice if no adapter can present
to it, or CreateSurfaceError::UnsupportedSurfaceFormat if the surface
offers neither Rgba8Unorm nor Bgra8Unorm.
pub async fn create_surface_unconfigured<'w>(
&mut self,
window: impl Into<SurfaceTarget<'w>>,
width: u32,
height: u32,
present_mode: PresentMode,
) -> Result<RenderSurface<'w>, CreateSurfaceError>
pub async fn create_surface_unconfigured<'w>( &mut self, window: impl Into<SurfaceTarget<'w>>, width: u32, height: u32, present_mode: PresentMode, ) -> Result<RenderSurface<'w>, CreateSurfaceError>
Build a surface and render targets without creating its swapchain.
A caller that adjusts alpha or other configuration must configure the returned surface before acquiring a frame. Native windows do that once inside their existing validation error scope.
§Errors
Returns the same surface, device and format errors as Self::create_surface.
pub fn resize_surface(
&self,
surface: &mut RenderSurface<'_>,
width: u32,
height: u32,
)
pub fn resize_surface( &self, surface: &mut RenderSurface<'_>, width: u32, height: u32, )
§Panics
If width or height is zero.
pub fn configure_surface(&self, surface: &RenderSurface<'_>)
Trait Implementations§
§impl Default for RenderContext
impl Default for RenderContext
§fn default() -> RenderContext
fn default() -> RenderContext
Auto Trait Implementations§
impl Freeze for RenderContext
impl !RefUnwindSafe for RenderContext
impl Send for RenderContext
impl Sync for RenderContext
impl Unpin for RenderContext
impl UnsafeUnpin for RenderContext
impl !UnwindSafe for RenderContext
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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