The design: two stages in a pipeline

The renderer's records stay in order. Each draw goes through two stages on two threads:

Stage 1 works on draw N+1 while Stage 2 works on draw N. Records that are not draws (clears, copies, barriers, writes of the front end) stop Stage 1 at their place: Stage 1 resolves no draw past a record that Stage 2 has not run.

Correctness: Stage 1 results are proposals

Stage 2 can change what Stage 1 read: draw N writes its targets, adds results that wait to land, makes surfaces, and can submit. Stage 1 for draw N+1 may have read the state from before that. So a Stage 1 result carries the stamps it read (the same stamps the memos ask today: gpu_mem_generation(), the results added, the storage images, the targets taken, the surface table, the write epoch, the submission, the present). Stage 2 compares them before it uses the result. Where one moved, Stage 2 resolves the draw again itself, as the renderer does today. The pipeline can only lose time, never correctness.

draw_state_check=1 turns Stage 1 off, or makes Stage 2 resolve each draw again and compare.

What Stage 1 must not do

Stage 1 must not submit, wait for the GPU, begin or end a render pass, or record a command. A step of Stage 1 that can do one of these (for example a texture upload that waits, or a reload of a target) stops Stage 1 for that draw, and Stage 2 does the step.


Made from docs/dev/parallel-draw-prep.md at 69237645142c. GPL-3.0-or-later.