Struct Device

Source
pub struct Device { /* private fields */ }
Expand description

Open connection to a graphics and/or compute device.

Responsible for the creation of most rendering and compute resources. These are then used in commands, which are submitted to a Queue.

A device may be requested from an adapter with Adapter::request_device.

Implementations§

Source§

impl Device

Source

pub fn poll(&self, maintain: Maintain)

Check for resource cleanups and mapping callbacks.

no-op on the web, device is automatically polled.

Source

pub fn features(&self) -> Features

List all features that may be used with this device.

Functions may panic if you use unsupported features.

Source

pub fn limits(&self) -> Limits

List all limits that were requested of this device.

If any of these limits are exceeded, functions may panic.

Source

pub fn create_shader_module( &self, source: ShaderModuleSource<'_>, ) -> ShaderModule

Creates a shader module from either SPIR-V or WGSL source code.

Source

pub fn create_command_encoder( &self, desc: &CommandEncoderDescriptor<'_>, ) -> CommandEncoder

Creates an empty CommandEncoder.

Source

pub fn create_render_bundle_encoder( &self, desc: &RenderBundleEncoderDescriptor<'_>, ) -> RenderBundleEncoder<'_>

Creates an empty RenderBundleEncoder.

Source

pub fn create_bind_group(&self, desc: &BindGroupDescriptor<'_>) -> BindGroup

Creates a new BindGroup.

Source

pub fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor<'_>, ) -> BindGroupLayout

Creates a BindGroupLayout.

Source

pub fn create_pipeline_layout( &self, desc: &PipelineLayoutDescriptor<'_>, ) -> PipelineLayout

Creates a PipelineLayout.

Source

pub fn create_render_pipeline( &self, desc: &RenderPipelineDescriptor<'_>, ) -> RenderPipeline

Creates a RenderPipeline.

Source

pub fn create_compute_pipeline( &self, desc: &ComputePipelineDescriptor<'_>, ) -> ComputePipeline

Creates a ComputePipeline.

Source

pub fn create_buffer(&self, desc: &BufferDescriptor<'_>) -> Buffer

Creates a Buffer.

Source

pub fn create_buffer_with_data(&self, data: &[u8], usage: BufferUsage) -> Buffer

Creates a new buffer, maps it into host-visible memory, copies data from the given slice, and finally unmaps it, returning a Buffer.

Source

pub fn create_texture(&self, desc: &TextureDescriptor<'_>) -> Texture

Creates a new Texture.

desc specifies the general format of the texture.

Source

pub fn create_sampler(&self, desc: &SamplerDescriptor<'_>) -> Sampler

Creates a new Sampler.

desc specifies the behavior of the sampler.

Source

pub fn create_swap_chain( &self, surface: &Surface, desc: &SwapChainDescriptor, ) -> SwapChain

Create a new SwapChain which targets surface.

§Panics
  • A old SwapChainFrame is still alive referencing an old swapchain.
  • Texture format requested is unsupported on the swap chain.

Trait Implementations§

Source§

impl Drop for Device

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl !RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl !UnwindSafe for Device

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.