Renderer · type
PrepareContext
What a pass is handed once a frame, before the frame's own target exists.
Explained in Hello world.
type PrepareContext =import type { PrepareContext } from '@driftengine/core';In depth
A sibling of PassContext rather than a widening of it, because the two carry different
things and one of them cannot be nested inside the other. draw is invoked inside an open
render pass on WebGPU, and a render pass cannot contain another; so a pass that wants to render
into a target of its own needs a GPUCommandEncoder instead, and that is what this is.
The window it runs in already existed. beginFrame creates the frame's command encoder and
then defers opening the frame's render pass until the first draw that wants one — which
ensurePass does for a measured reason about mirrors and tile memory. So there is a point at
which an encoder exists and no render pass is open, and commands recorded on one encoder execute
in recording order. A pass-owned target filled there has completed before any frame pass could
sample it, with the graph learning nothing and nothing reordered.
On WebGL2 the contract is a restore rather than an ordering. There is no verb-level graph on
that backend and it was withdrawn on purpose, so there is nothing to schedule against. prepare
is called before the frame's target is bound, with the default framebuffer bound, and must
leave it bound. That is the same promise draw already makes about the program, the vertex
array, the blend and depth state and the viewport — one step stronger, because a framebuffer
left bound takes the whole frame with it rather than one draw. The asymmetry with WebGPU is real
and is not papered over: there the ordering is a property of the encoder, and here it is a
property of the caller's politeness.