diff --git a/runtime/vk_exec.c b/runtime/vk_exec.c index 2709471d..ea91731c 100644 --- a/runtime/vk_exec.c +++ b/runtime/vk_exec.c @@ -491,18 +491,28 @@ static int tfr_recent(const VkExecTarget *t, uint64_t stamp) { return tfr_match(e, t) && (e->last == stamp ? e->prev : e->last) == stamp - 1; } +// No frame before the current one rendered the target (a slot another subresource took reads the same). +static int tfr_first(const VkExecTarget *t, uint64_t stamp) { + const TargetFrames *e = tfr_slot(t); + return !tfr_match(e, t) || !(e->last == stamp ? e->prev : e->last); +} + +// With any, a recent depth target alone does not make the pass per-frame when a colour target is rendered for the +// first time: the game's item icon capture (an inventory or Fuse icon) draws into a new colour target with the +// per-frame depth buffer, once. Its draws skipped there stay missing from the icon until the item is captured again. int vk_exec_targets_recent(VkExec *ex, int any) { resolve_rt(ex); uint64_t stamp = __atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED) + 1; - int n = 0, recent = 0; + int n = 0, color = 0, depth = 0, color_first = 0; for (int i = 0; i < 9; i++) { const VkExecTarget *t = i < 8 ? &ex->color[i] : &ex->depth; if (!t->image) continue; n++; - if (tfr_recent(t, stamp)) recent++; + if (tfr_recent(t, stamp)) *(i < 8 ? &color : &depth) = 1; else if (!any) return 0; + else if (i < 8 && tfr_first(t, stamp)) color_first = 1; } - return any ? recent > 0 : n > 0; + return any ? color || (depth && !color_first) : n > 0; } // One line naming each target of the current pass: format, extent, layer and the two frames it was last rendered in diff --git a/runtime/vk_exec.h b/runtime/vk_exec.h index 9e61e34a..550cedce 100644 --- a/runtime/vk_exec.h +++ b/runtime/vk_exec.h @@ -142,8 +142,9 @@ void vk_hdr_draw(VkExec *ex, const VkPipeInfo *info); // Scissor 0 clipped to the render area of the open pass; extent 0: nothing to draw. VkRect2D vk_exec_scissor(const VkExec *ex); void vk_exec_noatt_dims(const VkExec *ex, uint32_t *w, uint32_t *h); // pass size when no attachment is set -// 1: every target of the current pass (any 1: at least one) was rendered in the previous presented frame (per-frame -// targets); 0 otherwise, or when the pass has none. +// 1: every target of the current pass (any 1: at least one, and not only the depth target while a colour target is +// rendered for the first time) was rendered in the previous presented frame (per-frame targets); 0 otherwise, or when +// the pass has none. int vk_exec_targets_recent(VkExec *ex, int any); // The current pass's targets with their formats, extents and the frames they were last rendered in (diagnostics). void vk_exec_targets_describe(VkExec *ex, char *buf, size_t cap); diff --git a/runtime/vk_exec_draw.c b/runtime/vk_exec_draw.c index 45bd084a..c54be52e 100644 --- a/runtime/vk_exec_draw.c +++ b/runtime/vk_exec_draw.c @@ -2017,7 +2017,8 @@ static void bind_vertex_buffers(VkExec *ex) { // that was not counts as one-shot and waits. // any (1): also draws in a pass with at least one target rendered in the previous frame (a per-frame depth // buffer or g-buffer with a colour target the frame before did not use: half-resolution effect buffers in fights). -// Passes with none (volumes, LUTs, shadow layers seen for the first time) still wait. +// Passes with none (volumes, LUTs, shadow layers seen for the first time) still wait, and so do passes whose only +// recent target is the depth buffer while a colour target is rendered for the first time (item icon captures). // fullscreen (2, default): as any, and full-screen draws into such passes are skipped instead of waiting from their // budget. A full-screen pass whose stage libraries are cold in the driver cache took 86 ms on average (up to 194 ms) // in a fight on an RX 9070: three frames in a row each spent the 50 ms budget, and some of the draws were skipped