pub struct GpuContext { /* private fields */ }Expand description
The main GPU context holding the instance, adapter, device, queue, and surface.
Implementations§
Source§impl GpuContext
impl GpuContext
Sourcepub async fn new(window: &Window) -> Result<Self>
pub async fn new(window: &Window) -> Result<Self>
Create a new GPU context for the given window.
This is an async operation as it requires requesting the GPU adapter and device.
§Errors
Returns an error if:
- No suitable GPU adapter could be found
- The GPU device could not be requested
- The surface could not be created
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Resize the surface to a new size.
Call this when the window is resized.
Sourcepub fn get_current_texture(&self) -> Result<SurfaceTexture>
pub fn get_current_texture(&self) -> Result<SurfaceTexture>
Get the current surface texture for rendering.
§Errors
Returns an error if the surface texture could not be acquired.
Sourcepub fn surface_format(&self) -> TextureFormat
pub fn surface_format(&self) -> TextureFormat
Get the surface texture format.
Sourcepub fn surface_size(&self) -> (u32, u32)
pub fn surface_size(&self) -> (u32, u32)
Get the current surface size.
Sourcepub fn adapter_info(&self) -> AdapterInfo
pub fn adapter_info(&self) -> AdapterInfo
Get the adapter info.
Sourcepub fn create_command_encoder(&self) -> CommandEncoder
pub fn create_command_encoder(&self) -> CommandEncoder
Create a command encoder for recording GPU commands.
Sourcepub fn submit<I: IntoIterator<Item = CommandBuffer>>(&self, commands: I)
pub fn submit<I: IntoIterator<Item = CommandBuffer>>(&self, commands: I)
Submit command buffers to the GPU queue.
Auto Trait Implementations§
impl !Freeze for GpuContext
impl !RefUnwindSafe for GpuContext
impl !UnwindSafe for GpuContext
impl Send for GpuContext
impl Sync for GpuContext
impl Unpin for GpuContext
impl UnsafeUnpin for GpuContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.