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§
Required Methods§
Sourceunsafe fn create_buffer(
&self,
desc: &BufferDescriptor<'_>,
) -> Result<<Self::A as Api>::Buffer, DeviceError>
unsafe fn create_buffer( &self, desc: &BufferDescriptor<'_>, ) -> Result<<Self::A as Api>::Buffer, DeviceError>
Creates a new buffer.
The initial usage is BufferUses::empty()
.
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>,
Sourceunsafe fn create_texture(
&self,
desc: &TextureDescriptor<'_>,
) -> Result<<Self::A as Api>::Texture, DeviceError>
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
.
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)
Sourceunsafe fn create_command_encoder(
&self,
desc: &CommandEncoderDescriptor<'_, Self::A>,
) -> Result<<Self::A as Api>::CommandEncoder, DeviceError>
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.
unsafe fn destroy_command_encoder(&self, pool: <Self::A as Api>::CommandEncoder)
Sourceunsafe fn create_bind_group_layout(
&self,
desc: &BindGroupLayoutDescriptor<'_>,
) -> Result<<Self::A as Api>::BindGroupLayout, DeviceError>
unsafe fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor<'_>, ) -> Result<<Self::A as Api>::BindGroupLayout, DeviceError>
Creates a bind group layout.
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>
Sourceunsafe fn wait(
&self,
fence: &<Self::A as Api>::Fence,
value: FenceValue,
timeout_ms: u32,
) -> Result<bool, DeviceError>
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.
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, )
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.