pub struct Device { /* private fields */ }Expand description
An initialized native device. Clones share the process-owned device.
§Thread affinity
The native device table is thread-affine: enumerate once per thread and keep the device, its
allocator and every network that uses them on that thread. Devices coordinate process-owned
runtime state, so a device is not Send or Sync.
Implementations§
Source§impl Device
impl Device
Sourcepub fn enumerate() -> Result<Vec<DeviceInfo>>
pub fn enumerate() -> Result<Vec<DeviceInfo>>
Enumerates available devices without silently substituting the CPU backend.
The order is the native one and matches the index Device::new accepts. An empty vector
means no driver or ICD is visible, which is a missing capability rather than an empty device
list to fall back from.
Sourcepub fn new(index: usize) -> Result<Self>
pub fn new(index: usize) -> Result<Self>
Selects one device by index after validating it.
An index the driver does not expose returns Error::Unsupported.
The native device outlives this handle: every network that selects it keeps a reference.
Sourcepub fn default_device() -> Result<Self>
pub fn default_device() -> Result<Self>
Sourcepub fn info(&self) -> DeviceInfo
pub fn info(&self) -> DeviceInfo
Returns the copied device metadata.
The values are read once per call, so later driver-side changes are not observed.
Source§impl Device
impl Device
Sourcepub fn heap_budget_mib(&self) -> usize
pub fn heap_budget_mib(&self) -> usize
Reports the native device-wide heap budget in MiB, not application usage.
Sourcepub fn raw_device_handle(&self) -> u64
pub fn raw_device_handle(&self) -> u64
Returns the borrowed native VkDevice handle. This does not transfer ownership.
Sourcepub fn save_pipeline_cache(&self, path: impl AsRef<Path>) -> Result<()>
pub fn save_pipeline_cache(&self, path: impl AsRef<Path>) -> Result<()>
Serializes native compatibility metadata, shaders, and Vulkan pipeline data.
Sourcepub fn pipeline_cache(&self) -> Result<Vec<u8>>
pub fn pipeline_cache(&self) -> Result<Vec<u8>>
Returns the serialized pipeline cache for storage outside the file system.
The bytes are what save_pipeline_cache writes, so a caller can
keep them in memory, in an archive or in another process’s transport.
Sourcepub fn load_pipeline_cache(&self, path: impl AsRef<Path>) -> Result<()>
pub fn load_pipeline_cache(&self, path: impl AsRef<Path>) -> Result<()>
Rejects incompatible or corrupted native cache headers and payload hashes.
Sourcepub fn set_pipeline_cache(&self, data: &[u8]) -> Result<()>
pub fn set_pipeline_cache(&self, data: &[u8]) -> Result<()>
Loads a serialized pipeline cache produced by pipeline_cache.