Struct wgpu::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.

Corresponds to WebGPU GPUDevice.

Implementations§

Check for resource cleanups and mapping callbacks.

Return true if the queue is empty, or false if there are more queue submissions still in flight. (Note that, unless access to the Queue is coordinated somehow, this information could be out of date by the time the caller receives it. Queues can be shared between threads, so other threads could submit new work at any time.)

On the web, this is a no-op. Devices are automatically polled.

List all features that may be used with this device.

Functions may panic if you use unsupported features.

List all limits that were requested of this device.

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

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

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

Safety

In contrast with create_shader_module this function creates a shader module without runtime checks which allows shaders to perform operations which can lead to undefined behavior like indexing out of bounds, thus it’s the caller responsibility to pass a shader which doesn’t perform any of this operations.

This has no effect on web.

Creates a shader module from SPIR-V binary directly.

Safety

This function passes binary data to the backend as-is and can potentially result in a driver crash or bogus behaviour. No attempt is made to ensure that data is valid SPIR-V.

See also include_spirv_raw! and util::make_spirv_raw.

Creates an empty CommandEncoder.

Creates an empty RenderBundleEncoder.

Creates a new BindGroup.

Creates a BindGroupLayout.

Creates a PipelineLayout.

Creates a RenderPipeline.

Creates a ComputePipeline.

Creates a Buffer.

Creates a new Texture.

desc specifies the general format of the texture.

Available on non-WebAssembly or crate feature emscripten or crate feature webgl only.

Creates a Texture from a wgpu-hal Texture.

Safety
  • hal_texture must be created from this device internal handle
  • hal_texture must be created respecting desc
  • hal_texture must be initialized

Creates a new Sampler.

desc specifies the behavior of the sampler.

Creates a new QuerySet.

Set a callback for errors that are not handled in error scopes.

Push an error scope.

Pop an error scope.

Starts frame capture.

Stops frame capture.

Available on non-WebAssembly or crate feature emscripten only.

Apply a callback to this Device’s underlying backend device.

If this Device is implemented by the backend API given by A (Vulkan, Dx12, etc.), then apply hal_device_callback to Some(&device), where device is the underlying backend device type, A::Device.

If this Device uses a different backend, apply hal_device_callback to None.

The device is locked for reading while hal_device_callback runs. If the callback attempts to perform any wgpu operations that require write access to the device (destroying a buffer, say), deadlock will occur. The locks are automatically released when the callback returns.

Safety
  • The raw handle passed to the callback must not be manually destroyed.

Trait Implementations§

Formats the value using the given formatter. Read more
Creates a Buffer with data to initialize it.
Upload an entire texture and its mipmaps from a source buffer. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.