Skip to main content

WgpuRuntime

Struct WgpuRuntime 

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

Headless wgpu runtime for compute-only workloads.

Implementations§

Source§

impl WgpuRuntime

Source

pub fn new_headless() -> SpatialResult<Self>

Creates a headless wgpu runtime preferring a high-performance adapter.

Prefer Self::shared when running multiple GPU filters in one process.

Source

pub fn new_headless_with_preference( preference: WgpuPowerPreference, ) -> SpatialResult<Self>

Creates a headless wgpu runtime with an explicit adapter power preference.

Source

pub fn new_headless_with_timestamps( preference: WgpuPowerPreference, ) -> SpatialResult<Self>

Creates a runtime enabling pass timestamps when supported by the adapter.

Unsupported adapters still initialize; check Self::timestamp_queries_enabled before constructing a profiler. The default constructors request no timestamps.

Source

pub fn new_headless_with_options( options: WgpuRuntimeOptions, ) -> SpatialResult<Self>

Creates an owned runtime using explicit backend and profiling options.

GL must be compiled for the target and provide adapter compute shaders. An uncompiled GL request fails before instance creation. Admission errors do not select another backend. Browser callers should use the async counterpart.

Source

pub fn timestamp_queries_enabled(&self) -> bool

Returns whether this device has optional pass timestamp queries enabled.

Source

pub fn shared() -> SpatialResult<Arc<Self>>

Returns a process-wide shared headless runtime, initializing it on first use.

Source

pub fn device(&self) -> &Device

Returns the underlying wgpu device.

Source

pub fn queue(&self) -> &Queue

Returns the underlying wgpu queue.

Source

pub const fn adapter_info(&self) -> &WgpuAdapterInfo

Returns the selected adapter/backend receipt.

Source

pub fn wait_idle(&self)

Blocks until all previously submitted work on this device is complete.

Normal device-resident chains do not synchronize implicitly. This is an explicit profiling/testing boundary or host-coordination primitive.

Source

pub fn cached_image_texture_count(&self) -> usize

Returns the number of image textures retained for steady-state reuse.

Source

pub fn image_texture_pool_stats(&self) -> GpuResourcePoolStats

Returns image-texture retention and lifetime allocation/reuse counters. Texel bytes exclude driver overhead and live images; the default is 64 MiB.

Source

pub fn set_image_texture_pool_budget(&self, budget_bytes: u64)

Changes retained RGBA8 texel bytes; zero disables texture retention. Shrinking below current retention clears cached textures. Active images remain valid and allocations are not capped by the retention budget.

Source

pub fn clear_image_texture_pool(&self)

Drops cached texture handles without affecting live images or counters.

Source

pub fn initialized_image_pipeline_count(&self) -> usize

Returns the number of initialized GPU image pipeline families.

Source

pub fn pipelines(&self) -> &ComputePipelineCache

Returns cached compute pipelines for this runtime’s device.

Source

pub fn max_gather_channels(&self) -> u32

Returns the maximum attribute channels gatherable in one multi dispatch.

Source

pub fn buffer_pool(&self) -> &GpuBufferPool

Returns the reusable storage-buffer pool owned by this runtime.

Source

pub fn scratch_buffer_pool_stats(&self) -> GpuResourcePoolStats

Returns private point-kernel scratch retention and lifetime counters. The default budget is 64 MiB, independent of the public upload pool.

Source

pub fn set_scratch_buffer_pool_budget(&self, budget_bytes: u64)

Changes private scratch retention; zero disables reuse. Shrinking below current retention clears cached buffers without affecting submitted work.

Source

pub fn clear_scratch_buffer_pool(&self)

Drops cached scratch handles without changing the budget or counters.

Source

pub fn upload_pod_storage<T: Pod>( &self, label: &'static str, data: &[T], ) -> SpatialResult<Buffer>

Uploads a POD slice into a reusable pooled storage buffer.

Source

pub fn upload_f32_storage( &self, label: &'static str, data: &[f32], ) -> SpatialResult<Buffer>

Uploads f32 values into a reusable pooled storage buffer.

Source

pub fn upload_u32_storage( &self, label: &'static str, data: &[u32], ) -> SpatialResult<Buffer>

Uploads u32 values into a reusable pooled storage buffer.

Source

pub fn recycle_storage(&self, byte_len: u64, buffer: Buffer)

Returns a storage buffer to the upload pool for reuse.

Source

pub fn clear_buffer_pool(&self)

Clears all buffers cached in the upload pool.

Source

pub async fn new_headless_async( preference: WgpuPowerPreference, ) -> SpatialResult<Self>

Creates a headless runtime asynchronously.

This is the browser/WebGPU construction path because blocking a WASM main thread is not supported. Native callers may also use it from their async executor.

Source

pub async fn new_headless_with_timestamps_async( preference: WgpuPowerPreference, ) -> SpatialResult<Self>

Async counterpart of Self::new_headless_with_timestamps.

Source

pub async fn new_headless_with_options_async( options: WgpuRuntimeOptions, ) -> SpatialResult<Self>

Async counterpart of Self::new_headless_with_options.

Trait Implementations§

Source§

impl SpatialRuntime for WgpuRuntime

Available on crate feature gpu-wgpu only.
Source§

fn device_kind(&self) -> DeviceKind

Returns the device kind owned by this runtime.
Source§

fn supports_policy(&self, policy: ExecutionPolicy) -> bool

Returns whether this runtime can satisfy the requested policy.

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

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, 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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,