pub struct VulkanAccelerator { /* private fields */ }Implementations§
Source§impl VulkanAccelerator
impl VulkanAccelerator
Sourcepub fn new() -> Result<Self, InitError>
pub fn new() -> Result<Self, InitError>
Open the preferred Vulkan 1.3 compute device: discrete, integrated, virtual, then CPU.
Sourcepub fn with_device(device: &str) -> Result<Self, InitError>
pub fn with_device(device: &str) -> Result<Self, InitError>
Open the device whose enumerated name (available_devices) equals device.
Sourcepub fn with_device_options(
device: &str,
options: VulkanOptions,
) -> Result<Self, InitError>
pub fn with_device_options( device: &str, options: VulkanOptions, ) -> Result<Self, InitError>
with_device with explicit VulkanOptions.
Sourcepub fn available_devices() -> Result<Vec<String>, InitError>
pub fn available_devices() -> Result<Vec<String>, InitError>
Enumerate the names of every suitable device visible through the loader.
Sourcepub fn device_name(&self) -> &str
pub fn device_name(&self) -> &str
The enumerated name of the device this instance executes on.
Sourcepub fn is_poisoned(&self) -> bool
pub fn is_poisoned(&self) -> bool
Whether this instance observed device loss and refuses further work.
Sourcepub fn host_gate(&self) -> Result<VulkanHostGate, BackendError>
pub fn host_gate(&self) -> Result<VulkanHostGate, BackendError>
A new VulkanHostGate at value 0, or Unsupported without timeline semaphores.
Sourcepub fn submit_after(
&self,
queue: &VulkanQueue,
program: &VulkanProgram,
bindings: &[BindingRef<'_, VulkanBuffer>],
gate: &VulkanHostGate,
value: u64,
) -> Result<VulkanEvent, SubmitFailure<VulkanEvent>>
pub fn submit_after( &self, queue: &VulkanQueue, program: &VulkanProgram, bindings: &[BindingRef<'_, VulkanBuffer>], gate: &VulkanHostGate, value: u64, ) -> Result<VulkanEvent, SubmitFailure<VulkanEvent>>
Accelerator::submit, the work waiting on the device until gate reaches value
(ADR 0013). The bindings are held from now, as submit holds them, with one difference
the gate exists for: the bytes of the program’s input bindings may still be written
until the gate is raised to value (by host stores into an imported buffer, or by a
device’s DMA the host has seen complete), because raising the gate orders every host
operation before it ahead of the device’s wait. Outputs, and inputs after the raise,
follow submit’s rules.
Sourcepub fn host_import_alignment(&self) -> Option<u64>
pub fn host_import_alignment(&self) -> Option<u64>
The alignment import_host_buffer requires of a pointer and a
length, or None when the device cannot import host memory.
Sourcepub unsafe fn import_host_buffer(
&self,
context: &VulkanContext,
desc: BufferDesc,
memory: NonNull<u8>,
len: u64,
) -> Result<AllocatedBuffer<VulkanBuffer>, BackendError>
pub unsafe fn import_host_buffer( &self, context: &VulkanContext, desc: BufferDesc, memory: NonNull<u8>, len: u64, ) -> Result<AllocatedBuffer<VulkanBuffer>, BackendError>
A buffer over caller-owned host memory, imported rather than copied (ADR 0013): the device
addresses memory..memory + len itself, so bytes placed there by the host, or by another
device’s DMA, are the buffer’s contents with no write_buffer. Behaves as an allocated
buffer of desc in every other respect: bound by submissions, gated while in flight, read
and written by the explicit transfers, released by free_buffer. Its domain must be
Host or Shared, the domains whose contract is host-visible memory.
This is a host-side API of this backend, not a protocol feature: the protocol’s external memory import remains deferred.
§Safety
memory..memory + len must be live host memory (anonymous or huge-page mappings; not a
device mapping) that stays allocated and mapped, and is not remapped, until the buffer is
released and no submission that bound it is still executing. While a submission that binds
the buffer is in flight, the host must not write bytes that submission reads or read bytes
it writes.
Sourcepub fn direct_binding_admissions(&self) -> u64
pub fn direct_binding_admissions(&self) -> u64
Cumulative count of buffers admitted as direct bindings.
Sourcepub fn explicit_transfer_bytes(&self) -> u64
pub fn explicit_transfer_bytes(&self) -> u64
Cumulative bytes moved by explicit write_buffer/read_buffer transfers.
Sourcepub fn live_resources(&self) -> LiveResources
pub fn live_resources(&self) -> LiveResources
Provider handles currently alive for this instance.
Trait Implementations§
Source§impl Accelerator for VulkanAccelerator
impl Accelerator for VulkanAccelerator
Source§type Context = VulkanContext
type Context = VulkanContext
Source§type Buffer = VulkanBuffer
type Buffer = VulkanBuffer
BufferInfo.Source§type Program = VulkanProgram
type Program = VulkanProgram
Source§type Queue = VulkanQueue
type Queue = VulkanQueue
Source§type Event = VulkanEvent
type Event = VulkanEvent
Source§fn device_info(&self) -> Result<DeviceInfo, BackendError>
fn device_info(&self) -> Result<DeviceInfo, BackendError>
Source§fn create_context(
&self,
desc: ContextDesc,
) -> Result<Self::Context, BackendError>
fn create_context( &self, desc: ContextDesc, ) -> Result<Self::Context, BackendError>
Source§fn destroy_context(
&self,
context: Self::Context,
) -> Result<(), ReleaseFailure<Self::Context>>
fn destroy_context( &self, context: Self::Context, ) -> Result<(), ReleaseFailure<Self::Context>>
Source§fn allocate_buffer(
&self,
context: &Self::Context,
desc: BufferDesc,
) -> Result<AllocatedBuffer<Self::Buffer>, BackendError>
fn allocate_buffer( &self, context: &Self::Context, desc: BufferDesc, ) -> Result<AllocatedBuffer<Self::Buffer>, BackendError>
Source§fn write_buffer(
&self,
buffer: &mut Self::Buffer,
offset: u64,
data: &dyn ByteSource,
) -> Result<(), BackendError>
fn write_buffer( &self, buffer: &mut Self::Buffer, offset: u64, data: &dyn ByteSource, ) -> Result<(), BackendError>
Source§fn read_buffer(
&self,
buffer: &Self::Buffer,
offset: u64,
data: &mut dyn ByteSink,
) -> Result<(), BackendError>
fn read_buffer( &self, buffer: &Self::Buffer, offset: u64, data: &mut dyn ByteSink, ) -> Result<(), BackendError>
Source§fn free_buffer(
&self,
buffer: Self::Buffer,
) -> Result<(), ReleaseFailure<Self::Buffer>>
fn free_buffer( &self, buffer: Self::Buffer, ) -> Result<(), ReleaseFailure<Self::Buffer>>
Source§fn load_program(
&self,
context: &Self::Context,
artifact: ArtifactRef<'_>,
) -> Result<Self::Program, BackendError>
fn load_program( &self, context: &Self::Context, artifact: ArtifactRef<'_>, ) -> Result<Self::Program, BackendError>
Source§fn unload_program(
&self,
program: Self::Program,
) -> Result<(), ReleaseFailure<Self::Program>>
fn unload_program( &self, program: Self::Program, ) -> Result<(), ReleaseFailure<Self::Program>>
Source§fn create_queue(
&self,
context: &Self::Context,
desc: QueueDesc,
) -> Result<Self::Queue, BackendError>
fn create_queue( &self, context: &Self::Context, desc: QueueDesc, ) -> Result<Self::Queue, BackendError>
Source§fn destroy_queue(
&self,
_queue: Self::Queue,
) -> Result<(), ReleaseFailure<Self::Queue>>
fn destroy_queue( &self, _queue: Self::Queue, ) -> Result<(), ReleaseFailure<Self::Queue>>
Source§fn submit(
&self,
queue: &Self::Queue,
program: &Self::Program,
bindings: &[BindingRef<'_, Self::Buffer>],
timeout: Timeout,
) -> Result<Self::Event, SubmitFailure<Self::Event>>
fn submit( &self, queue: &Self::Queue, program: &Self::Program, bindings: &[BindingRef<'_, Self::Buffer>], timeout: Timeout, ) -> Result<Self::Event, SubmitFailure<Self::Event>>
Source§fn poll_event(&self, event: &Self::Event) -> Result<EventState, BackendError>
fn poll_event(&self, event: &Self::Event) -> Result<EventState, BackendError>
Source§fn destroy_event(
&self,
event: Self::Event,
) -> Result<(), ReleaseFailure<Self::Event>>
fn destroy_event( &self, event: Self::Event, ) -> Result<(), ReleaseFailure<Self::Event>>
Source§fn cancel_event(&self, _event: &Self::Event) -> Result<(), BackendError>
fn cancel_event(&self, _event: &Self::Event) -> Result<(), BackendError>
EventState::Cancelled. Read more