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 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-10-25 19:00:06 +03:00
1 parent 6ece59b33e
commit dc3a0e906a
2 files changed
+12 -8

No files matched your search

+3 -2
View File
@@ -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
+9 -6
View File
@@ -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)");