Skip to main content

Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

Handle to abstract device that can execute graphics, compute and ray-tracing pipelines.

Implementations§

Source§

impl Device

Source

pub fn graphics(&self) -> &'static Graphics

Returns Graphics associated with the device instance.

Source

pub fn downgrade(&self) -> WeakDevice

Returns weak reference to this device.

Source

pub fn create_buffer(&self, info: BufferInfo) -> Result<Buffer, OutOfMemory>

Creates buffer with uninitialized content.

Source

pub fn create_mappable_buffer( &self, info: BufferInfo, memory_usage: MemoryUsage, ) -> Result<MappableBuffer, OutOfMemory>

Creates buffer with uninitialized content.

Source

pub fn create_buffer_static<T>( &self, info: BufferInfo, data: &[T], ) -> Result<Buffer, OutOfMemory>
where T: Pod + 'static,

Creates static buffer pre-initialized with content from [data]. Implies MemoryUsage::Device.

§Panics

Function will panic if specified buffer size does not equal data size. i.e. if info.size != std::mem::size_of(data).

Source

pub fn create_buffer_view( &self, info: BufferViewInfo, ) -> Result<BufferView, OutOfMemory>

Source

pub fn create_image(&self, info: ImageInfo) -> Result<Image, OutOfMemory>

Creates image with uninitialized content.

Source

pub fn create_image_view( &self, info: ImageViewInfo, ) -> Result<ImageView, OutOfMemory>

Creates view to an image.

Source

pub fn create_fence(&self) -> Result<Fence, OutOfMemory>

Returns handle to newly created Fence. Fences are create in un-signaled state.

Source

pub fn create_framebuffer( &self, info: FramebufferInfo, ) -> Result<Framebuffer, OutOfMemory>

Returns handle to newly created Framebuffer.

Source

pub fn create_graphics_pipeline( &self, info: GraphicsPipelineInfo, ) -> Result<GraphicsPipeline, OutOfMemory>

Creates graphics pipeline.

Source

pub fn create_compute_pipeline( &self, info: ComputePipelineInfo, ) -> Result<ComputePipeline, OutOfMemory>

Creates compute pipeline.

Source

pub fn create_pipeline_layout( &self, info: PipelineLayoutInfo, ) -> Result<PipelineLayout, OutOfMemory>

Creates pipeline layout.

Source

pub fn create_render_pass( &self, info: RenderPassInfo, ) -> Result<RenderPass, CreateRenderPassError>

Creates render pass.

Source

pub fn create_semaphore(&self) -> Result<Semaphore, OutOfMemory>

Creates semaphore. Semaphores are created in unsignaled state.

Source

pub fn create_shader_module( &self, info: ShaderModuleInfo, ) -> Result<ShaderModule, CreateShaderModuleError>

Creates new shader module from shader’s code.

Source

pub fn create_surface( &self, window: &impl HasRawWindowHandle, display: &impl HasRawDisplayHandle, ) -> Result<Surface, CreateSurfaceError>

Creates surface for specified window.

Source

pub fn reset_fences(&self, fences: &mut [&mut Fence]) -> Result<(), DeviceLost>

Resets fences. All specified fences must be in signalled state. Fences are moved into unsignalled state.

Source

pub fn is_fence_signalled(&self, fence: &mut Fence) -> Result<bool, DeviceLost>

Checks if fence is in signalled state.

Source

pub fn wait_fences( &self, fences: &mut [&mut Fence], all: bool, ) -> Result<(), DeviceLost>

Wait for fences to become signaled. If all is true - waits for all specified fences to become signaled. Otherwise waits for at least on of specified fences to become signaled. May return immediately if all fences are already signaled (or at least one is signaled if all == false). Fences are signaled by Queues. See Queue::submit.

Source

pub fn wait_idle(&self) -> Result<(), DeviceLost>

Wait for whole device to become idle. That is, wait for all pending operations to complete. This is equivalent to calling Queue::wait_idle for all queues. Typically used only before device destruction.

Source

pub fn get_acceleration_structure_build_sizes( &self, level: AccelerationStructureLevel, flags: AccelerationStructureBuildFlags, geometry: &[AccelerationStructureGeometryInfo], ) -> AccelerationStructureBuildSizesInfo

Returns memory size requirements for accelelration structure build operations.

Source

pub fn create_acceleration_structure( &self, info: AccelerationStructureInfo, ) -> Result<AccelerationStructure, OutOfMemory>

Creates acceleration structure.

§Panics

This method may panic if Feature::RayTracing wasn’t enabled.

Source

pub fn get_buffer_device_address( &self, buffer: &Buffer, ) -> Option<DeviceAddress>

Returns buffers device address.

Source

pub fn get_acceleration_structure_device_address( &self, acceleration_structure: &AccelerationStructure, ) -> DeviceAddress

Returns device address of acceleration strucutre.

Source

pub fn create_ray_tracing_pipeline( &self, info: RayTracingPipelineInfo, ) -> Result<RayTracingPipeline, OutOfMemory>

Creates ray-tracing pipeline.

Source

pub fn create_descriptor_set_layout( &self, info: DescriptorSetLayoutInfo, ) -> Result<DescriptorSetLayout, OutOfMemory>

Source

pub fn create_descriptor_set( &self, info: DescriptorSetInfo, ) -> Result<WritableDescriptorSet, DescriptorsAllocationError>

Source

pub fn update_descriptor_sets<'a>( &self, updates: &mut [UpdateDescriptorSet<'a>], )

Source

pub fn create_sampler(&self, info: SamplerInfo) -> Result<Sampler, OutOfMemory>

Source

pub fn create_shader_binding_table( &self, pipeline: &RayTracingPipeline, info: ShaderBindingTableInfo<'_>, ) -> Result<ShaderBindingTable, OutOfMemory>

Source

pub fn map_memory( &self, buffer: &mut MappableBuffer, offset: u64, size: usize, ) -> Result<&mut [MaybeUninit<u8>], MapError>

Source

pub fn unmap_memory(&self, buffer: &mut MappableBuffer) -> bool

Source

pub fn upload_to_memory<T>( &self, buffer: &mut MappableBuffer, offset: u64, data: &[T], ) -> Result<(), MapError>
where T: Pod,

Source

pub fn write_buffer<T>( &self, buffer: &mut MappableBuffer, offset: u64, data: &[T], ) -> Result<(), MapError>
where T: Pod,

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq<Device> for &Device

Source§

fn eq(&self, weak: &Device) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<WeakDevice> for &Device

Source§

fn eq(&self, weak: &WeakDevice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<WeakDevice> for Device

Source§

fn eq(&self, weak: &WeakDevice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Device

Source§

fn eq(&self, weak: &Device) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,