mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-15 19:19:58 -04:00
Write a GPU-drawn texture back to its storage before dropping it, when the fence write-back would have.
An entry the GPU drew into since its last write-back holds texels its storage lacks; the fence write-back (vk_texture_write_back_small) sends such targets back when the CPU waits, about once a frame. An entry dropped before that, for a budget, a commit or video memory squeeze, its release or a replacement at its address, went without, and a texture the game then made again from that storage started from what the storage held before the GPU drew. drop_tex now writes such an entry back first when the fence write-back would take it (wb_wanted) and the CPU has not rewritten the storage since. An entry another target drew over (its storage is the newer one's) and drops at shutdown are left as they are. The commit drop pause counts the drop either way (comment beside commit_drop_note). The perf line of texture origins counts the write-backs. Checked: the runtime compiles; --probe-vkmem passes (164 GPU checks, 0 validation errors; it needs a writable TEMP). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1679,8 +1679,27 @@ static int commit_drops_held(void) {
|
||||
}
|
||||
|
||||
// destroy_tex with the reason, which every caller gives.
|
||||
// An entry the GPU drew into since its last write-back holds texels its storage lacks. Dropped for a reason that leaves
|
||||
// the storage to the game (a budget, a commit or video memory squeeze, its release, a replacement at its address), a
|
||||
// texture the game makes again from that storage (the drawn-once maps the fence write-back is for, moved or remade)
|
||||
// would start from what the storage held before the GPU drew. Such an entry goes back first when the fence write-back
|
||||
// would take it (wb_wanted) and the CPU has not rewritten its storage since; the commit drop pause above counts it the
|
||||
// same either way. Not an entry another target drew over (DROP_OVERWRITTEN: the storage is the newer one's), nor at
|
||||
// shutdown.
|
||||
static int wb_wanted(const Tex *e);
|
||||
static void wb_cfg_init(void);
|
||||
static int storage_rewritten(const Tex *e, uint32_t since, uint32_t *now);
|
||||
static void write_back_n(Tex **v, int n);
|
||||
static uint64_t n_drop_wb; // entries written back before their drop since the last perf line
|
||||
|
||||
static void drop_tex(Tex *e, int why) {
|
||||
if (why == DROP_COMMIT || why == DROP_IDLE_COMMIT) commit_drop_note(e);
|
||||
if (e->gpu_dirty && why != DROP_OVERWRITTEN && why != DROP_SHUTDOWN) {
|
||||
uint32_t now;
|
||||
wb_cfg_init();
|
||||
if (storage_rewritten(e, e->gpu_gen, &now) == 1) e->gpu_dirty = 0;
|
||||
else if (wb_wanted(e)) write_back_n(&e, 1), n_drop_wb++;
|
||||
}
|
||||
n_drop_by[why]++;
|
||||
if (rt_trace & RT_TRACE_PERF)
|
||||
drops[ndrops++ % DROPS_N] = (DropRec){key_hash(&e->key), e->key.addr, frames_now(), (uint32_t)e->t.d.format,
|
||||
@@ -4091,12 +4110,12 @@ void vk_texture_new_submit(void) {
|
||||
rt_log("perf: frame %llu: texture origins: released entries dropped past RELEASED_MAX %llu, replaced by another "
|
||||
"descriptor at their address %llu; entries the CPU does not write made without content at an address it "
|
||||
"can see: on their own %llu, over a released entry %llu, over a live one %llu; marked slots that met an "
|
||||
"entry without content %llu, that show no entry %llu",
|
||||
"entry without content %llu, that show no entry %llu; GPU-drawn entries written back before their drop %llu",
|
||||
(unsigned long long)f * 60, (unsigned long long)n_drop_by[DROP_MAX], (unsigned long long)n_drop_by[DROP_REPLACED],
|
||||
(unsigned long long)n_cpu_empty[0], (unsigned long long)n_cpu_empty[1], (unsigned long long)n_cpu_empty[2],
|
||||
(unsigned long long)n_mark_empty, (unsigned long long)n_mark_none);
|
||||
(unsigned long long)n_mark_empty, (unsigned long long)n_mark_none, (unsigned long long)n_drop_wb);
|
||||
memset(n_drop_by, 0, sizeof n_drop_by), memset(n_cpu_empty, 0, sizeof n_cpu_empty);
|
||||
n_mark_empty = n_mark_none = 0;
|
||||
n_mark_empty = n_mark_none = n_drop_wb = 0;
|
||||
rt_log("perf: frame %llu: texture finalizes: slots marked %llu; slots of another live texture with the same "
|
||||
"parameters at the storage, left current %llu (terrain heightmaps %llu); lookups the stale rule gave the "
|
||||
"stand-in %llu (terrain heightmaps %llu)", (unsigned long long)f * 60, (unsigned long long)n_fin_own,
|
||||
|
||||
Reference in New Issue
Block a user