pub struct Instance {
name: String,
instance_per_backend: Vec<(Backend, Box<dyn DynInstance>)>,
requested_backends: Backends,
supported_backends: Backends,
pub flags: InstanceFlags,
}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: BackendsThe backends that were requested by the user.
supported_backends: BackendsThe 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: InstanceFlagsImplementations§
Source§impl Instance
impl Instance
pub fn new(name: &str, instance_desc: &InstanceDescriptor) -> Self
Sourcefn try_add_hal<A: Api>(&mut self, _: A, instance_desc: &InstanceDescriptor)
fn try_add_hal<A: Api>(&mut self, _: A, instance_desc: &InstanceDescriptor)
Helper for Instance::new(); attempts to add a single wgpu-hal backend to this instance.
pub(crate) fn from_hal_instance<A: Api>( name: String, hal_instance: <A as Api>::Instance, ) -> Self
pub fn raw(&self, backend: Backend) -> Option<&dyn DynInstance>
Sourcepub unsafe fn as_hal<A: Api>(&self) -> Option<&A::Instance>
pub unsafe fn as_hal<A: Api>(&self) -> Option<&A::Instance>
§Safety
- The raw instance handle returned must not be manually destroyed.
Sourcepub unsafe fn create_surface(
&self,
display_handle: RawDisplayHandle,
window_handle: RawWindowHandle,
) -> Result<Surface, CreateSurfaceError>
pub unsafe fn create_surface( &self, display_handle: 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_handlemust be a valid object to create a surface upon.window_handlemust remain valid as long as the returnedSurfaceIdis being used.