A render target's frame count follows its storage, not the guest's texture object, and a mesh draw no longer waits for a pipeline that is known to be compiling.

Found in the first run of the previous two commits (a first visit of Kokiri Forest from a state that had only seen Hyrule Field):

- The count of frames a target was rendered in started again whenever the guest's texture object changed, and the game initializes its render target objects anew every frame at the same storage: the log showed `seen 2129/2128 in 1 frames`, so no target ever became steady and the rule did nothing. The owner of an image is now the storage address the texture cache keys it by. An image handed on to a texture elsewhere still starts at none.
- A one-shot mesh draw waited its 8 ms in every frame that met the same pipeline while it compiled for 150 to 1100 ms: 17 waits, 170 ms, every draw skipped at the end, up to four in one frame. A mesh pipeline that has been building for longer than that wait is a compile, and the draws after the first do not wait for it (vk_pipeline_building_ms).
- The last wait of a full-screen draw with no picture to hold was 40 ms a draw, and two such draws made 86 ms in one frame. It is 40 ms a frame now.
- A one-shot vertex draw skipped at the end of its wait gets its log line however short the wait was (seven were skipped with no line, so their targets could not be named).

That run against the same cell of the earlier comparison (same exe path, cache state, route and settings; one run each): the load's worst wait of the draws in one frame 99 ms against 735 ms, no mesh wait over 13 ms against 524 and 206 ms. Two long frames remain in both runs (628 and 862 ms here, 660 and 854 ms there): two compute pipelines built at their first dispatch, about 395 and 397 ms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 12:14:29 -05:00
parent 9d257edf5a
commit e9ec6de6bc
6 changed files with 66 additions and 32 deletions

View File

@@ -18,12 +18,14 @@
// frames before, so each draw with a new pipeline waited on the replay thread, and a mesh draw, whose pipeline has no
// fast link, for its whole compile. One player's session shows it three times at area changes: frames of 954, 1015
// and 684 ms, six mesh draws waiting 52 to 660 ms each in passes whose targets had been rendered in thousands of
// frames. An entry therefore also counts the frames its subresource was rendered in, for as long as it is the same
// guest texture (its initialization serial: an image taken over by another texture starts again at none). From
// TFR_STEADY frames on the target is one the game draws again and again, and its draws are skipped while a pipeline
// builds, as in any other frame, however long ago the last one was. A target generated once never gets there; one
// generated again at every area load would after TFR_STEADY loads, by when its pipelines are recorded and prebuilt
// at the start.
// frames. An entry therefore also counts the frames its subresource was rendered in, for as long as the image is the
// texture at the same storage (its owner, the storage GPU address the texture cache keys the image by: an image
// handed on to a texture elsewhere starts again at none). The guest's texture object does not serve as the owner:
// the game initializes its render target objects anew every frame at the same storage, so a count kept per object
// never passed one. From TFR_STEADY frames on the target is one the game draws again and again, and its draws are
// skipped while a pipeline builds, as in any other frame, however long ago the last one was. A target generated once
// never gets there; one generated again at every area load would after TFR_STEADY loads, by when its pipelines are
// recorded and prebuilt at the start.
#pragma once
#include <stdint.h>
@@ -33,9 +35,9 @@
#define TFR_RECENT 4
#define TFR_STEADY 8
// One render target of a pass: the image handle as a number, the subresource, the guest texture's serial (0 unknown).
typedef struct { uint64_t image; uint32_t level, layer; uint64_t serial; } TfrTarget;
typedef struct { uint64_t image; uint32_t level, layer, n; uint64_t last, prev, serial; } TargetFrames;
// One render target of a pass: the image handle as a number, the subresource, the image's owner (0 unknown).
typedef struct { uint64_t image; uint32_t level, layer; uint64_t owner; } TfrTarget;
typedef struct { uint64_t image; uint32_t level, layer, n; uint64_t last, prev, owner; } TargetFrames;
static TargetFrames tfr[TFR_SETS * TFR_WAYS];
// The target's entry, or with make the entry it takes (the set's oldest, an empty one first); NULL without make
@@ -55,7 +57,7 @@ static inline TargetFrames *tfr_find(const TfrTarget *t, int make) {
// The target is rendered in frame stamp.
static inline void tfr_note(const TfrTarget *t, uint64_t stamp) {
TargetFrames *e = tfr_find(t, 1);
if (e->serial != t->serial) e->serial = t->serial, e->n = 0; // another texture has the image now: its own count
if (e->owner != t->owner) e->owner = t->owner, e->n = 0; // another texture has the image now: its own count
if (e->last != stamp) e->prev = e->last, e->last = stamp, e->n += e->n < UINT32_MAX;
}
@@ -73,10 +75,10 @@ static inline int tfr_recent(const TfrTarget *t, uint64_t stamp) {
// No frame before stamp rendered the target.
static inline int tfr_first(const TfrTarget *t, uint64_t stamp) { return !tfr_before(t, stamp); }
// TFR_STEADY frames or more before stamp rendered the target as the texture it is now.
// TFR_STEADY frames or more before stamp rendered the target under the owner it has now.
static inline int tfr_steady(const TfrTarget *t, uint64_t stamp) {
const TargetFrames *e = tfr_find(t, 0);
return e && e->serial == t->serial && e->n - (e->last == stamp) >= TFR_STEADY;
return e && e->owner == t->owner && e->n - (e->last == stamp) >= TFR_STEADY;
}
// Whether the pass with the n_color colour targets c and the depth target d (NULL: none) is one the game renders