From dc3a0e906ad9d9124e65930a768c837a3795fcfe Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Sun, 25 Oct 2026 19:00:01 +0300 Subject: [PATCH] Reserve one pipeline worker for waiting draws' libraries only at the default TOTK_PIPE_WAIT, so TOTK_PIPE_WAIT=draw restores the old scheduling Co-Authored-By: Claude Opus 5.5 --- docs/agent-playbook.md | 5 +++-- runtime/vk_pipeline.c | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/agent-playbook.md b/docs/agent-playbook.md index b18f0ffe..9fdc6481 100644 --- a/docs/agent-playbook.md +++ b/docs/agent-playbook.md @@ -96,8 +96,9 @@ Check these classes before you re-investigate a symptom that looks like one of t waits for a fence, targets up to 64 KiB rendered before it go back too (`vk_texture.c` `vk_texture_write_back_small`): the 128x128 cut map is read with no invalidate. Without it a cut left the grass standing, with no blades and no insects. -- A one-shot draw (a target not rendered in the previous frame) waits for its shader and pipeline instead of being - skipped: `vk_exec_draw.c` `prepare_draw`. Skipping left the cloud and fog volumes empty for the session. +- A one-shot draw (a pass none of whose targets the previous frame rendered) waits for its shader and pipeline instead + of being skipped: `vk_exec_draw.c` `prepare_draw`, `TOTK_PIPE_SKIP`. Skipping left the cloud and fog volumes empty + for the session. Its stage libraries build on idle workers in parallel (`vk_pipeline.c` `lib_wait`). - Storage buffers bound by Ryujinx first-use order instead of the NVN c0 slot: `vk_exec_draw.c` `ssbo_slot`. It showed as tile rectangles. - 3D colour targets rejected: `vk_exec.c` `resolve_target`. The grading LUT was never written, so the dialog diff --git a/runtime/vk_pipeline.c b/runtime/vk_pipeline.c index 1ab28c9d..ffa82aed 100644 --- a/runtime/vk_pipeline.c +++ b/runtime/vk_pipeline.c @@ -1632,9 +1632,10 @@ static struct { LibJob *head, *tail; int idle; // workers asleep on work_cv int running; // jobs workers are building - int on; // TOTK_PIPE_WAIT: 1 workers (default), 0 the drawing thread builds them (draw) + int on; // TOTK_PIPE_WAIT: 1 workers (default), 0 the drawing thread builds them (draw); + // set by vk_pipeline_async_enable, before the replay runs uint64_t waits, queued, by_worker, stolen, timeouts; -} U = {.on = -1}; +} U; // A building entry for key, NULL when out of memory. Caller holds P.lock and found none. static Lib *lib_new(uint64_t h, const void *key, uint32_t size) { @@ -1998,8 +1999,9 @@ static DWORD WINAPI pipe_worker(void *arg) { int me = (int)(intptr_t)arg; AcquireSRWLockExclusive(&P.lock); for (;;) { - // With 3 or more workers one never takes low-queue work, so a waiting draw's library starts at once. - while (!U.head && !A.head && !(A.low && (A.threads < 3 || A.low_running < A.threads - 1))) { + // With 3 or more workers one never takes low-queue work, so a waiting draw's library starts at once + // (not with TOTK_PIPE_WAIT=draw). + while (!U.head && !A.head && !(A.low && (A.threads < 3 || !U.on || A.low_running < A.threads - 1))) { U.idle++; SleepConditionVariableSRW(&work_cv, &P.lock, INFINITE, 0); U.idle--; @@ -2117,6 +2119,8 @@ static void workers_drain(void) { } void vk_pipeline_async_enable(void) { + const char *w = cfg_get("TOTK_PIPE_WAIT"); + U.on = !(w && !strcmp(w, "draw")); const char *e = cfg_get("TOTK_PIPE_SYNC"); if (e && *e && strcmp(e, "0")) return; A.on = 1; @@ -2295,9 +2299,8 @@ static VkPipeline graphics(const VkPipeState *s, const VkPipeInfo **info, int as // leaves them to the job. static int draw_build = -1; if (draw_build < 0) { - const char *e = cfg_get("TOTK_GPL_DRAW_BUILD"), *w = cfg_get("TOTK_PIPE_WAIT"); + const char *e = cfg_get("TOTK_GPL_DRAW_BUILD"); draw_build = !(e && !strcmp(e, "0")); - U.on = !(w && !strcmp(w, "draw")); rt_log("vk_pipeline: a draw that waits for its pipeline %s", !draw_build ? "leaves its libraries to its job" : U.on ? "has its libraries built in parallel on the workers, ahead of other jobs" : "builds its libraries itself (TOTK_PIPE_WAIT=draw)");