pub struct Device { /* private fields */ }
Expand description
Represents a Vulkan context.
Implementations§
Source§impl Device
impl Device
Sourcepub fn new(
physical_device: Arc<PhysicalDevice>,
create_info: DeviceCreateInfo,
) -> Result<(Arc<Device>, impl ExactSizeIterator<Item = Arc<Queue>>), Validated<VulkanError>>
pub fn new( physical_device: Arc<PhysicalDevice>, create_info: DeviceCreateInfo, ) -> Result<(Arc<Device>, impl ExactSizeIterator<Item = Arc<Queue>>), Validated<VulkanError>>
Creates a new Device
.
Sourcepub unsafe fn from_handle(
physical_device: Arc<PhysicalDevice>,
handle: Device,
create_info: DeviceCreateInfo,
) -> (Arc<Device>, impl ExactSizeIterator<Item = Arc<Queue>>)
pub unsafe fn from_handle( physical_device: Arc<PhysicalDevice>, handle: Device, create_info: DeviceCreateInfo, ) -> (Arc<Device>, impl ExactSizeIterator<Item = Arc<Queue>>)
Creates a new Device
from a raw object handle.
§Safety
handle
must be a valid Vulkan object handle created fromphysical_device
.create_info
must match the info used to create the object.
Sourcepub fn api_version(&self) -> Version
pub fn api_version(&self) -> Version
Returns the Vulkan version supported by the device.
This is the lower of the
physical device’s supported version
and the instance’s max_api_version
.
Sourcepub fn fns(&self) -> &DeviceFunctions
pub fn fns(&self) -> &DeviceFunctions
Returns pointers to the raw Vulkan functions of the device.
Sourcepub fn physical_device(&self) -> &Arc<PhysicalDevice>
pub fn physical_device(&self) -> &Arc<PhysicalDevice>
Returns the physical device that was used to create this device.
Sourcepub fn physical_devices(&self) -> &[Arc<PhysicalDevice>]
pub fn physical_devices(&self) -> &[Arc<PhysicalDevice>]
Returns the list of physical devices that was used to create this device. The index of each physical device in this list is its device index.
This always contains the physical device returned by physical_device
.
Sourcepub fn device_mask(&self) -> u32
pub fn device_mask(&self) -> u32
Returns a device mask containing all physical devices in this device. In other words: every bit that corresponds to a physical device in this device is set to 1.
Sourcepub fn active_queue_family_indices(&self) -> &[u32]
pub fn active_queue_family_indices(&self) -> &[u32]
Returns the queue family indices that this device uses.
Sourcepub fn enabled_extensions(&self) -> &DeviceExtensions
pub fn enabled_extensions(&self) -> &DeviceExtensions
Returns the extensions that have been enabled on the device.
This includes both the extensions specified in DeviceCreateInfo::enabled_extensions
,
and any extensions that are required by those extensions.
Sourcepub fn enabled_features(&self) -> &DeviceFeatures
pub fn enabled_features(&self) -> &DeviceFeatures
Returns the features that have been enabled on the device.
This includes both the features specified in DeviceCreateInfo::enabled_features
,
and any features that are required by the enabled extensions.
Sourcepub fn allocation_count(&self) -> u32
pub fn allocation_count(&self) -> u32
Returns the current number of active DeviceMemory
allocations the device has.
Sourcepub fn acceleration_structure_build_sizes(
&self,
build_type: AccelerationStructureBuildType,
build_info: &AccelerationStructureBuildGeometryInfo,
max_primitive_counts: &[u32],
) -> Result<AccelerationStructureBuildSizesInfo, Box<ValidationError>>
pub fn acceleration_structure_build_sizes( &self, build_type: AccelerationStructureBuildType, build_info: &AccelerationStructureBuildGeometryInfo, max_primitive_counts: &[u32], ) -> Result<AccelerationStructureBuildSizesInfo, Box<ValidationError>>
For the given acceleration structure build info and primitive counts, returns the minimum size required to build the acceleration structure, and the minimum size of the scratch buffer used during the build operation.
Sourcepub fn acceleration_structure_is_compatible(
&self,
version_data: &[u8; 32],
) -> Result<bool, Box<ValidationError>>
pub fn acceleration_structure_is_compatible( &self, version_data: &[u8; 32], ) -> Result<bool, Box<ValidationError>>
Returns whether a serialized acceleration structure with the specified version data is compatible with this device.
Sourcepub fn descriptor_set_layout_support(
&self,
create_info: &DescriptorSetLayoutCreateInfo,
) -> Result<Option<DescriptorSetLayoutSupport>, Box<ValidationError>>
pub fn descriptor_set_layout_support( &self, create_info: &DescriptorSetLayoutCreateInfo, ) -> Result<Option<DescriptorSetLayoutSupport>, Box<ValidationError>>
Returns whether a descriptor set layout with the given create_info
could be created
on the device, and additional supported properties where relevant. Some
is returned if
the descriptor set layout is supported, None
if it is not.
This is primarily useful for checking whether the device supports a descriptor set layout
that goes beyond the max_per_set_descriptors
limit. A layout that does not exceed
that limit is guaranteed to be supported, otherwise this function can be called.
The device API version must be at least 1.1, or the khr_maintenance3
extension must
be enabled on the device.
Sourcepub fn buffer_memory_requirements(
&self,
create_info: BufferCreateInfo,
) -> Result<MemoryRequirements, Box<ValidationError>>
pub fn buffer_memory_requirements( &self, create_info: BufferCreateInfo, ) -> Result<MemoryRequirements, Box<ValidationError>>
Returns the memory requirements that would apply for a buffer created with the specified
create_info
.
The device API version must be at least 1.3, or the khr_maintenance4
extension must
be enabled on the device.
Sourcepub fn image_memory_requirements(
&self,
create_info: ImageCreateInfo,
plane: Option<usize>,
) -> Result<MemoryRequirements, Box<ValidationError>>
pub fn image_memory_requirements( &self, create_info: ImageCreateInfo, plane: Option<usize>, ) -> Result<MemoryRequirements, Box<ValidationError>>
Returns the memory requirements that would apply for an image created with the specified
create_info
.
If create_info.flags
contains ImageCreateFlags::DISJOINT
, then plane
must specify
the plane number of the format or memory plane (depending on tiling) that memory
requirements will be returned for. Otherwise, plane
must be None
.
The device API version must be at least 1.3, or the khr_maintenance4
extension must
be enabled on the device.
Sourcepub unsafe fn memory_fd_properties(
&self,
handle_type: ExternalMemoryHandleType,
file: File,
) -> Result<MemoryFdProperties, Validated<VulkanError>>
pub unsafe fn memory_fd_properties( &self, handle_type: ExternalMemoryHandleType, file: File, ) -> Result<MemoryFdProperties, Validated<VulkanError>>
Retrieves the properties of an external file descriptor when imported as a given external handle type.
An error will be returned if the
khr_external_memory_fd
extension was not
enabled on the device, or if handle_type
is ExternalMemoryHandleType::OpaqueFd
.
§Safety
file
must be a handle to external memory that was created outside the Vulkan API.
Sourcepub fn set_debug_utils_object_name<T: VulkanObject + DeviceOwned>(
&self,
object: &T,
object_name: Option<&str>,
) -> Result<(), VulkanError>
pub fn set_debug_utils_object_name<T: VulkanObject + DeviceOwned>( &self, object: &T, object_name: Option<&str>, ) -> Result<(), VulkanError>
Assigns a human-readable name to object
for debugging purposes.
If object_name
is None
, a previously set object name is removed.
§Panics
- If
object
is not owned by this device.
Sourcepub unsafe fn wait_idle(&self) -> Result<(), VulkanError>
pub unsafe fn wait_idle(&self) -> Result<(), VulkanError>
Waits until all work on this device has finished. You should never need to call this function, but it can be useful for debugging or benchmarking purposes.
Note: This is the Vulkan equivalent of OpenGL’s
glFinish
.
§Safety
This function is not thread-safe. You must not submit anything to any of the queue of the device (either explicitly or implicitly, for example with a future’s destructor) while this function is waiting.