gpu_pipeline 1.4.12
gpu_pipeline: ^1.4.12 copied to clipboard
A GPU-accelerated streaming pipeline for Dart and Flutter. Define directed stage graphs that route Tensors and host data through WGSL compute shaders with typed I/O ports, resource management, and rea [...]
gpu_pipeline #
A GPU-accelerated streaming pipeline for Dart and Flutter. Define directed graphs of processing stages that route Tensor and host typed-data through WGSL compute shaders via minigpu, with typed I/O ports, resource management, and real-time constraints.
Part of the minigpu package family.
Features #
- Directed stage graph — connect
PipelineStagenodes via typedInputPort/OutputPortpairs; the pipeline routes data automatically - GPU + CPU stages —
ShaderStageOperationruns WGSL compute shaders onTensordata;CpuStageOperationprocesses hostTypedData; mix freely in the same graph - Multi-stream routing — each stage declares a
StageStreamConfigto receive all streams, a merged view, or only selected stream IDs - Resource-aware scheduling —
ResourceRequirements,MemoryStrategy, andRealTimeConstraintslet stages express their resource needs; the pipeline honours them during execution - Dynamic stages —
PipelineDynamicStagecan modify the graph topology at runtime - Asset management — stages declare
StaticAssetrequirements; the built-inAssetManagerloads and caches them before first execution - Event bus —
PipelineEventNotifierdelivers lifecycle and error events to any observer
Getting started #
Add to pubspec.yaml:
dependencies:
gpu_pipeline: ^1.0.0
gpu_tensor: ^1.3.0
minigpu: ^1.3.0
Initialise minigpu once before creating pipelines:
import 'package:minigpu/minigpu.dart';
await Minigpu.initialize();
Usage #
Define a stage #
import 'package:gpu_pipeline/gpu_pipeline.dart';
import 'package:gpu_tensor/gpu_tensor.dart';
class NormalizeStage extends PipelineStage {
NormalizeStage() : super(stageId: 'normalize') {
addInputPort(InputPort('input', formats: ['tensor']));
addOutputPort(OutputPort('output', format: 'tensor'));
}
@override
Future<PipelineEvent> process(Map<String, dynamic> inputs) async {
final tensor = inputs['input'] as Tensor;
// run a WGSL shader or transform tensors here
return PipelineEvent.data({'output': tensor});
}
}
Build and run a pipeline #
final pipeline = Pipeline();
pipeline.addStage(NormalizeStage());
pipeline.addStage(MyOutputStage());
pipeline.connect('normalize.output', 'output.input');
await pipeline.initialize();
final result = await pipeline.process({'normalize.input': myTensor});
Shader stage #
Use ShaderStageOperation to dispatch a WGSL compute shader directly:
final op = ShaderStageOperation(
shader: myWgslSource,
workgroupSize: (8, 8, 1),
bindingLayout: [...],
);
Architecture #
MediaStream ──► Stage A ──► Stage B ──► Stage C ──► output
(WGSL) (CPU) (WGSL)
Each stage receives a Map<String, dynamic> of named inputs and returns a PipelineEvent carrying named outputs. The Pipeline scheduler resolves the connection graph, dispatches stages in dependency order, and propagates errors via the event bus.
Platform support #
| Platform | Status |
|---|---|
| Windows | ✅ |
| Linux | ✅ |
| macOS | ✅ |
| Android | ✅ |
| iOS | ✅ |
| Web | ✅ (dart2wasm / dart2js) |
Additional information #
- Source: github.com/PracticalXR/minigpu
- Issues: github.com/PracticalXR/minigpu/issues
- Related packages: minigpu, gpu_tensor