Mesh emulation: the stages of a pass's emulated draws run before the pass, in a command buffer of their own.

Each emulated mesh draw ended the pass, ran its stages between four barriers and began the pass again: a pass of 20
emulated draws became 20 passes, and on an RX 580 6 to 7 ms of a frame's 30 ms of GPU time went to the gaps between
passes (gpu_passes in Kokiri Forest: 8.7-10 ms per frame outside the game's passes and dispatches, 6.3-7.7 ms of it in
273-306 gaps with barriers only; 71 emulated draws a frame, 36 of them indirect). Now the first emulated draw of a pass
ends the part there (vk_exec_split_now), so the pass begins a new part, and the stages of every emulated draw of that
pass, the indirect ones' ring entries included, go into the part's pre-pass command buffer (vk_sync_pre), which the
queue runs after the mirror prologue and before the part; the pass is not split again. NX2NAVI_MESH_EMU_BATCH=0 (Lama
patches: Mesh emulation before the pass) brings the split back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tobim6
2026-11-12 16:22:35 +01:00
parent 93e68d57f1
commit 55ab90c66e
9 changed files with 147 additions and 24 deletions

View File

@@ -1112,6 +1112,9 @@ static void set_rt(VkExec *ex, const p_set_rt *r) {
static int split_n = -1, split_idle, split_in_pass, split_draws, split_at, part_start;
static uint64_t split_ns, part_t0;
static uint64_t n_parts, n_subs, n_idle_parts, n_pass_splits;
int vk_exec_split_now(VkExec *ex) {
return 1;
}
static int split_wanted(void) {
if (split_draws >= split_at) return 1;
@@ -2082,9 +2085,10 @@ static uint32_t group_peek(const VkExec *ex, const op_hdr *h, const op_hdr **end
int begun = 0;
const p_set_rt *rt = &ex->rt;
*why = GE_LIMIT;
// mesh draws stay on the submitting thread with the mesh fallback (its buffers are shared) and while
// NX2NAVI_GPU_PASSES copies their workgroup counts (one list)
int mesh_serial = vk_ctx()->mesh_fallback || vk_gpu_passes_capturing();
// mesh draws stay on the submitting thread with the mesh fallback (its buffers are shared), with the mesh emulation
// (no VK_EXT_mesh_shader: its arena, queue and the part's pre-pass command buffer are the submitting thread's) and
// while NX2NAVI_GPU_PASSES copies their workgroup counts (one list)
int mesh_serial = vk_ctx()->mesh_fallback || !vk_ctx()->has_mesh_shader || vk_gpu_passes_capturing();
for (uint32_t ops = 0; ops < GROUP_PEEK; ops++) {
if (h->size < sizeof *h || (h->size & 7) || h->op >= OP_COUNT_) { *why = GE_RUN; break; } // the walk reports it
const void *a = nvn_op_payload(h);