Shared state

A map of render_draw_main and its callees (render.c, surface.c, texture.c, pipeline.c, record.c) found two blockers before any single structure:

Structures both stages touch:

Effects of Stage 2 that Stage 1 must see, and their stamps:

Stage 1 is free of side effects only on its memo hits. Each miss path can land results, submit, end a render pass or compile: vk_frame_check, the guest reads of draw_find and draw_shaders, the target reloads of read_targets, the uploads and reloads of the texture resolve, capture_draw, and the pipeline wait. These paths need vk_lock and the record ring, which has one producer. So Stage 1 must stop at a miss and leave the draw to Stage 2.

Globals that need to change: a per-draw packet for g_mesh_first, g_mesh_payload, g_memh_draw, g_setup_restarts, g_vk_drawing, g_predraw and g_capture_draw. Thread-local copies of g_pipeline.sh_ds, sh_bind and the write epoch's stream state. Per-thread statistics. Atomics or a sequence lock for the take generation, the surface bucket epochs, g_vk_present, Surf.wgen and Surf.layout. A review of every callee that takes vk_lock or checks that it is held.


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