beginFrame method

  1. @override
void beginFrame()

Rewinds the three frame arenas, then hands over what the browser said since the last frame.

This is the member GraphicsDevice.beginFrame exists for, and the one backend of the four with something real to do in it. See webgpu_resources.dart for why rewinding under a frame the GPU has not finished with is safe, which is the only surprising thing about it.

Throws what the browser refused, once, at the start of the frame after the call: a ShaderCompileException for WGSL that did not compile, a DeviceResourceException for any other refusal — the earliest a synchronous caller can hear an answer that arrives as a promise. Nothing is thrown once the device is lost; lost says that. The arenas are rewound first, so the device is ready for the next frame whether or not this one is refused.

Implementation

@override
void beginFrame() {
  _frame++;
  _timer.endFrame(_timingListener);
  _uniformArena.reset();
  _vertexArena.reset();
  _indexArena.reset();
  _ledger.takeFrame(deviceLost: _isLost);
}