mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 16:49:58 -04:00
Merge the shader stutter fixes into the combined test line.
Eight commits: a draw that misses its pipeline has the rest of its submission read ahead, the library workers link the pipelines of skipped draws, a pipeline whose fragment shader reads a target of its own pass is fast-linked like any other, and diagnostics. The merge was clean. Their before and after matrix had not finished when this was merged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -76,7 +76,7 @@ static struct {
|
||||
int indep; // stage-independent layouts (vk_caps.gpl): vertex set 0, fragment set 1
|
||||
int push_stage; // GFX_STAGE_* whose set is pushed with independent layouts
|
||||
int gpl; // draws whose pipeline is building get a fast-linked one (vk_caps.gpl)
|
||||
struct { uint64_t links, wlinks, dlinks, requeued, link_fail, defer, lib_n[4], lib_fail, swaps, slow, pre_used[4]; double link_ms, link_max, lib_ms[4], lib_max[4], dlink_ms, dlink_max; } g;
|
||||
struct { uint64_t links, fb_links, wlinks, flinks, dlinks, pr_added, lib_slow[4], ready_n[6], ready_nofast, hints, hint_libs, requeued, link_fail, defer, lib_n[4], lib_fail, swaps, slow, pre_used[4]; double pr_added_ms, lib_slow_ms[4], ready_ms, ready_max, link_ms, link_max, lib_ms[4], lib_max[4], dlink_ms, dlink_max; } g;
|
||||
int vs_outs_all; // NX2NAVI_VS_OUTS: 0 union of paired fragment inputs, 1 (all) all 32 output locations
|
||||
int dyn_vi, dyn_clamp, dyn_poly, dyn_blend_en, dyn_blend_eq, dyn_wmask, dyn_a2c;
|
||||
int f_logic_op, f_depth_clamp, f_fill_non_solid, f_dual_src, f_full_subgroups;
|
||||
@@ -134,6 +134,7 @@ typedef struct Pipe {
|
||||
uint8_t link_queued; // a waiting draw queued its fast link to the workers (LibJob p), not yet run
|
||||
uint8_t used; // compute: a dispatch of this run asked for it (vk_pipeline_compute)
|
||||
uint8_t pre; // compute: built and kept by the boot prebuild (lb_compute) or bg_main
|
||||
uint64_t t_miss; // graphics: when a draw first missed it (ns), 0 once it is usable (ready_note)
|
||||
size_t key_size;
|
||||
uint8_t key[];
|
||||
} Pipe;
|
||||
@@ -2619,8 +2620,8 @@ static Lib *libs[LIB_BUCKETS];
|
||||
typedef struct { uint32_t kind, topo_class, attr_fmt[32], attr_off[32]; uint8_t attr_bind[32], rate[17], pad[3]; } ViKey;
|
||||
typedef struct { uint32_t kind, missing; const GfxShader *vs; uint8_t clamp, poly_mode, minus_w, pad; GfxShaderIo fin[32]; } PrKey;
|
||||
typedef struct { uint32_t kind; uint8_t dsb, samples, a2c, pad; const GfxShader *fs; } FsKey;
|
||||
typedef struct { uint32_t kind; uint8_t n_color, samples, a2c, logic_op, blend_en, pad[3]; uint32_t color[8], depth, stencil, wmask;
|
||||
uint8_t blend[8][6]; } FoKey;
|
||||
typedef struct { uint32_t kind; uint8_t n_color, samples, a2c, logic_op, blend_en, fbl, pad[2]; uint32_t color[8], depth, stencil, wmask;
|
||||
uint8_t blend[8][6]; } FoKey; // fbl: GKey.fbl, the feedback loop flags of the library (gpl_feedback)
|
||||
|
||||
static uint64_t qpc(void) { return plat_now_ns(); }
|
||||
static double ms_since(uint64_t t0) { return (double)(qpc() - t0) / 1e6; }
|
||||
@@ -2732,6 +2733,11 @@ static VkPipeline lib_create(int kind, const VkPipeState *s, const GKey *k, VkPi
|
||||
ri.colorAttachmentCount = k->n_color, ri.pColorAttachmentFormats = (const VkFormat *)k->color;
|
||||
ri.depthAttachmentFormat = (VkFormat)k->depth, ri.stencilAttachmentFormat = (VkFormat)k->stencil;
|
||||
pi.pColorBlendState = &cb, pi.pMultisampleState = &ms;
|
||||
// Whether the pipeline may sample an attachment it renders to is part of the fragment output state: the flags
|
||||
// go on this library alone, and a pipeline linked from it has them (gpl_feedback).
|
||||
const FoKey *ok = key;
|
||||
if (ok->fbl & 1) pi.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
|
||||
if (ok->fbl & 2) pi.flags |= VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
|
||||
}
|
||||
VkPipelineCreationFeedbackCreateInfo fci;
|
||||
VkPipelineCreationFeedback fb;
|
||||
@@ -2814,6 +2820,8 @@ static VkPipeline lib_build(Lib *b, int kind, const VkPipeState *s, const GKey *
|
||||
plat_mutex_lock(&P.lock);
|
||||
P.g.lib_n[kind]++, P.g.lib_ms[kind] += ms;
|
||||
if (ms > P.g.lib_max[kind]) P.g.lib_max[kind] = ms;
|
||||
if (kind == LIB_PR && ((const PrKey *)(const void *)b->key)->missing) P.g.pr_added++, P.g.pr_added_ms += ms;
|
||||
if (ms >= 25) P.g.lib_slow[kind]++, P.g.lib_slow_ms[kind] += ms;
|
||||
}
|
||||
if (!pipe && ++P.g.lib_fail <= 8) rt_log("vk_pipeline: gpl: stage library %d not built", kind);
|
||||
b->pipe = pipe, b->building = 0;
|
||||
@@ -2897,19 +2905,48 @@ static void lib_keys(const VkPipeState *s, const GKey *k, ViKey *v, PrKey *pk, F
|
||||
fk->kind = LIB_FS, fk->fs = s->fs, fk->dsb = k->dsb, fk->samples = k->samples, fk->a2c = k->a2c;
|
||||
memset(ok, 0, sizeof *ok);
|
||||
ok->kind = LIB_FO, ok->n_color = k->n_color, ok->samples = k->samples, ok->a2c = k->a2c, ok->logic_op = k->logic_op;
|
||||
ok->blend_en = k->blend_en, ok->depth = k->depth, ok->stencil = k->stencil, ok->wmask = k->wmask;
|
||||
ok->blend_en = k->blend_en, ok->fbl = k->fbl, ok->depth = k->depth, ok->stencil = k->stencil, ok->wmask = k->wmask;
|
||||
memcpy(ok->color, k->color, sizeof ok->color), memcpy(ok->blend, k->blend, sizeof ok->blend);
|
||||
}
|
||||
|
||||
// p, which a draw missed, has its first usable pipeline: how long that took is how long its draws were skipped or
|
||||
// waited. fast 0: it had no fast link and this is the optimised build. Caller holds P.lock.
|
||||
static void ready_note(Pipe *p, int fast) {
|
||||
if (!p->t_miss) return;
|
||||
double ms = (double)(plat_now_ns() - p->t_miss) / 1e6;
|
||||
p->t_miss = 0;
|
||||
P.g.ready_n[ms < 4 ? 0 : ms < 8 ? 1 : ms < 17 ? 2 : ms < 50 ? 3 : ms < 150 ? 4 : 5]++;
|
||||
P.g.ready_ms += ms;
|
||||
if (ms > P.g.ready_max) P.g.ready_max = ms;
|
||||
P.g.ready_nofast += !fast;
|
||||
}
|
||||
|
||||
// NX2NAVI_GPL_FEEDBACK (default 1; 0 = as before): a pipeline whose fragment shader samples an attachment of its own pass
|
||||
// (VkPipeState.feedback: soft particles and water reading the depth buffer, decals, full-screen passes that read the
|
||||
// target they write) gets a fast link like any other. The feedback loop flags belong to the fragment output state, so
|
||||
// they are part of that library's key (FoKey.fbl) and of nothing else; the shader libraries are the ones the same
|
||||
// shaders use without a loop. Before, such a pipeline had no fast link at all and its draws waited for, or were
|
||||
// skipped during, the whole optimised build. On a first visit to Kokiri Forest (RTX 5090, every stage library in the
|
||||
// driver's cache, DLSS Frame Generation on, so no frame is held back) full-screen draws of such pipelines waited
|
||||
// 267 ms at the area's first frame and 410 ms in the middle of a walk; linked, 3 ms.
|
||||
static int gpl_feedback(void) {
|
||||
static int on = -1;
|
||||
if (on < 0) {
|
||||
on = cfg_bool("NX2NAVI_GPL_FEEDBACK");
|
||||
if (!on) rt_log("vk_pipeline: gpl: pipelines with a feedback loop get no fast link (NX2NAVI_GPL_FEEDBACK=0)");
|
||||
}
|
||||
return on;
|
||||
}
|
||||
|
||||
// A fast-linked pipeline for s from its stage libraries. Caller holds P.lock.
|
||||
// build 0 (drawing thread): links only when the shader libraries exist (vertex input and fragment output libraries,
|
||||
// which hold no shader, are built here); *final 0 = not yet, a worker builds them. build 1 (worker): builds the
|
||||
// missing libraries and links with P.lock released. VK_NULL_HANDLE with *final 1 when GPL cannot express the pipeline
|
||||
// (shared layout, feedback loop) or a build failed.
|
||||
// (shared layout; a feedback loop with NX2NAVI_GPL_FEEDBACK=0) or a build failed.
|
||||
static VkPipeline gpl_link(const VkPipeState *s, const GKey *k, const Layout *lc, int build, int *final) {
|
||||
Layout *l = (Layout *)lc;
|
||||
*final = 1;
|
||||
if (!l->set1 || k->fbl) return VK_NULL_HANDLE;
|
||||
if (!l->set1 || (k->fbl && !gpl_feedback())) return VK_NULL_HANDLE;
|
||||
uint64_t t0 = qpc();
|
||||
ViKey vk_;
|
||||
PrKey pk;
|
||||
@@ -2942,7 +2979,7 @@ static VkPipeline gpl_link(const VkPipeState *s, const GKey *k, const Layout *lc
|
||||
P.g.link_ms += ms;
|
||||
if (ms > P.g.link_max) P.g.link_max = ms;
|
||||
}
|
||||
if (pipe) P.g.links++;
|
||||
if (pipe) P.g.links++, P.g.fb_links += k->fbl != 0;
|
||||
else if (!P.g.link_fail++) rt_log("vk_pipeline: gpl: fast link failed; such draws wait or skip as without GPL");
|
||||
double total = ms_since(t0);
|
||||
if (!build && total > 5.0 && P.g.slow++ < 16)
|
||||
@@ -3186,6 +3223,7 @@ static void u_run(LibJob *lj) {
|
||||
VkPipeline f = gpl_link(&lj->s, &lj->k, lj->l, 1, &final); // releases P.lock while linking
|
||||
if (f && !p->info.pipeline) {
|
||||
p->fast = p->info.pipeline = f;
|
||||
ready_note(p, 1);
|
||||
job_lower(p->job); // its job now only does the optimised build
|
||||
} else if (f) {
|
||||
vkDestroyPipeline(P.device, f, NULL); // the job published one meanwhile
|
||||
@@ -3201,17 +3239,74 @@ static void u_run(LibJob *lj) {
|
||||
free(lj);
|
||||
}
|
||||
|
||||
// A worker for waiting draws' jobs only (U): a draw that waits finds one free even while the pool builds pipelines,
|
||||
// so the drawing thread never builds a library itself.
|
||||
// NX2NAVI_PIPE_FAST_WORKERS (default 1; 0 = as before): the library workers also take the fast link of a draw-queue job
|
||||
// (fast_take). A draw that is skipped rather than waiting leaves its pipeline to the pool, where a job is first
|
||||
// fast-linked and then goes back in the queue for its optimised build. The pool keeps one worker out of optimised
|
||||
// builds, so with the others inside one (about 100 ms each with the driver's cache warm, 350 ms cold) that single
|
||||
// worker linked every new pipeline of a burst, one after another at 5 to 10 ms each. On a first visit to Kokiri
|
||||
// Forest (RTX 5090, libraries in the driver's cache) 180 of the 444 pipelines draws missed took over 50 ms to become
|
||||
// usable, the longest 1.3 s, and their draws were missing from every frame until then; with the library workers
|
||||
// linking, 23 did, 19 of them mesh pipelines, which have no fast link.
|
||||
static int fast_workers(void) {
|
||||
static int on = -1;
|
||||
if (on < 0) on = cfg_bool("NX2NAVI_PIPE_FAST_WORKERS");
|
||||
return on;
|
||||
}
|
||||
|
||||
// The first draw-queue job whose pipeline still lacks its fast link, taken out of the queue; NULL when there is none.
|
||||
// Caller holds P.lock.
|
||||
static Job *fast_take(void) {
|
||||
if (!P.gpl || !fast_workers()) return NULL;
|
||||
for (Job *j = A.head, *prev = NULL; j; prev = j, j = j->next) {
|
||||
Pipe *p = j->p;
|
||||
if (p->info.pipeline || p->fast_tried || p->link_queued || !p->lay || is_mesh(&j->s)) continue;
|
||||
if (prev) prev->next = j->next;
|
||||
else A.head = j->next;
|
||||
if (A.tail == j) A.tail = prev;
|
||||
j->next = j->prev = NULL;
|
||||
return j;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// A worker for stage libraries and fast links only: a waiting draw's jobs (U) first, so a draw that waits finds one
|
||||
// free even while the pool builds pipelines and the drawing thread never builds a library itself; then the fast link
|
||||
// of a draw-queue job (fast_take), whose optimised build goes on to the pool.
|
||||
static void lib_worker(void *arg) {
|
||||
(void)arg;
|
||||
plat_mutex_lock(&P.lock);
|
||||
for (;;) {
|
||||
while (!U.head) plat_cond_wait(&lib_cv, &P.lock);
|
||||
LibJob *lj = U.head;
|
||||
if (!(U.head = lj->next)) U.tail = NULL;
|
||||
if (lj->b) lj->b->job = NULL;
|
||||
u_run(lj);
|
||||
Job *j = NULL;
|
||||
while (!U.head && !(j = fast_take())) plat_cond_wait(&lib_cv, &P.lock);
|
||||
if (!j) {
|
||||
LibJob *lj = U.head;
|
||||
if (!(U.head = lj->next)) U.tail = NULL;
|
||||
if (lj->b) lj->b->job = NULL;
|
||||
u_run(lj);
|
||||
continue;
|
||||
}
|
||||
Pipe *p = j->p;
|
||||
int final;
|
||||
p->fast_tried = 1; // no other thread links it meanwhile; a draw that waits for it waits for this link
|
||||
VkPipeline f = gpl_link(&j->s, &j->k, p->lay, 1, &final); // releases P.lock while building
|
||||
if (f && !p->info.pipeline) {
|
||||
p->fast = p->info.pipeline = f, P.g.wlinks++, P.g.flinks++;
|
||||
ready_note(p, 1);
|
||||
plat_cond_broadcast(&done_cv);
|
||||
} else if (f) {
|
||||
vkDestroyPipeline(P.device, f, NULL);
|
||||
}
|
||||
if (p->info.pipeline) { // the optimised build: ahead of the prebuild, behind other draws' misses
|
||||
j->low = 1, P.g.requeued++;
|
||||
j->next = A.low;
|
||||
if (A.low) A.low->prev = j;
|
||||
else A.low_tail = j;
|
||||
A.low = j;
|
||||
} else { // no fast link for this one: its whole build, next in the draw queue
|
||||
if (!(j->next = A.head)) A.tail = j;
|
||||
A.head = j;
|
||||
}
|
||||
plat_cond_signal(&work_cv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3259,6 +3354,7 @@ static void pipe_worker(void *arg) {
|
||||
j->p->fast_tried = 1;
|
||||
if (f && !j->p->info.pipeline) {
|
||||
j->p->fast = j->p->info.pipeline = f, P.g.wlinks++;
|
||||
ready_note(j->p, 1);
|
||||
plat_cond_broadcast(&done_cv);
|
||||
j->low = 1, j->worker = -1, P.g.requeued++;
|
||||
j->prev = NULL, j->next = A.low;
|
||||
@@ -3275,6 +3371,7 @@ static void pipe_worker(void *arg) {
|
||||
VkPipeline pipe = create_graphics(&j->s, &j->k, j->l, j->fs_off);
|
||||
plat_mutex_lock(&P.lock);
|
||||
if (pipe || !j->p->fast) j->p->info.pipeline = pipe; // a failed optimised build keeps the fast-linked one
|
||||
ready_note(j->p, 0);
|
||||
if (pipe && j->p->fast) P.g.swaps++;
|
||||
j->p->building = 0;
|
||||
j->p->job = NULL;
|
||||
@@ -3300,6 +3397,8 @@ static void pipe_worker(void *arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
static int hint_on(void);
|
||||
|
||||
// Starts the pool on first use: a quarter of the logical processors, 2 to 4. Caller holds P.lock.
|
||||
static int workers_start(void) {
|
||||
if (A.threads) return 1;
|
||||
@@ -3310,8 +3409,12 @@ static int workers_start(void) {
|
||||
if (!t) break;
|
||||
A.thread[A.threads++] = t; // kept: promote() raises a worker running a prebuild job
|
||||
}
|
||||
// two for waiting draws' libraries and links (the vertex and fragment libraries of one draw in parallel)
|
||||
for (int i = 0; A.threads && U.on && P.gpl && i < 2; i++)
|
||||
// Workers for stage libraries and fast links alone: two (the vertex and fragment libraries of one waiting draw in
|
||||
// parallel), and as many as the pool has with the look-ahead, which queues the libraries of a whole submission's
|
||||
// new pipelines at once (vk_pipeline_hint), or with the fast links of skipped draws (lib_worker). They sleep
|
||||
// unless a library or a fast link is queued.
|
||||
int nlib = hint_on() || fast_workers() ? n : 2;
|
||||
for (int i = 0; A.threads && U.on && P.gpl && i < nlib; i++)
|
||||
if (plat_thread_new(lib_worker, NULL, "pipe lib worker")) U.lib_workers++;
|
||||
if (A.threads)
|
||||
rt_log("vk_pipeline: %d background graphics pipeline workers, %d for waiting draws' libraries", A.threads,
|
||||
@@ -3355,6 +3458,7 @@ int vk_pipeline_async_on(void) { return A.on; }
|
||||
static void promote(Pipe *p) {
|
||||
Job *j = p->job;
|
||||
if (!j || !j->low) return;
|
||||
if (j->prebuild && !j->demanded && !p->info.pipeline) p->t_miss = plat_now_ns();
|
||||
j->low = 0, j->demanded = 1;
|
||||
if (j->worker < 0) {
|
||||
if (j->prev) j->prev->next = j->next;
|
||||
@@ -3366,6 +3470,7 @@ static void promote(Pipe *p) {
|
||||
else A.head = j;
|
||||
A.tail = j;
|
||||
plat_cond_signal(&work_cv);
|
||||
if (U.lib_workers) plat_cond_signal(&lib_cv); // its fast link (lib_worker)
|
||||
} else if (A.prio_low[j->worker]) {
|
||||
A.prio_low[j->worker] = 0;
|
||||
plat_thread_set_priority(A.thread[j->worker], PLAT_PRIO_NORMAL);
|
||||
@@ -3425,6 +3530,7 @@ static Pipe *pipe_miss(const VkPipeState *s, const GKey *k, uint64_t h, int mode
|
||||
}
|
||||
j->p = p;
|
||||
p->building = 1, p->job = j;
|
||||
if (mode != 2) p->t_miss = plat_now_ns();
|
||||
if (mode == 2) {
|
||||
j->prev = A.low_tail;
|
||||
if (A.low_tail) A.low_tail->next = j;
|
||||
@@ -3435,6 +3541,7 @@ static Pipe *pipe_miss(const VkPipeState *s, const GKey *k, uint64_t h, int mode
|
||||
if (A.tail) A.tail->next = j;
|
||||
else A.head = j;
|
||||
A.tail = j;
|
||||
if (U.lib_workers && fast_workers()) plat_cond_signal(&lib_cv); // its fast link (lib_worker)
|
||||
}
|
||||
A.inflight++;
|
||||
plat_cond_signal(&work_cv);
|
||||
@@ -3536,6 +3643,42 @@ static void lib_wait(const VkPipeState *s, const GKey *k, Layout *l, double end)
|
||||
}
|
||||
}
|
||||
|
||||
// ---- stage libraries ahead of their draws (NX2NAVI_PIPE_AHEAD, default 1; 0 off; vk_exec.c "looking ahead")
|
||||
// The replay names the state of a draw it has not reached yet. When no pipeline is known for it, its pre-rasterization
|
||||
// and fragment shader libraries are queued to the library workers now, so they build while the draws before it are
|
||||
// recorded, in parallel with each other and with those of the other draws named: the draw's own lookup then finds both
|
||||
// and links on its thread in microseconds instead of waiting for them or being skipped while they build. Nothing else
|
||||
// is entered, no pipeline, no optimised build and no key record: a state the scan guessed wrong costs two libraries
|
||||
// at most. The feedback loop bits, the topology and the targets do not matter here, as no shader library depends on
|
||||
// them. Returns the libraries queued.
|
||||
static int hint_on(void) {
|
||||
static int on = -1;
|
||||
if (on < 0) on = cfg_bool("NX2NAVI_PIPE_AHEAD");
|
||||
return on;
|
||||
}
|
||||
|
||||
int vk_pipeline_hint(const VkPipeState *s) {
|
||||
if (!A.on || !U.on || !hint_on() || !s->vs || !ensure_init() || !P.gpl || !P.indep || is_mesh(s)) return 0;
|
||||
if (gfx_shader_stage(s->vs) != GFX_STAGE_VS || (s->fs && gfx_shader_stage(s->fs) != GFX_STAGE_FS)) return 0;
|
||||
GKey k;
|
||||
gkey_fill(s, &k);
|
||||
if (k.topo_class == 3) return 0;
|
||||
uint64_t h = key_hash(&k, sizeof k);
|
||||
int queued = 0;
|
||||
plat_mutex_lock(&P.lock);
|
||||
if (!pipe_find(&k, sizeof k, h)) {
|
||||
Bindings B = {0}, F = {0};
|
||||
Layout *l = add_stage(&B, s->vs, 0) && (!s->fs || add_stage(&F, s->fs, 0)) ? layout_pair(&B, &F) : NULL;
|
||||
Lib *b[2];
|
||||
uint64_t q0 = U.queued, w0 = U.waits;
|
||||
if (l && l->set1 && workers_start() && lib_queue(s, &k, l, b)) queued = (int)(U.queued - q0);
|
||||
U.waits = w0, U.queued = q0; // those count waiting draws' jobs
|
||||
P.g.hints++, P.g.hint_libs += (uint64_t)queued;
|
||||
}
|
||||
plat_mutex_unlock(&P.lock);
|
||||
return queued;
|
||||
}
|
||||
|
||||
static VkPipeline graphics(const VkPipeState *s, const VkPipeInfo **info, int async, int *pending, uint32_t wait_ms) {
|
||||
if (info) *info = NULL;
|
||||
if (pending) *pending = 0;
|
||||
@@ -3594,6 +3737,7 @@ static VkPipeline graphics(const VkPipeState *s, const VkPipeInfo **info, int as
|
||||
if (final) p->fast_tried = 1;
|
||||
if (f && !p->info.pipeline) {
|
||||
p->fast = p->info.pipeline = f;
|
||||
ready_note(p, 1);
|
||||
job_lower(p->job);
|
||||
plat_cond_broadcast(&done_cv);
|
||||
} else if (f) {
|
||||
@@ -3614,7 +3758,6 @@ static VkPipeline graphics(const VkPipeState *s, const VkPipeInfo **info, int as
|
||||
VkPipeline pipe = p ? p->info.pipeline : VK_NULL_HANDLE;
|
||||
plat_mutex_unlock(&P.lock);
|
||||
if (wait) {
|
||||
perf_count(PERF_CNT_PIPE_SKIP);
|
||||
if (pending) *pending = 1;
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
@@ -3650,6 +3793,7 @@ static void warm_builder(void *arg) {
|
||||
VkPipeline pipe = create_graphics(&j->s, &j->k, j->l, j->fs_off);
|
||||
plat_mutex_lock(&P.lock);
|
||||
if (pipe || !j->p->fast) j->p->info.pipeline = pipe; // a failed optimised build keeps the fast-linked one
|
||||
ready_note(j->p, 0);
|
||||
if (pipe && j->p->fast) P.g.swaps++;
|
||||
j->p->building = 0;
|
||||
j->p->job = NULL;
|
||||
@@ -5749,14 +5893,27 @@ static int cache_save(uint32_t wait_ms) {
|
||||
static void save_with(uint32_t wait_ms) {
|
||||
if (P.ready) keys_flush(), pb_flush(), cu_flush(), cf_log();
|
||||
if (P.ready && P.gpl) {
|
||||
rt_log("vk_pipeline: gpl: %llu fast links (%llu by workers; avg %.2f ms, max %.2f ms, %llu failed), %llu draws "
|
||||
rt_log("vk_pipeline: gpl: %llu fast links (%llu by workers, %llu of those by the library workers for skipped draws; "
|
||||
"%llu of pipelines with a feedback loop; avg %.2f ms, "
|
||||
"max %.2f ms, %llu failed), %llu draws "
|
||||
"lookups found shader libraries missing (left to a worker), %llu optimised pipelines swapped in (%llu queued "
|
||||
"low after their fast link), %llu drawing-thread links over 5 ms; %llu waiting draws built their libraries "
|
||||
"(avg %.2f ms, max %.2f ms)",
|
||||
(unsigned long long)P.g.links, (unsigned long long)P.g.wlinks, P.g.links ? P.g.link_ms / P.g.links : 0.0,
|
||||
(unsigned long long)P.g.links, (unsigned long long)P.g.wlinks, (unsigned long long)P.g.flinks,
|
||||
(unsigned long long)P.g.fb_links,
|
||||
P.g.links ? P.g.link_ms / P.g.links : 0.0,
|
||||
P.g.link_max, (unsigned long long)P.g.link_fail, (unsigned long long)P.g.defer,
|
||||
(unsigned long long)P.g.swaps, (unsigned long long)P.g.requeued, (unsigned long long)P.g.slow,
|
||||
(unsigned long long)P.g.dlinks, P.g.dlinks ? P.g.dlink_ms / P.g.dlinks : 0.0, P.g.dlink_max);
|
||||
uint64_t rn = P.g.ready_n[0] + P.g.ready_n[1] + P.g.ready_n[2] + P.g.ready_n[3] + P.g.ready_n[4] + P.g.ready_n[5];
|
||||
rt_log("vk_pipeline: gpl: pipelines a draw missed were usable after under 4 ms %llu, 4-8 ms %llu, 8-17 ms %llu, "
|
||||
"17-50 ms %llu, 50-150 ms %llu, longer %llu (avg %.1f ms, longest %.0f ms); %llu of them had no fast link",
|
||||
(unsigned long long)P.g.ready_n[0], (unsigned long long)P.g.ready_n[1], (unsigned long long)P.g.ready_n[2],
|
||||
(unsigned long long)P.g.ready_n[3], (unsigned long long)P.g.ready_n[4], (unsigned long long)P.g.ready_n[5],
|
||||
rn ? P.g.ready_ms / (double)rn : 0.0, P.g.ready_max, (unsigned long long)P.g.ready_nofast);
|
||||
if (P.g.hints)
|
||||
rt_log("vk_pipeline: gpl: looking ahead named %llu pipeline states not known yet and queued %llu stage libraries "
|
||||
"for them", (unsigned long long)P.g.hints, (unsigned long long)P.g.hint_libs);
|
||||
if (U.waits || U.queued)
|
||||
rt_log("vk_pipeline: gpl: library jobs for waiting draws: %llu queued, %llu built by a worker, %llu by the "
|
||||
"thread that needed them (no worker free), %llu waits ended at their limit; %llu fast links on the %d "
|
||||
@@ -5765,8 +5922,13 @@ static void save_with(uint32_t wait_ms) {
|
||||
(unsigned long long)U.timeouts, (unsigned long long)U.links, U.lib_workers);
|
||||
static const char *const kn[4] = {"vertex input", "pre-rasterization", "fragment shader", "fragment output"};
|
||||
for (int i = 0; i < 4; i++)
|
||||
rt_log("vk_pipeline: gpl: %s libraries %llu (avg %.2f ms, max %.2f ms)", kn[i], (unsigned long long)P.g.lib_n[i],
|
||||
P.g.lib_n[i] ? P.g.lib_ms[i] / P.g.lib_n[i] : 0.0, P.g.lib_max[i]);
|
||||
rt_log("vk_pipeline: gpl: %s libraries %llu (avg %.2f ms, max %.2f ms; %llu of 25 ms or more, %.0f ms in all)",
|
||||
kn[i], (unsigned long long)P.g.lib_n[i], P.g.lib_n[i] ? P.g.lib_ms[i] / P.g.lib_n[i] : 0.0, P.g.lib_max[i],
|
||||
(unsigned long long)P.g.lib_slow[i], P.g.lib_slow_ms[i]);
|
||||
if (P.g.pr_added)
|
||||
rt_log("vk_pipeline: gpl: %llu of the pre-rasterization libraries had outputs added for their fragment shaders "
|
||||
"(avg %.1f ms): another module than the one the preparation built, so the driver's cache has none of them",
|
||||
(unsigned long long)P.g.pr_added, P.g.pr_added_ms / (double)P.g.pr_added);
|
||||
if (LB.n)
|
||||
rt_log("vk_pipeline: gpl: prebuilt libraries a draw used: pre-rasterization %llu, fragment shader %llu; "
|
||||
"compute pipelines built on the replay thread %llu", (unsigned long long)P.g.pre_used[LIB_PR],
|
||||
|
||||
Reference in New Issue
Block a user