wgpu_core::instance

Struct Instance

Source
pub struct Instance {
    pub name: String,
    pub instance_per_backend: Vec<(Backend, Box<dyn DynInstance>)>,
    pub flags: InstanceFlags,
}

Fields§

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

List of instances per backend.

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

§flags: InstanceFlags

Implementations§

Source§

impl Instance

Source

pub fn new(name: &str, instance_desc: InstanceDescriptor) -> Self

Source

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

Source

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

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

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

Available on crate feature raw-window-handle only.

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.
  • window_handle must remain valid as long as the returned SurfaceId is being used.
Source

pub unsafe fn create_surface_from_visual( &self, visual: *mut c_void, ) -> Result<Surface, CreateSurfaceError>

Available on dx12 only.
§Safety

The visual must be valid and able to be used to make a swapchain with.

Source

pub unsafe fn create_surface_from_surface_handle( &self, surface_handle: *mut c_void, ) -> Result<Surface, CreateSurfaceError>

Available on dx12 only.
§Safety

The surface_handle must be valid and able to be used to make a swapchain with.

Source

pub unsafe fn create_surface_from_swap_chain_panel( &self, swap_chain_panel: *mut c_void, ) -> Result<Surface, CreateSurfaceError>

Available on dx12 only.
§Safety

The swap_chain_panel must be valid and able to be used to make a swapchain with.

Source

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

Source

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

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

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

Source§

impl<T> WasmNotSendSync for T

Source§

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