pub struct Instance { /* private fields */ }Expand description
Context for all other wgpu objects. Instance of wgpu.
This is the first thing you create when using wgpu.
Its primary use is to create Adapters and Surfaces.
Does not have to be kept alive.
Corresponds to WebGPU GPU.
Implementations
sourceimpl Instance
impl Instance
sourcepub unsafe fn as_hal<A: HalApi, F: FnOnce(Option<&A::Instance>) -> R, R>(
&self,
hal_instance_callback: F
) -> R
pub unsafe fn as_hal<A: HalApi, F: FnOnce(Option<&A::Instance>) -> R, R>(
&self,
hal_instance_callback: F
) -> R
Returns the inner hal Instance using a callback. The hal instance will be None if the
backend type argument does not match with this wgpu Instance
Safety
- The raw handle obtained from the hal Instance must not be manually destroyed
sourcepub fn enumerate_adapters(
&self,
backends: Backends
) -> impl Iterator<Item = Adapter>
pub fn enumerate_adapters(
&self,
backends: Backends
) -> impl Iterator<Item = Adapter>
sourcepub fn request_adapter(
&self,
options: &RequestAdapterOptions<'_>
) -> impl Future<Output = Option<Adapter>> + Send
pub fn request_adapter(
&self,
options: &RequestAdapterOptions<'_>
) -> impl Future<Output = Option<Adapter>> + Send
Retrieves an Adapter which matches the given RequestAdapterOptions.
Some options are “soft”, so treated as non-mandatory. Others are “hard”.
If no adapters are found that suffice all the “hard” options, None is returned.
sourcepub unsafe fn create_adapter_from_hal<A: HalApi>(
&self,
hal_adapter: ExposedAdapter<A>
) -> Adapter
pub unsafe fn create_adapter_from_hal<A: HalApi>(
&self,
hal_adapter: ExposedAdapter<A>
) -> Adapter
sourcepub unsafe fn create_surface<W: HasRawWindowHandle>(
&self,
window: &W
) -> Surface
pub unsafe fn create_surface<W: HasRawWindowHandle>(
&self,
window: &W
) -> Surface
Creates a surface from a raw window handle.
Safety
- Raw Window Handle must be a valid object to create a surface upon and must remain valid for the lifetime of the returned surface.
- If not called on the main thread, metal backend will panic.
sourcepub fn poll_all(&self, force_wait: bool) -> bool
pub fn poll_all(&self, force_wait: bool) -> bool
Polls all devices.
If force_wait is true and this is not running on the web, then this
function will block until all in-flight buffers have been mapped and
all submitted commands have finished execution.
Return true if all devices’ queues are empty, or false if there are
queue submissions still in flight. (Note that, unless access to all
Queues associated with this Instance is coordinated somehow,
this information could be out of date by the time the caller receives
it. Queues can be shared between threads, and other threads could
submit new work at any time.)
On the web, this is a no-op. Devices are automatically polled.
sourcepub fn generate_report(&self) -> GlobalReport
pub fn generate_report(&self) -> GlobalReport
Generates memory report.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Instance
impl Send for Instance
impl Sync for Instance
impl Unpin for Instance
impl !UnwindSafe for Instance
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
