afterSubmissions static method

FrameCompletion afterSubmissions({
  1. Iterable<ExternalRenderTarget> present = const [],
})

Signals completion once a trailing empty submission finishes, which on an in-order queue is after everything submitted before it.

The surface frames among present are presented on that submission, so each surface learns its image is final when the frame's work is.

Implementation

static FrameCompletion afterSubmissions({
  Iterable<ExternalRenderTarget> present = const [],
}) {
  final completer = Completer<void>();
  final commandBuffer = gpu.gpuContext.createCommandBuffer();
  for (final target in present) {
    target.presentSurfaceFrame(commandBuffer);
  }
  commandBuffer.submit(
    completionCallback: (_) {
      if (!completer.isCompleted) completer.complete();
    },
  );
  return FrameCompletion.rendered(completer.future);
}