pub struct GpuContext {
pub device: Device,
pub queue: Queue,
}wgpu only.Expand description
A headless wgpu device + queue for running the compute kernel.
Callers that already own a wgpu::Device should build StencilEvalPipeline
and StencilTableGpu directly; this is a convenience for standalone use
and tests. new returns None when no adapter is available.
Fields§
§device: DeviceThe wgpu device.
queue: QueueThe wgpu queue.
Implementations§
Source§impl GpuContext
impl GpuContext
Sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Create a headless compute context, or None if no GPU adapter is
available (so callers can gracefully fall back to the CPU path).
Sourcepub fn evaluate(
&self,
table: &StencilTable,
input: &[f32],
components: u32,
) -> Result<Vec<f32>, KernelError>
pub fn evaluate( &self, table: &StencilTable, input: &[f32], components: u32, ) -> Result<Vec<f32>, KernelError>
Evaluate table over a tightly-packed input buffer of
components-vectors, returning the packed output.
Equivalent to StencilTable::interpolate for [f32; components] data.
Builds all transient GPU resources per call; for repeated evaluation hold
a StencilEvalPipeline + StencilTableGpu and reuse buffers via
evaluate_stencils.
Sourcepub fn evaluate_sparse(
&self,
table: &StencilTable,
input: &[f32],
components: u32,
affected: &[u32],
prior_output: &[f32],
) -> Result<Vec<f32>, KernelError>
pub fn evaluate_sparse( &self, table: &StencilTable, input: &[f32], components: u32, affected: &[u32], prior_output: &[f32], ) -> Result<Vec<f32>, KernelError>
Sparse re-evaluation: recompute only the affected output rows from
input, splicing them into prior_output (the previous dense result).
Pair with RefinementResult::affected_outputs for incremental edits.
The result equals a full dense re-evaluation when affected covers every
output row that actually changed.