A client requests a set of commands to be Presented as part of a future Scenic frame. A single Scenic frame can have multiple client "Presents", where each Present represents a Session's update to the global scene graph. This doc describes the architecture internal to Scenic for how a request becomes pixels.
The diagram below shows the steps a client Present follows when it is requested. Everything between the Scenic FIDL Boundary and the Vulkan driver is currently single-threaded and executes sequentially.
- Client
Enqueue()
s a set of commands to change the contents of its part of the scene, and callsPresent2()
to commit them. - The
Present2()
request entersscenic_impl::Session
,.scenic_impl::Session
waits for any acquire fences to signal, as well as any previousPresent2()
calls whose fences haven't been reached yet.scenic_impl::Session
then schedules an update for the targetedpresentation_time
with theFrameScheduler
. - The
FrameScheduler
starts sleeps until there's just enough time to prepare a frame in time for the targeted presentation time. At that point theFrameScheduler
wakes up and callsSessionUpdater::UpdateSessions()
on allSessionUpdaters
. - For each client Session,
GfxSystem
callsApplyScheduledUpdates()
, which applies the commands to the scene graph that were enqueued in step 1. Note:GfxSystem
is aSessionUpdater
. - Commands from a Session are applied to the global scene graph. The scene graph is in an inconsistent state ("dirty") at this time, and should not be read by other systems (i.e. input) until after the scene graph has been post-processed.
- When all
SessionUpdaters
have successfully updated, theFrameScheduler
is notified that the scene graph is dirty, and triggers aRenderFrame()
call on theFrameRenderer
. - To draw a frame,
gfx::Engine
's renderer traverses the scene graph and createsEscher::objects
for each element in the scene. The renderer then passes these objects toEscher
, and callsDrawFrame()
. Note:gfx::Engine
is aFrameRenderer
. Escher
interprets the scene graph objects asvk::commands
, and sends these commands to the GPU.- The GPU processes the commands and sends the results to the display driver.
- The display driver pushes the pixels to the screen.