Mesh emulation: the stages of a pass's emulated draws recorded by stage, with one barrier between stages for all of them.

Each draw's indices are now a range of its own and its task records too, reserved by an allocation shader (one
invocation, mesh_emu_alloc_spirv) for the run of draw records queued: before the task stages the task records and the
index ranges of draws without a task stage, after them the index ranges of the others (mesh workgroups with output,
which the task stage now counts in the record, times OutputPrimitives x vertices per primitive). The mesh stage takes
its indices from the draw's range with an atomic in its record; vertex slots stay the arena's, as the indices name
them. So no draw's stages need another's, and the queue (MEQ) records the fills as the draws come, then at the
pre-pass command buffer's end (vk_sync.c pre_end -> vk_exec_mesh_flush): allocation, every task stage, allocation,
every mesh stage, a barrier between each. One by one each draw took three barriers and copied the arena's counters
after the draw before it: an RX 580 spent 5.5 ms of a frame's GPU time on 69 draws' stages in Kokiri Forest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tobim6
2026-11-12 16:23:02 +01:00
parent f35e8d1eb2
commit ff1c1ed87a
5 changed files with 326 additions and 1 deletions

View File

@@ -764,6 +764,9 @@ void vk_sync_worker_end(VkCommandBuffer cb);
// The part's pre-pass command buffer: submitted right before the part being recorded (after its mirror prologue), begun
// with a full barrier at the first call of a part; VK_NULL_HANDLE when it cannot be made. Replay thread, sub_lock held.
VkCommandBuffer vk_sync_pre(void);
// vk_exec_draw.c: records into the pre-pass command buffer, as it ends, the stages of the emulated mesh draws queued
// for it (NX2NAVI_MESH_EMU_BATCH). A weak vk_sync.c version does nothing.
void vk_exec_mesh_flush(VkCommandBuffer cb);
// Ends the part being recorded without handing it to the queue (it goes with the next part that does, in order) and
// returns the command buffer the replay continues in; VK_NULL_HANDLE when no more parts can wait. Replay thread.
VkCommandBuffer vk_sync_cut(void);