captureRenderGraph method
Future<RenderGraphCaptureResult>
captureRenderGraph({
- int viewIndex = 0,
- RenderGraphCaptureRequest request = const RenderGraphCaptureRequest(),
- Duration timeout = const Duration(seconds: 5),
Captures the next rendered frame of screen view viewIndex: the pass
list with CPU timings, the blackboard data flow, and (per request)
GPU copies of the textures each pass wrote. Resolves after that frame's
graph executes; the caller must ensure a frame renders (schedule one).
Requires debugAllowRenderGraphCapture. A second call before the
pending one resolves replaces it, and a capture no frame fulfills
within timeout (the view hidden, zero-sized, or the scene not ready)
fails instead of hanging its caller; either way the first future
completes with an error.
Implementation
Future<RenderGraphCaptureResult> captureRenderGraph({
int viewIndex = 0,
RenderGraphCaptureRequest request = const RenderGraphCaptureRequest(),
Duration timeout = const Duration(seconds: 5),
}) {
if (!debugAllowRenderGraphCapture) {
throw StateError(
'Render graph capture is disabled; set '
'Scene.debugAllowRenderGraphCapture first.',
);
}
final pending = _pendingGraphCapture;
if (pending != null) {
_pendingGraphCapture = null;
pending.completer.completeError(
StateError('Superseded by a newer render graph capture'),
);
}
final completer = Completer<RenderGraphCaptureResult>();
final armed = (
viewIndex: viewIndex,
request: request,
completer: completer,
);
_pendingGraphCapture = armed;
Timer(timeout, () {
if (!identical(_pendingGraphCapture, armed)) return;
_pendingGraphCapture = null;
completer.completeError(
StateError(
'Render graph capture timed out; no frame rendered view '
'$viewIndex (is the viewport visible and the scene ready?)',
),
);
});
return completer.future;
}