Struct InstanceDescriptor

Source
pub struct InstanceDescriptor {
    pub backends: Backends,
    pub flags: InstanceFlags,
    pub memory_budget_thresholds: MemoryBudgetThresholds,
    pub backend_options: BackendOptions,
}
Expand description

Options for creating an instance.

If you want to allow control of instance settings via environment variables, call either InstanceDescriptor::from_env_or_default() or InstanceDescriptor::with_env(). Each type within this descriptor has its own equivalent methods, so you can select which options you want to expose to influence from the environment.

Fields§

§backends: Backends

Which Backends to enable.

Backends::BROWSER_WEBGPU has an additional effect: If it is set and a navigator.gpu object is present, this instance will only be able to create WebGPU adapters.

⚠️ On some browsers this check is insufficient to determine whether WebGPU is supported, as the browser may define the navigator.gpu object, but be unable to create any WebGPU adapters. For targeting both WebGPU & WebGL, it is recommended to use crate::util::new_instance_with_webgpu_detection.

If you instead want to force use of WebGL, either disable the webgpu compile-time feature or don’t include the Backends::BROWSER_WEBGPU flag in this field. If it is set and WebGPU support is not detected, the instance will use wgpu-core to create adapters, meaning that if the webgl feature is enabled, it is able to create a WebGL adapter.

§flags: InstanceFlags

Flags to tune the behavior of the instance.

§memory_budget_thresholds: MemoryBudgetThresholds

Memory budget thresholds used by some backends.

§backend_options: BackendOptions

Options the control the behavior of specific backends.

Implementations§

Source§

impl InstanceDescriptor

Source

pub fn from_env_or_default() -> InstanceDescriptor

Choose instance options entirely from environment variables.

This is equivalent to calling from_env on every field.

Source

pub fn with_env(self) -> InstanceDescriptor

Takes the given options, modifies them based on the environment variables, and returns the result.

This is equivalent to calling with_env on every field.

Trait Implementations§

Source§

impl Clone for InstanceDescriptor

Source§

fn clone(&self) -> InstanceDescriptor

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InstanceDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for InstanceDescriptor

Source§

fn default() -> InstanceDescriptor

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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>

Source§

impl<T> CommonTraits for T
where T: AsAny + Any + Debug + WasmNotSendSync,

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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