Expand description
GPU facade: backend selection, capability traits, opaque handles, and feature-gated backends. Feature matrix:
gpu-noop(default): deterministic noop backend, always available; zero-GPU environments still compile.gpu-mock: deterministic mock backend for tests/CI.gpu-wgpu: real wgpu backend (types remain internal), placeholder for now. Concurrency: backends areSend + Sync; clone the handle (cheapArc) to share across tasks. Planner/runtime expectation: callselect_backendonce, inspect skipped reasons (for “why not GPU?”), then use the returned handle to allocate buffers/images without depending on any concrete GPU type.
Structs§
- Backend
Skip - Explanation for a backend that was skipped during selection.
- Erased
Payload - Type-erased payload wrapper so runtimes can carry GPU-capable data without monomorphizing.
- GpuAdapter
Info - Adapter information exposed to planner/runtime.
- GpuBlock
Info - Block/stride info for formats (useful if compressed formats are added later).
- GpuBuffer
Handle - Opaque buffer handle (no backend types).
- GpuBuffer
Id - Opaque buffer identifier.
- GpuCapabilities
- Capability query result.
- GpuContext
Handle - Shared handle wrapping a selected backend and diagnostics for why other backends were skipped.
- GpuFormat
Features - Per-format feature flags for planner/runtime decisions.
- GpuImage
Handle - Opaque image/texture handle (no backend types).
- GpuImage
Id - Opaque image identifier.
- GpuImage
Request - Request shape for image/texture creation.
- GpuOptions
- Adapter selection options.
- GpuRequest
- Request shape for resource creation.
- GpuUsage
- Usage flags for buffers/images; combinations are allowed.
- Noop
Backend - Noop backend: deterministic, does nothing.
- Simple
Buffer Pool - Naive buffer pool that reuses freed handles by size and usage.
- Transfer
Stats - Upload telemetry for tracking bytes transferred.
Enums§
- Backend
Skip Reason - Reason a backend was skipped during selection.
- GpuBackend
Kind - Backend kind identifiers.
- GpuError
- GPU error codes for diagnostics.
- GpuFormat
- Common GPU formats (minimal set for planner decisions).
- GpuMemory
Location - Memory location hint for GPU resources.
- Payload
- Generic payload that can carry either CPU data or a GPU representation.
Traits§
- Buffer
Pool - Simple buffer pool trait; implementations provide recycling.
- GpuBackend
- GPU backend trait; no backend-specific types exposed.
- GpuContext
- Optional context trait if backends need per-thread context.
- GpuSendable
- Opt-in bridge to allow CPU types to participate in GPU segments. Users implement this for their own types to describe how to upload/download.
Functions§
- active_
backend - Convenience for callers that just need to know the active backend kind.
- format_
bytes_ per_ pixel - select_
backend - Select the best available backend given build-time features and runtime options. Order: preferred backend (if set), then wgpu, mock, noop.
- upload_
bytes - Simple upload helper: allocates an upload buffer and returns it with bytes staged length.
- upload_
r8_ texture - Convenience helper for uploading an R8 (single-channel) texture with basic size/length validation.
- upload_
rgba8_ texture - Convenience helper for uploading an RGBA8 texture with basic size/length validation.
- validate_
texture_ bytes - Validate texture copy layout against capabilities.