Skip to main content

Instance

Struct Instance 

Source
pub struct Instance {
    pub flags: InstanceFlags,
    /* private fields */
}

Fields§

§flags: InstanceFlags

Implementations§

Source§

impl Instance

Source

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

Source

pub fn from_hal_instance<A: Api>( name: String, hal_instance: <A as Api>::Instance, ) -> Arc<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<Arc<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 Surface is being used.
Source

pub unsafe fn create_surface_from_drm( &self, fd: i32, plane: u32, connector_id: u32, width: u32, height: u32, refresh_rate: u32, ) -> Result<Arc<Surface>, CreateSurfaceError>

Available on drm only.

Creates a new surface from the given drm configuration.

§Safety
  • All parameters must point to valid DRM values.
§Platform Support

This function requires the "drm" feature. It is only available on non-apple Unix-like platforms (Linux, FreeBSD) and currently only works with the Vulkan backend.

Source

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

Source

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

Returns a list of adapters that match the given request options and are compatible with the specified backends.

On success at least one compatible adapter will be returned in the resulting vector.

Source

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

Source

pub unsafe fn create_adapter_from_hal( self: &Arc<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() -> Self

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

Auto Trait Implementations§

§

impl !Freeze for Instance

§

impl !RefUnwindSafe for Instance

§

impl !UnwindSafe for Instance

§

impl Forget for Instance

§

impl Move for Instance

§

impl Send for Instance
where RawVecInner: Send, BoxRaw<dyn DynInstance>: Send, InternalBitFlags: Send, InternalBitFlags: Send, BoxRaw<dyn WgpuHasDisplayHandle>: Send, Mutex<RawMutex, WeakVec<Device>>: Send, InternalBitFlags: Send,

§

impl Sync for Instance
where RawVecInner: Sync, BoxRaw<dyn DynInstance>: Sync, InternalBitFlags: Sync, InternalBitFlags: Sync, BoxRaw<dyn WgpuHasDisplayHandle>: Sync, Mutex<RawMutex, WeakVec<Device>>: Sync, InternalBitFlags: Sync,

§

impl Unpin for Instance
where *const u8 is !null: Unpin, Box<dyn DynInstance>: Unpin, InternalBitFlags: Unpin, InternalBitFlags: Unpin, Box<dyn WgpuHasDisplayHandle>: Unpin, Align1<u8>: Unpin, *const ArcInner<Device> is !null: Unpin, InternalBitFlags: Unpin,

§

impl UnsafeUnpin for Instance

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

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

Source§

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

Source§

impl<T> Downcast<T> for T

Source§

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> Upcast<T> for T

Source§

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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