pub struct Device {
mem_allocator: Mutex<Allocator>,
desc_allocator: Mutex<DescriptorAllocator>,
valid_ash_memory_types: u32,
naga_options: Options<'static>,
counters: Arc<HalCounters>,
shared: Arc<DeviceShared>,
}Fields§
§mem_allocator: Mutex<Allocator>§desc_allocator: Mutex<DescriptorAllocator>§valid_ash_memory_types: u32§naga_options: Options<'static>§counters: Arc<HalCounters>Implementations§
Source§impl Device
impl Device
Sourcepub unsafe fn texture_from_raw(
&self,
vk_image: Image,
desc: &TextureDescriptor<'_>,
drop_callback: Option<DropCallback>,
memory: TextureMemory,
) -> Texture
pub unsafe fn texture_from_raw( &self, vk_image: Image, desc: &TextureDescriptor<'_>, drop_callback: Option<DropCallback>, memory: TextureMemory, ) -> Texture
§Safety
vk_imagemust be created respectingdesc- If
drop_callbackisNone, wgpu-hal will take ownership ofvk_image. Ifdrop_callbackisSome,vk_imagemust be valid until the callback is called. - If the
ImageCreateFlagsdoes not containMUTABLE_FORMAT, theview_formatsofdescmust be empty. - If
memoryis notsuper::TextureMemory::External, wgpu-hal will take ownership of the memory (which is presumed to backvk_image). Otherwise, the memory must remain valid untildrop_callbackis called.
fn find_memory_type_index( &self, type_bits_req: u32, flags_req: MemoryPropertyFlags, ) -> Option<usize>
fn create_image_without_memory( &self, desc: &TextureDescriptor<'_>, external_memory_image_create_info: Option<&mut ExternalMemoryImageCreateInfo<'_>>, ) -> Result<ImageWithoutMemory, DeviceError>
fn create_image_without_memory_with_tiling( &self, desc: &TextureDescriptor<'_>, tiling: ImageTiling, external_memory_image_create_info: Option<&mut ExternalMemoryImageCreateInfo<'_>>, drm_modifier_info: Option<&mut ImageDrmFormatModifierExplicitCreateInfoEXT<'_>>, ) -> Result<ImageWithoutMemory, DeviceError>
Sourcepub unsafe fn texture_from_dmabuf_fd(
&self,
fd: OwnedFd,
desc: &TextureDescriptor<'_>,
drm_modifier: u64,
stride: u64,
offset: u64,
) -> Result<Texture, DeviceError>
pub unsafe fn texture_from_dmabuf_fd( &self, fd: OwnedFd, desc: &TextureDescriptor<'_>, drm_modifier: u64, stride: u64, offset: u64, ) -> Result<Texture, DeviceError>
Import a DMA-buf as a texture. Currently only supports single-plane DMA-bufs.
§Safety
- Requires
VULKAN_EXTERNAL_MEMORY_DMA_BUFfeature (implies VK_EXT_external_memory_dma_buf and VK_EXT_image_drm_format_modifier) - The
fdmust be a valid DMA-buf file descriptor matchingdesc - On success, Vulkan takes ownership of the file descriptor. On failure, the file descriptor is closed.
- The
drm_modifier,stride, andoffsetmust match the DMA-buf layout
Sourcefn import_dmabuf_memory(
&self,
external_memory_fd_fn: &Device,
fd_raw: i32,
image: Image,
requirements: &MemoryRequirements,
) -> Result<DeviceMemory, DeviceError>
fn import_dmabuf_memory( &self, external_memory_fd_fn: &Device, fd_raw: i32, image: Image, requirements: &MemoryRequirements, ) -> Result<DeviceMemory, DeviceError>
Import DMA-buf memory and bind it to the image.
On failure, the raw fd is closed (if not yet consumed by Vulkan) and the caller is responsible for destroying the VkImage.
fn create_shader_module_impl( &self, spv: &[u32], label: &Label<'_>, ) -> Result<ShaderModule, DeviceError>
fn compile_stage( &self, stage: &ProgrammableStage<'_, ShaderModule>, naga_stage: ShaderStage, binding_map: &BindingMap, ) -> Result<CompiledStage, PipelineError>
Sourcepub fn queue_family_index(&self) -> u32
pub fn queue_family_index(&self) -> u32
Returns the queue family index of the device’s internal queue.
This is useful for constructing memory barriers needed for queue family ownership transfer when
external memory is involved (from/to VK_QUEUE_FAMILY_EXTERNAL_KHR and VK_QUEUE_FAMILY_FOREIGN_EXT
for example).
pub fn queue_index(&self) -> u32
pub fn raw_device(&self) -> &Device
pub fn raw_physical_device(&self) -> PhysicalDevice
pub fn raw_queue(&self) -> Queue
pub fn enabled_device_extensions(&self) -> &[&'static CStr]
fn get_memory_properties(&self) -> Option<MemoryProperties>
Sourcefn error_if_would_oom_on_resource_allocation(
&self,
location: MemoryLocation,
requirements: &MemoryRequirements,
) -> Result<(), DeviceError>
fn error_if_would_oom_on_resource_allocation( &self, location: MemoryLocation, requirements: &MemoryRequirements, ) -> Result<(), DeviceError>
Predict whether a proposed allocation will result in an OOM condition.
If so, returns Err(crate::DeviceError::OutOfMemory). If not, returns
Ok(()).
The prediction quality depends on accurately selecting the heap that
gpu_allocator will use for the allocation, and is subject to
deteriorate if the logic in gpu_allocator changes.
Trait Implementations§
Source§impl Device for Device
impl Device for Device
type A = Api
Source§unsafe fn create_buffer(
&self,
desc: &BufferDescriptor<'_>,
) -> Result<Buffer, DeviceError>
unsafe fn create_buffer( &self, desc: &BufferDescriptor<'_>, ) -> Result<Buffer, DeviceError>
Source§unsafe fn destroy_buffer(&self, buffer: Buffer)
unsafe fn destroy_buffer(&self, buffer: Buffer)
buffer and any GPU resources it owns. Read moreSource§unsafe fn add_raw_buffer(&self, _buffer: &Buffer)
unsafe fn add_raw_buffer(&self, _buffer: &Buffer)
Source§unsafe fn map_buffer(
&self,
buffer: &Buffer,
range: MemoryRange,
) -> Result<BufferMapping, DeviceError>
unsafe fn map_buffer( &self, buffer: &Buffer, range: MemoryRange, ) -> Result<BufferMapping, DeviceError>
buffer. Read moreSource§unsafe fn unmap_buffer(&self, buffer: &Buffer)
unsafe fn unmap_buffer(&self, buffer: &Buffer)
Device::map_buffer. Read moreSource§unsafe fn flush_mapped_ranges<I>(&self, buffer: &Buffer, ranges: I)where
I: Iterator<Item = MemoryRange>,
unsafe fn flush_mapped_ranges<I>(&self, buffer: &Buffer, ranges: I)where
I: Iterator<Item = MemoryRange>,
Source§unsafe fn invalidate_mapped_ranges<I>(&self, buffer: &Buffer, ranges: I)where
I: Iterator<Item = MemoryRange>,
unsafe fn invalidate_mapped_ranges<I>(&self, buffer: &Buffer, ranges: I)where
I: Iterator<Item = MemoryRange>,
Source§unsafe fn create_texture(
&self,
desc: &TextureDescriptor<'_>,
) -> Result<Texture, DeviceError>
unsafe fn create_texture( &self, desc: &TextureDescriptor<'_>, ) -> Result<Texture, DeviceError>
unsafe fn destroy_texture(&self, texture: Texture)
Source§unsafe fn add_raw_texture(&self, _texture: &Texture)
unsafe fn add_raw_texture(&self, _texture: &Texture)
unsafe fn create_texture_view( &self, texture: &Texture, desc: &TextureViewDescriptor<'_>, ) -> Result<TextureView, DeviceError>
unsafe fn destroy_texture_view(&self, view: TextureView)
unsafe fn create_sampler( &self, desc: &SamplerDescriptor<'_>, ) -> Result<Sampler, DeviceError>
unsafe fn destroy_sampler(&self, sampler: Sampler)
Source§unsafe fn create_command_encoder(
&self,
desc: &CommandEncoderDescriptor<'_, Queue>,
) -> Result<CommandEncoder, DeviceError>
unsafe fn create_command_encoder( &self, desc: &CommandEncoderDescriptor<'_, Queue>, ) -> Result<CommandEncoder, DeviceError>
CommandEncoder. Read more