wgpu_hal

Trait Device

Source
pub trait Device: WasmNotSendSync {
    type A: Api;

Show 39 methods // Required methods unsafe fn exit(self, queue: <Self::A as Api>::Queue); unsafe fn create_buffer( &self, desc: &BufferDescriptor<'_>, ) -> Result<<Self::A as Api>::Buffer, DeviceError>; unsafe fn destroy_buffer(&self, buffer: <Self::A as Api>::Buffer); unsafe fn map_buffer( &self, buffer: &<Self::A as Api>::Buffer, range: MemoryRange, ) -> Result<BufferMapping, DeviceError>; unsafe fn unmap_buffer( &self, buffer: &<Self::A as Api>::Buffer, ) -> Result<(), DeviceError>; unsafe fn flush_mapped_ranges<I>( &self, buffer: &<Self::A as Api>::Buffer, ranges: I, ) where I: Iterator<Item = MemoryRange>; unsafe fn invalidate_mapped_ranges<I>( &self, buffer: &<Self::A as Api>::Buffer, ranges: I, ) where I: Iterator<Item = MemoryRange>; unsafe fn create_texture( &self, desc: &TextureDescriptor<'_>, ) -> Result<<Self::A as Api>::Texture, DeviceError>; unsafe fn destroy_texture(&self, texture: <Self::A as Api>::Texture); unsafe fn create_texture_view( &self, texture: &<Self::A as Api>::Texture, desc: &TextureViewDescriptor<'_>, ) -> Result<<Self::A as Api>::TextureView, DeviceError>; unsafe fn destroy_texture_view(&self, view: <Self::A as Api>::TextureView); unsafe fn create_sampler( &self, desc: &SamplerDescriptor<'_>, ) -> Result<<Self::A as Api>::Sampler, DeviceError>; unsafe fn destroy_sampler(&self, sampler: <Self::A as Api>::Sampler); unsafe fn create_command_encoder( &self, desc: &CommandEncoderDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::CommandEncoder, DeviceError>; unsafe fn destroy_command_encoder( &self, pool: <Self::A as Api>::CommandEncoder, ); unsafe fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor<'_>, ) -> Result<<Self::A as Api>::BindGroupLayout, DeviceError>; unsafe fn destroy_bind_group_layout( &self, bg_layout: <Self::A as Api>::BindGroupLayout, ); unsafe fn create_pipeline_layout( &self, desc: &PipelineLayoutDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::PipelineLayout, DeviceError>; unsafe fn destroy_pipeline_layout( &self, pipeline_layout: <Self::A as Api>::PipelineLayout, ); unsafe fn create_bind_group( &self, desc: &BindGroupDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::BindGroup, DeviceError>; unsafe fn destroy_bind_group(&self, group: <Self::A as Api>::BindGroup); unsafe fn create_shader_module( &self, desc: &ShaderModuleDescriptor<'_>, shader: ShaderInput<'_>, ) -> Result<<Self::A as Api>::ShaderModule, ShaderError>; unsafe fn destroy_shader_module( &self, module: <Self::A as Api>::ShaderModule, ); unsafe fn create_render_pipeline( &self, desc: &RenderPipelineDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::RenderPipeline, PipelineError>; unsafe fn destroy_render_pipeline( &self, pipeline: <Self::A as Api>::RenderPipeline, ); unsafe fn create_compute_pipeline( &self, desc: &ComputePipelineDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::ComputePipeline, PipelineError>; unsafe fn destroy_compute_pipeline( &self, pipeline: <Self::A as Api>::ComputePipeline, ); unsafe fn create_query_set( &self, desc: &QuerySetDescriptor<Label<'_>>, ) -> Result<<Self::A as Api>::QuerySet, DeviceError>; unsafe fn destroy_query_set(&self, set: <Self::A as Api>::QuerySet); unsafe fn create_fence( &self, ) -> Result<<Self::A as Api>::Fence, DeviceError>; unsafe fn destroy_fence(&self, fence: <Self::A as Api>::Fence); unsafe fn get_fence_value( &self, fence: &<Self::A as Api>::Fence, ) -> Result<FenceValue, DeviceError>; unsafe fn wait( &self, fence: &<Self::A as Api>::Fence, value: FenceValue, timeout_ms: u32, ) -> Result<bool, DeviceError>; unsafe fn start_capture(&self) -> bool; unsafe fn stop_capture(&self); unsafe fn create_acceleration_structure( &self, desc: &AccelerationStructureDescriptor<'_>, ) -> Result<<Self::A as Api>::AccelerationStructure, DeviceError>; unsafe fn get_acceleration_structure_build_sizes( &self, desc: &GetAccelerationStructureBuildSizesDescriptor<'_, Self::A>, ) -> AccelerationStructureBuildSizes; unsafe fn get_acceleration_structure_device_address( &self, acceleration_structure: &<Self::A as Api>::AccelerationStructure, ) -> BufferAddress; unsafe fn destroy_acceleration_structure( &self, acceleration_structure: <Self::A as Api>::AccelerationStructure, );
}

Required Associated Types§

Source

type A: Api

Required Methods§

Source

unsafe fn exit(self, queue: <Self::A as Api>::Queue)

Exit connection to this logical device.

Source

unsafe fn create_buffer( &self, desc: &BufferDescriptor<'_>, ) -> Result<<Self::A as Api>::Buffer, DeviceError>

Creates a new buffer.

The initial usage is BufferUses::empty().

Source

unsafe fn destroy_buffer(&self, buffer: <Self::A as Api>::Buffer)

Source

unsafe fn map_buffer( &self, buffer: &<Self::A as Api>::Buffer, range: MemoryRange, ) -> Result<BufferMapping, DeviceError>

Source

unsafe fn unmap_buffer( &self, buffer: &<Self::A as Api>::Buffer, ) -> Result<(), DeviceError>

Source

unsafe fn flush_mapped_ranges<I>( &self, buffer: &<Self::A as Api>::Buffer, ranges: I, )
where I: Iterator<Item = MemoryRange>,

Source

unsafe fn invalidate_mapped_ranges<I>( &self, buffer: &<Self::A as Api>::Buffer, ranges: I, )
where I: Iterator<Item = MemoryRange>,

Source

unsafe fn create_texture( &self, desc: &TextureDescriptor<'_>, ) -> Result<<Self::A as Api>::Texture, DeviceError>

Creates a new texture.

The initial usage for all subresources is TextureUses::UNINITIALIZED.

Source

unsafe fn destroy_texture(&self, texture: <Self::A as Api>::Texture)

Source

unsafe fn create_texture_view( &self, texture: &<Self::A as Api>::Texture, desc: &TextureViewDescriptor<'_>, ) -> Result<<Self::A as Api>::TextureView, DeviceError>

Source

unsafe fn destroy_texture_view(&self, view: <Self::A as Api>::TextureView)

Source

unsafe fn create_sampler( &self, desc: &SamplerDescriptor<'_>, ) -> Result<<Self::A as Api>::Sampler, DeviceError>

Source

unsafe fn destroy_sampler(&self, sampler: <Self::A as Api>::Sampler)

Source

unsafe fn create_command_encoder( &self, desc: &CommandEncoderDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::CommandEncoder, DeviceError>

Create a fresh CommandEncoder.

The new CommandEncoder is in the “closed” state.

Source

unsafe fn destroy_command_encoder(&self, pool: <Self::A as Api>::CommandEncoder)

Source

unsafe fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor<'_>, ) -> Result<<Self::A as Api>::BindGroupLayout, DeviceError>

Creates a bind group layout.

Source

unsafe fn destroy_bind_group_layout( &self, bg_layout: <Self::A as Api>::BindGroupLayout, )

Source

unsafe fn create_pipeline_layout( &self, desc: &PipelineLayoutDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::PipelineLayout, DeviceError>

Source

unsafe fn destroy_pipeline_layout( &self, pipeline_layout: <Self::A as Api>::PipelineLayout, )

Source

unsafe fn create_bind_group( &self, desc: &BindGroupDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::BindGroup, DeviceError>

Source

unsafe fn destroy_bind_group(&self, group: <Self::A as Api>::BindGroup)

Source

unsafe fn create_shader_module( &self, desc: &ShaderModuleDescriptor<'_>, shader: ShaderInput<'_>, ) -> Result<<Self::A as Api>::ShaderModule, ShaderError>

Source

unsafe fn destroy_shader_module(&self, module: <Self::A as Api>::ShaderModule)

Source

unsafe fn create_render_pipeline( &self, desc: &RenderPipelineDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::RenderPipeline, PipelineError>

Source

unsafe fn destroy_render_pipeline( &self, pipeline: <Self::A as Api>::RenderPipeline, )

Source

unsafe fn create_compute_pipeline( &self, desc: &ComputePipelineDescriptor<'_, Self::A>, ) -> Result<<Self::A as Api>::ComputePipeline, PipelineError>

Source

unsafe fn destroy_compute_pipeline( &self, pipeline: <Self::A as Api>::ComputePipeline, )

Source

unsafe fn create_query_set( &self, desc: &QuerySetDescriptor<Label<'_>>, ) -> Result<<Self::A as Api>::QuerySet, DeviceError>

Source

unsafe fn destroy_query_set(&self, set: <Self::A as Api>::QuerySet)

Source

unsafe fn create_fence(&self) -> Result<<Self::A as Api>::Fence, DeviceError>

Source

unsafe fn destroy_fence(&self, fence: <Self::A as Api>::Fence)

Source

unsafe fn get_fence_value( &self, fence: &<Self::A as Api>::Fence, ) -> Result<FenceValue, DeviceError>

Source

unsafe fn wait( &self, fence: &<Self::A as Api>::Fence, value: FenceValue, timeout_ms: u32, ) -> Result<bool, DeviceError>

Wait for fence to reach value.

Operations like Queue::submit can accept a Fence and a FenceValue to store in it, so you can use this wait function to wait for a given queue submission to finish execution.

The value argument must be a value that some actual operation you have already presented to the device is going to store in fence. You cannot wait for values yet to be submitted. (This restriction accommodates implementations like the vulkan backend’s FencePool that must allocate a distinct synchronization object for each fence value one is able to wait for.)

Calling wait with a lower FenceValue than fence’s current value returns immediately.

Source

unsafe fn start_capture(&self) -> bool

Source

unsafe fn stop_capture(&self)

Source

unsafe fn create_acceleration_structure( &self, desc: &AccelerationStructureDescriptor<'_>, ) -> Result<<Self::A as Api>::AccelerationStructure, DeviceError>

Source

unsafe fn get_acceleration_structure_build_sizes( &self, desc: &GetAccelerationStructureBuildSizesDescriptor<'_, Self::A>, ) -> AccelerationStructureBuildSizes

Source

unsafe fn get_acceleration_structure_device_address( &self, acceleration_structure: &<Self::A as Api>::AccelerationStructure, ) -> BufferAddress

Source

unsafe fn destroy_acceleration_structure( &self, acceleration_structure: <Self::A as Api>::AccelerationStructure, )

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Device for Context

Source§

type A = Api

Source§

impl Device for wgpu_hal::gles::Device

Available on gles only.
Source§

type A = Api

Source§

impl Device for wgpu_hal::vulkan::Device

Available on vulkan only.
Source§

type A = Api