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:
vk_lock is a reentrant mutex, and each draw holds it from vkr_draw. Stage 1 cannot hold it while Stage 2 does,
and several Stage 1 callees take it (mem_need_reason in buffer.c, vk_compute_mem_need).ds is the owner's live DsState, which the front end changes after vkr_draw returns. Stage 2 of draw N reads
its dynamic state, viewports, bindings, index, vertex buffers, blend, raster key and targets. Each draw needs its
own copy of ds, of dc and of its inline indices.Structures both stages touch:
g_tex_recent and g_tex_memo: both write them. stage_set_ resolves the textures of the stages before the
fragment stage and the slots fs_key did not resolve, and tex_memo_of writes each entry's view and sampler caches.
One owner means that all texture resolves move into Stage 1.g_targets and g_draw: Stage 1 writes them on each lookup. Stage 2 writes g_targets in a predraw probe, and
g_draw.last and fs at the end of each draw. The final key needs the feedback slots and edges, which only Stage 2
knows.layout (in render_begin and vk_surf_use) and wgen (in target_written). Stage 1
writes gw, layout and the LRU when it reloads or touches a target.gmem_read).g_rp (Stage 1 reads it at the merge with the open pass), g_vk.has_descriptor_heaps (the heaps retry), and the
statistics.Effects of Stage 2 that Stage 1 must see, and their stamps:
Surf.wgen and the take generation. A result added: the adds counters. A surface made or
reloaded: the surface table's epoch and the take generation. A submit or a wait: the submission number and the write
epoch. A result landed: gpu_mem_generation().UNDEFINED, a texture's quiet and upload state, the draw
memo's last entry, and g_rp after render_begin. Each needs a new counter, or a direct check in Stage 2.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.