Instance

Struct Instance 

Source
pub struct Instance {
    _name: String,
    instance_per_backend: Vec<(Backend, Box<dyn DynInstance>)>,
    requested_backends: Backends,
    supported_backends: Backends,
    pub flags: InstanceFlags,
    display: Option<Box<dyn WgpuHasDisplayHandle>>,
    devices: InstanceDevices,
}

Fields§

§_name: String§instance_per_backend: Vec<(Backend, Box<dyn DynInstance>)>

List of instances per wgpu-hal backend.

The ordering in this list implies prioritization and needs to be preserved.

§requested_backends: Backends

The backends that were requested by the user.

§supported_backends: Backends

The backends that we could have attempted to obtain from wgpu-hal — those for which support is compiled in, currently.

The union of this and requested_backends is the set of backends that would be used, independent of whether accessing the drivers/hardware for them succeeds. To obtain the set of backends actually in use by this instance, check instance_per_backend instead.

§flags: InstanceFlags§display: Option<Box<dyn WgpuHasDisplayHandle>>

Non-lifetimed [raw_window_handle::DisplayHandle], for keepalive and validation purposes in Self::create_surface().

When used with winit, callers are expected to pass its OwnedDisplayHandle (created from the EventLoop) here.

§devices: InstanceDevices

Keeps track of all devices created from this instance, so that they can be polled.

Implementations§

Source§

impl Instance

Source

pub fn new( name: &str, instance_desc: InstanceDescriptor, telemetry: Option<Telemetry>, ) -> Self

Source

fn try_add_hal<A: Api>( &mut self, _: A, instance_desc: &InstanceDescriptor, telemetry: Option<Telemetry>, )

Helper for Instance::new(); attempts to add a single wgpu-hal backend to this instance.

Source

pub(crate) fn from_hal_instance<A: Api>( name: String, hal_instance: <A as Api>::Instance, ) -> Self

Source

pub fn raw(&self, backend: Backend) -> Option<&dyn DynInstance>

Source

pub unsafe fn as_hal<A: Api>(&self) -> Option<&A::Instance>

§Safety
  • The raw instance handle returned must not be manually destroyed.
Source

pub unsafe fn create_surface( &self, display_handle: Option<RawDisplayHandle>, window_handle: RawWindowHandle, ) -> Result<Surface, CreateSurfaceError>

Creates a new surface targeting the given display/window handles.

Internally attempts to create hal surfaces for all enabled backends.

Fails only if creation for surfaces for all enabled backends fails in which case the error for each enabled backend is listed. Vice versa, if creation for any backend succeeds, success is returned. Surface creation errors are logged to the debug log in any case.

§Safety
  • display_handle must be a valid object to create a surface upon, falls back to the instance display handle otherwise.
  • window_handle must remain valid as long as the returned SurfaceId is being used.
Source

fn adapter_allowed(&self, raw: &DynExposedAdapter) -> bool

Source

pub fn enumerate_adapters( &self, backends: Backends, apply_limit_buckets: bool, ) -> Vec<Arc<Adapter>>

Source

pub fn request_adapter( &self, desc: &RequestAdapterOptions<&Surface>, backends: Backends, ) -> Result<Arc<Adapter>, RequestAdapterError>

Source

fn adjust_limits_for_indirect_validation(&self, limits: &mut Limits)

This is similar to wgpu-hal’s adjust_raw_limits but tailored to wgpu-core’s constraints.

Source

fn active_backends(&self) -> Backends

Source

pub unsafe fn create_adapter_from_hal( &self, hal_adapter: DynExposedAdapter, ) -> Arc<Adapter>

Create an adapter from a HAL adapter.

The HAL adapter may be obtained e.g. by calling enumerate_adapters on the HAL directly.

If limit bucketing is desired, crate::limits::apply_limit_buckets should be called with the HAL adapter before calling this function.

§Safety

hal_adapter must be created from this global internal instance handle.

Source

pub fn poll_all_devices(&self, force_wait: bool) -> Result<bool, WaitIdleError>

Poll all devices on all backends.

This is the implementation of wgpu::Instance::poll_all.

Return all_queue_empty indicating whether there are more queue submissions still in flight.

Trait Implementations§

Source§

impl Default for Instance

Source§

fn default() -> Instance

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,