pub struct Engine { /* private fields */ }Expand description
Sole owner of OA’s local execution services.
The current one-device recorder is thread-affine. Engine intentionally
remains neither Send nor Sync until concurrent queue scheduling and
submission synchronization are implemented and verified.
Clones share the execution handle and persistence guard: .vkcache
persistence runs once, when the last Engine clone drops, never per
temporary handle. A clone does not own the log-selection restore that the
constructing engine performs on drop.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn available_devices() -> Result<Vec<DeviceSummary>>
pub fn available_devices() -> Result<Vec<DeviceSummary>>
List every Vulkan device, including software CPU implementations.
Creates a temporary instance but no logical device, allocator or pipelines. A listed device may still fail OA capability admission. Ordinals are scoped to the current loader and ICD configuration, not stable across machines.
§Errors
Returns backend initialization or enumeration errors.
Sourcepub fn device_info(&self) -> DeviceInfo
pub fn device_info(&self) -> DeviceInfo
Return queried device facts and the allocated descriptor capacities.
Sourcepub fn fusion_stats(&self) -> FusionStats
pub fn fusion_stats(&self) -> FusionStats
Return engine-lifetime fusion decision and decline counters.
Counts reflect fusion passes that already ran: eager work is fused when it is flushed and captured work when it is captured. This query does not flush, submit or wait, and plan replay does not change the counters. The record is a diagnostic; it never influences route selection.
Sourcepub fn builder() -> EngineBuilder
pub fn builder() -> EngineBuilder
Begin explicit engine configuration.
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create an engine using one compute-capable Vulkan device.
§Errors
Returns an error when Vulkan cannot be loaded, no hardware device meets the compiled Core or Compatibility profile requirements, or logical-device creation fails.
Sourcepub fn init_default() -> Result<()>
pub fn init_default() -> Result<()>
Initialize this thread’s default compute engine before its first use.
Initialization is lazy and attempted again after a failure. The selected engine remains thread-affine and is reused by later default operations.
§Errors
Returns the same backend or device-selection error as Engine::new.
Sourcepub fn set_default(engine: Engine)
pub fn set_default(engine: Engine)
Install engine as this thread’s default compute engine.
Replaces any engine previously stored by Engine::init_default or an
earlier set_default call. The previous default is dropped after the
new engine is installed.
Sourcepub fn current() -> Result<Self>
pub fn current() -> Result<Self>
Return this thread’s default compute engine.
Initialization is lazy on first use and the returned handle clones the installed engine, so it remains valid if the default is later replaced.
§Errors
Returns the same backend or device-selection error as Engine::new.
Sourcepub fn with_default<T>(use_engine: impl FnOnce(&Self) -> Result<T>) -> Result<T>
pub fn with_default<T>(use_engine: impl FnOnce(&Self) -> Result<T>) -> Result<T>
Access this thread’s lazily initialized default compute engine.
§Errors
Returns an engine initialization error or an error from use_engine.
Sourcepub fn has_graphics(&self) -> bool
pub fn has_graphics(&self) -> bool
Return whether this Engine has an executable graphics path.
Both profiles require enabled dynamic rendering and a graphics queue. Presentation additionally requires WSI support and per-surface present-support negotiation.
Sourcepub fn supports_clock_calibration(&self) -> bool
pub fn supports_clock_calibration(&self) -> bool
Return whether this Engine’s device can calibrate its timestamp domain against a POSIX monotonic host clock.
Sourcepub fn calibrate_clock(&self, sample_count: u32) -> Result<ClockCalibration>
pub fn calibrate_clock(&self, sample_count: u32) -> Result<ClockCalibration>
Sample paired device/host timestamps and retain the lowest-deviation pair.
sample_count selects the best of [1, 1024] quasi-simultaneous
samples; recalibrate long-running traces periodically because a value
farther than half a device-clock period from the sample is inherently
ambiguous.
§Errors
Returns InvalidArgument when sample_count is outside [1, 1024],
Unavailable when the device lacks calibrated timestamps or usable
domains, and a backend error when sampling fails.
Sourcepub fn new_presentation_surface<'window>(
&self,
window: &'window SdlWindow,
) -> Result<PresentationSurface<'window>>
pub fn new_presentation_surface<'window>( &self, window: &'window SdlWindow, ) -> Result<PresentationSurface<'window>>
Create one SDL3 Vulkan surface borrowing this Engine and window.
pub fn owns_matrix(&self, matrix: &Matrix) -> bool
Sourcepub fn checkpoint(&self) -> Result<Event>
pub fn checkpoint(&self) -> Result<Event>
Submit an explicit completion checkpoint to this engine’s compute queue.
Pending eager operations are submitted together as one batch. When no eager work is pending, an empty checkpoint is submitted. The returned event completes after that exact queue point. Dropping it does not wait.
§Errors
Returns an error when command recording, submission, or retirement fails, or when the engine exhausts its timeline epoch space.
Sourcepub fn checkpoint_timed(&self) -> Result<Event>
pub fn checkpoint_timed(&self) -> Result<Event>
Submit pending eager work with one device timestamp pair around the batch.
Unlike Engine::checkpoint, this requires at least one pending operation;
there is no meaningful device interval for an empty queue checkpoint.
§Errors
Returns the errors from Engine::checkpoint, MissingCapability when
timestamps are unavailable, or FailedPrecondition for an empty batch.
Sourcepub fn checkpoint_with_timer(&self, timer: &mut Timer) -> Result<Event>
pub fn checkpoint_with_timer(&self, timer: &mut Timer) -> Result<Event>
Submit pending eager work bracketed by a device Timer’s timestamps.
The timer must be initialized for TimerDomain::Device on this engine
and is single-flight: a new tagged submission is rejected while the
previous one is pending. The returned event carries no timing; the
elapsed device duration is committed through Timer::commit.
Donor: oa::Engine::submit(oa::Timer*) in
oacpp/source/cpp/lib/oa/runtime/engine/engine.cpp.
§Errors
Returns the errors from Engine::checkpoint_timed, or
FailedPrecondition when the timer is host-domain, uninitialized, or
still pending, or InvalidArgument when it was initialized by another
engine.
Sourcepub fn capture<T>(
&self,
capture: impl FnOnce() -> Result<T>,
) -> Result<(ExecutionPlan, T)>
pub fn capture<T>( &self, capture: impl FnOnce() -> Result<T>, ) -> Result<(ExecutionPlan, T)>
Capture an isolated operation sequence as an immutable execution plan.
Capture records but never submits or waits. The returned value may include
matrices produced by the plan; those matrices become observable only after
Engine::submit is called for the returned plan.
§Errors
Returns an error when eager work is already pending, capture is nested, the closure fails, or the closure records no executable work.
Sourcepub fn submit(&self, plan: &ExecutionPlan) -> Result<Event>
pub fn submit(&self, plan: &ExecutionPlan) -> Result<Event>
Submit an immutable execution plan to its originating engine.
Any pending eager batch is submitted first. The returned event identifies exact completion of this plan replay. Submission does not wait.
§Errors
Returns an error when the plan belongs to another engine, capture is active, eager flushing fails, or command recording, submission, or retirement fails.
Sourcepub fn submit_timed(&self, plan: &ExecutionPlan) -> Result<Event>
pub fn submit_timed(&self, plan: &ExecutionPlan) -> Result<Event>
Submit a plan with one device timestamp pair around its complete graph.
The returned event exposes the device duration through
Event::try_device_duration and Event::device_duration. Timing adds
instrumentation only to this replay and does not wait.
§Errors
Returns the errors from Engine::submit, or MissingCapability when the
selected compute queue cannot provide timestamps.
Sourcepub fn log(
&self,
level: LogLevel,
component: LogComponent,
text: impl AsRef<str>,
) -> Result<()>
pub fn log( &self, level: LogLevel, component: LogComponent, text: impl AsRef<str>, ) -> Result<()>
Write one record through this engine’s logging session.
Filtered records return successfully without formatting or output.
§Errors
Returns the first retained console or file output failure, or an error if the logging session has already been closed.
Sourcepub fn set_log_level(&self, level: LogLevel)
pub fn set_log_level(&self, level: LogLevel)
Change this engine logger’s minimum severity.
Sourcepub fn log_path(&self) -> Option<PathBuf>
pub fn log_path(&self) -> Option<PathBuf>
Return the active log-file path when file output is enabled.
Sourcepub fn flush_log(&self) -> Result<()>
pub fn flush_log(&self) -> Result<()>
Flush this engine’s logging session and report any retained sink failure.
§Errors
Returns the first console or file output failure.
Sourcepub fn close(self) -> Result<()>
pub fn close(self) -> Result<()>
Explicitly close this engine’s logging session before releasing the engine.
Existing values retain the execution services they require, but no longer
have a selected engine logging session after this call consumes self.
§Errors
Returns the first console or file flush failure.
Source§impl Engine
impl Engine
Sourcepub fn dispatch_kernel(
&self,
kernel: &Kernel,
bindings: &[KernelBinding<'_>],
push_constants: &[KernelPush],
workgroups: [u32; 3],
) -> Result<()>
pub fn dispatch_kernel( &self, kernel: &Kernel, bindings: &[KernelBinding<'_>], push_constants: &[KernelPush], workgroups: [u32; 3], ) -> Result<()>
Record one eager extension-kernel dispatch.
The dispatch joins the engine’s pending batch like any eager operation:
barriers against other recorded work are derived from the declared
binding accesses, and completion is observed through
Engine::checkpoint or any host read.
§Errors
Returns InvalidArgument when kernel belongs to another engine, when
bindings/push_constants counts do not match the kernel’s declared
ABI, or when workgroups is zero or exceeds device limits; returns the
recording errors from the underlying session otherwise.