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
impl Device
Sourcepub fn poll(&self, maintain: Maintain)
pub fn poll(&self, maintain: Maintain)
Check for resource cleanups and mapping callbacks.
no-op on the web, device is automatically polled.
Sourcepub fn features(&self) -> Features
pub fn features(&self) -> Features
List all features that may be used with this device.
Functions may panic if you use unsupported features.
Sourcepub fn limits(&self) -> Limits
pub fn limits(&self) -> Limits
List all limits that were requested of this device.
If any of these limits are exceeded, functions may panic.
Sourcepub fn create_shader_module(
&self,
source: ShaderModuleSource<'_>,
) -> ShaderModule
pub fn create_shader_module( &self, source: ShaderModuleSource<'_>, ) -> ShaderModule
Creates a shader module from either SPIR-V or WGSL source code.
Sourcepub fn create_command_encoder(
&self,
desc: &CommandEncoderDescriptor<'_>,
) -> CommandEncoder
pub fn create_command_encoder( &self, desc: &CommandEncoderDescriptor<'_>, ) -> CommandEncoder
Creates an empty CommandEncoder
.
Sourcepub fn create_render_bundle_encoder(
&self,
desc: &RenderBundleEncoderDescriptor<'_>,
) -> RenderBundleEncoder<'_>
pub fn create_render_bundle_encoder( &self, desc: &RenderBundleEncoderDescriptor<'_>, ) -> RenderBundleEncoder<'_>
Creates an empty RenderBundleEncoder
.
Sourcepub fn create_bind_group(&self, desc: &BindGroupDescriptor<'_>) -> BindGroup
pub fn create_bind_group(&self, desc: &BindGroupDescriptor<'_>) -> BindGroup
Creates a new BindGroup
.
Sourcepub fn create_bind_group_layout(
&self,
desc: &BindGroupLayoutDescriptor<'_>,
) -> BindGroupLayout
pub fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor<'_>, ) -> BindGroupLayout
Creates a BindGroupLayout
.
Sourcepub fn create_pipeline_layout(
&self,
desc: &PipelineLayoutDescriptor<'_>,
) -> PipelineLayout
pub fn create_pipeline_layout( &self, desc: &PipelineLayoutDescriptor<'_>, ) -> PipelineLayout
Creates a PipelineLayout
.
Sourcepub fn create_render_pipeline(
&self,
desc: &RenderPipelineDescriptor<'_>,
) -> RenderPipeline
pub fn create_render_pipeline( &self, desc: &RenderPipelineDescriptor<'_>, ) -> RenderPipeline
Creates a RenderPipeline
.
Sourcepub fn create_compute_pipeline(
&self,
desc: &ComputePipelineDescriptor<'_>,
) -> ComputePipeline
pub fn create_compute_pipeline( &self, desc: &ComputePipelineDescriptor<'_>, ) -> ComputePipeline
Creates a ComputePipeline
.
Sourcepub fn create_buffer(&self, desc: &BufferDescriptor<'_>) -> Buffer
pub fn create_buffer(&self, desc: &BufferDescriptor<'_>) -> Buffer
Creates a Buffer
.
Sourcepub fn create_buffer_with_data(&self, data: &[u8], usage: BufferUsage) -> Buffer
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
.
Sourcepub fn create_texture(&self, desc: &TextureDescriptor<'_>) -> Texture
pub fn create_texture(&self, desc: &TextureDescriptor<'_>) -> Texture
Creates a new Texture
.
desc
specifies the general format of the texture.
Sourcepub fn create_sampler(&self, desc: &SamplerDescriptor<'_>) -> Sampler
pub fn create_sampler(&self, desc: &SamplerDescriptor<'_>) -> Sampler
Creates a new Sampler
.
desc
specifies the behavior of the sampler.
Sourcepub fn create_swap_chain(
&self,
surface: &Surface,
desc: &SwapChainDescriptor,
) -> SwapChain
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.