Skip to main content

GpuContext

Struct GpuContext 

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

A device plus everything FlashRaw needs to run its kernels on it.

Create one with GpuContext::new (default adapter), or wrap an application’s existing device with GpuContext::from_device so that FlashRaw outputs live on the same device as the rest of the app (required for zero-copy interop).

Implementations§

Source§

impl GpuContext

Source

pub async fn new() -> Result<Self>

Request the default high-performance adapter and create a device.

Source

pub fn from_device(device: Device, queue: Queue, info: &AdapterInfo) -> Self

Use an application-owned device (e.g. the one a wgpu/WebGPU renderer already uses) so that GPU-resident outputs can be consumed without copies. TIMESTAMP_QUERY is used when the device was created with it.

Source

pub fn trim(&self)

Free all pooled buffers.

Source

pub fn unified_memory(&self) -> bool

True when storage buffers are mapped directly (unified memory).

Source

pub fn info(&self) -> &GpuAdapterInfo

Source

pub fn device(&self) -> &Device

Source

pub fn queue(&self) -> &Queue

Source

pub fn adapter(&self) -> Option<&Adapter>

The adapter, when this context created its own device.

Source

pub async fn wait_idle(&self) -> Result<()>

Wait until all submitted work has completed. On native this blocks in Device::poll; in the browser it yields to the event loop.

Source

pub fn override_limits(&self, max_binding: Option<u64>, max_buffer: Option<u64>)

Cap the storage-binding size and/or the buffer size FlashRaw plans with, below the adapter’s limits (None restores the adapter limit). Frames are processed in bands that fit these caps, so this bounds the size of every buffer FlashRaw binds (useful to limit peak device memory, and to exercise tiling in tests). Values are rounded down to a multiple of 256 bytes, with a 4 KB minimum.

Source

pub fn max_binding_bytes(&self) -> u64

Largest storage binding FlashRaw uses (adapter limit, caps, 32-bit addressing).

Source

pub fn max_buffer_bytes(&self) -> u64

Largest single buffer FlashRaw allocates (adapter limit and cap).

Source

pub fn estimate_bands(&self, input_bytes: u64, output_bytes: u64) -> u32

Number of bands a frame with input_bytes of upload and output_bytes of result needs on this device (an estimate for cost models; 1 = untiled).

Source§

impl GpuContext

Source

pub async fn calibration(self: &Arc<Self>) -> GpuCalibration

Measured characteristics of this device (one-time micro-benchmark, ~2048x2048 synthetic frame; cached). Returns static defaults if the benchmark fails or FLASHRAW_GPU_CALIBRATION=static.

Source

pub fn cached_calibration(&self) -> Option<GpuCalibration>

The calibration if it has already been measured (never runs the benchmark).

Source

pub fn calibration_blocking(self: &Arc<Self>) -> GpuCalibration

Blocking GpuContext::calibration (native only).

Source§

impl GpuContext

Source

pub async fn run( self: &Arc<Self>, frame: &GpuFrame<'_>, info: &FrameInfo, op: &GpuOp, ) -> Result<GpuRun>

Upload frame, run op and return the GPU-resident result.

Frames whose input or output exceed one storage binding (GpuContext::max_binding_bytes) are processed in horizontal bands: each band uploads only the rows it needs (plus a one-row halo for the demosaic), the upload of band N+1 overlaps the kernel of band N, and the output is either one buffer (bound per band) or a tiled GpuImage.

Source

pub fn run_blocking( self: &Arc<Self>, frame: &GpuFrame<'_>, info: &FrameInfo, op: &GpuOp, ) -> Result<GpuRun>

Blocking GpuContext::run (native only).

Trait Implementations§

Source§

impl Debug for GpuContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> Upcast<T> for T

Source§

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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