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
impl GpuContext
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Request the default high-performance adapter and create a device.
Sourcepub fn from_device(device: Device, queue: Queue, info: &AdapterInfo) -> Self
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.
Sourcepub fn unified_memory(&self) -> bool
pub fn unified_memory(&self) -> bool
True when storage buffers are mapped directly (unified memory).
pub fn info(&self) -> &GpuAdapterInfo
pub fn device(&self) -> &Device
pub fn queue(&self) -> &Queue
Sourcepub fn adapter(&self) -> Option<&Adapter>
pub fn adapter(&self) -> Option<&Adapter>
The adapter, when this context created its own device.
Sourcepub async fn wait_idle(&self) -> Result<()>
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.
Sourcepub fn override_limits(&self, max_binding: Option<u64>, max_buffer: Option<u64>)
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.
Sourcepub fn max_binding_bytes(&self) -> u64
pub fn max_binding_bytes(&self) -> u64
Largest storage binding FlashRaw uses (adapter limit, caps, 32-bit addressing).
Sourcepub fn max_buffer_bytes(&self) -> u64
pub fn max_buffer_bytes(&self) -> u64
Largest single buffer FlashRaw allocates (adapter limit and cap).
Sourcepub fn estimate_bands(&self, input_bytes: u64, output_bytes: u64) -> u32
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
impl GpuContext
Sourcepub async fn calibration(self: &Arc<Self>) -> GpuCalibration
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.
Sourcepub fn cached_calibration(&self) -> Option<GpuCalibration>
pub fn cached_calibration(&self) -> Option<GpuCalibration>
The calibration if it has already been measured (never runs the benchmark).
Sourcepub fn calibration_blocking(self: &Arc<Self>) -> GpuCalibration
pub fn calibration_blocking(self: &Arc<Self>) -> GpuCalibration
Blocking GpuContext::calibration (native only).
Source§impl GpuContext
impl GpuContext
Sourcepub async fn run(
self: &Arc<Self>,
frame: &GpuFrame<'_>,
info: &FrameInfo,
op: &GpuOp,
) -> Result<GpuRun>
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.
Sourcepub fn run_blocking(
self: &Arc<Self>,
frame: &GpuFrame<'_>,
info: &FrameInfo,
op: &GpuOp,
) -> Result<GpuRun>
pub fn run_blocking( self: &Arc<Self>, frame: &GpuFrame<'_>, info: &FrameInfo, op: &GpuOp, ) -> Result<GpuRun>
Blocking GpuContext::run (native only).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GpuContext
impl !RefUnwindSafe for GpuContext
impl !UnwindSafe for GpuContext
impl Send for GpuContext
impl Sync for GpuContext
impl Unpin for GpuContext
impl UnsafeUnpin for GpuContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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