mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 06:29:58 -04:00
Refresh the texture pool from a list of its entries instead of walking every slot, for about 7 % more frames a second where the replay thread is the limit.
Each submission's first sync of the bindless texture pool walked every registered slot, 33,000 in Kokiri Forest, to find the few textures the CPU wrote and the few slots that changed. Three parts of that walk change, each with its own switch (pool_fast, pool_presnap, pool_group; on by default, 0 and ab accepted): - The freshness check goes through a list of the entries the slots resolved to, with a check by 2 MiB region first; slots that resolved to nothing are looked up again when the game's memory map changes and every eighth submission. The use stamps the idle eviction reads are left from a count of the slots that hold each entry. - The check takes the write-watch snapshots of its regions first, so unchanged entries pass the region test. - The GPU-written slots of one address bucket with one descriptor form a group, which the dirty walk leaves alone while its first member is unchanged. Measured on an RTX 5090 at 2560x1440, standing in Kokiri Forest, in-run A/B over five runs with all three switched (three of them with the barrier change switched too): 93.6 to 100.7, 96.4 to 103.1, 95.8 to 102.6, 99.3 to 107.1 and 91.9 to 99.9 frames a second, the replay thread 0.7 to 0.8 ms a frame shorter; a control's blocks differ by 0.4 %. On a walk with NX2NAVI_POOL_GROUP_CHECK=1 no group that was left alone had missed a write, and screenshots across the A and B blocks show the same picture. From pull request #390. Not tried: the texture eviction under memory pressure (a 9 GiB budget was never reached on the walk), AMD and Intel drivers, Linux. One of the nine runs with it on ended by itself with exit code 0 and nothing in its log two seconds after the window lost the focus; three repeats of that run did not. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
36
runtime/vk.h
36
runtime/vk.h
@@ -565,8 +565,42 @@ uint32_t vk_texture_entry_gen(void); // vk_texture.c: bumped by
|
||||
// Slots whose token may have changed since *pos (0 at first; then the value these calls leave): fn is called for each
|
||||
// (some more than once) and *pos advanced. 0 when too many changes came since: the caller looks at every slot. *pos
|
||||
// from vk_texture_dirty_pos_locked after such a walk. Texture lock held.
|
||||
int vk_texture_dirty_slots_locked(uint64_t *pos, void (*fn)(int id, void *arg), void *arg);
|
||||
// gfn, when given, gets each slot group of a bucket in place of fn for its members.
|
||||
int vk_texture_dirty_slots_locked(uint64_t *pos, void (*fn)(int id, void *arg), void (*gfn)(int g, void *arg), void *arg);
|
||||
// Slot groups (vk_texture.c): the GPU-written slots of one address bucket with one descriptor hash kh, which resolve
|
||||
// alike. head the first member, vk_texture_group_next_locked the next (-1: the end), n how many; stamp and fmask the
|
||||
// texture pool's (vk_exec_draw.c pool_dirty_group: 1 when every member holds the same views, of the kinds fmask; a slot
|
||||
// that joins goes to the tail, refilled on its own), set 0 by vk_texture_groups_unstamp_locked. Texture lock held.
|
||||
typedef struct { uint64_t kh; int32_t head, n; uint32_t stamp, fmask; } VkSlotGroup;
|
||||
VkSlotGroup *vk_texture_group_locked(int g);
|
||||
int vk_texture_group_next_locked(int id);
|
||||
void vk_texture_groups_unstamp_locked(void);
|
||||
uint64_t vk_texture_dirty_pos_locked(void);
|
||||
// The bindless pool's entries (vk_texture.c): after a pool fill of slot id, notes the entry it resolved to (1; 0: none)
|
||||
// and gives its number for vk_texture_pool_hold_locked in *ent (0: none); a submission's freshness check of every
|
||||
// noted entry (returns how many). Texture lock held.
|
||||
int vk_texture_pool_note_locked(int id, uint32_t *ent);
|
||||
int vk_texture_pool_fresh_locked(void);
|
||||
// A pool slot that held the entry old (0: none) now holds ent: the entries slots hold get the use stamps a lookup
|
||||
// leaves (vk_texture.c touch) from the check by list. Texture lock held.
|
||||
void vk_texture_pool_hold_locked(uint32_t old, uint32_t ent);
|
||||
// A slot whose last lookup found no entry, looked up again: 1 it resolves now; 0 still none, its storage may become
|
||||
// readable; -1 none until its token changes (a CPU slot whose texture was released after its registration, no storage).
|
||||
int vk_texture_slot_retry_locked(int id);
|
||||
// vk_memory.c, for the pool's freshness check: the generation table's lock, shared; with it held, 1 when every 2 MiB
|
||||
// region of [addr, addr+size) has this epoch's write-watch snapshot and no page stamped after since (nothing in it can
|
||||
// have changed), 0 when a closer look is due (vk_mem_changed_snap).
|
||||
void vk_mem_gen_lock_shared(void);
|
||||
void vk_mem_gen_unlock_shared(void);
|
||||
int vk_mem_unchanged_locked(uint64_t addr, uint64_t size, uint32_t since, uint32_t epoch);
|
||||
// The same check's reason when it fails: 1 a region without this epoch's snapshot yet, 2 one untracked, 3 one written
|
||||
// since, 4 nothing to check (no size, beyond the regions); 0 unchanged.
|
||||
int vk_mem_unchanged_why_locked(uint64_t addr, uint64_t size, uint32_t since, uint32_t epoch);
|
||||
// The lock exclusively, for the snapshot of the regions of [addr, addr+size) that have none in epoch yet (the number of
|
||||
// write-watch queries it took).
|
||||
void vk_mem_gen_lock(void);
|
||||
void vk_mem_gen_unlock(void);
|
||||
uint64_t vk_mem_snap_range_locked(uint64_t addr, uint64_t size, uint32_t epoch);
|
||||
void vk_sampler_dlss_bias(float bias); // texture LOD bias added for DLSS upscaling (material samplers)
|
||||
void vk_sampler_aniso_live(void); // each present: NX2NAVI_ANISO after a settings change (tiled samplers)
|
||||
uint32_t vk_sampler_gen(void); // changes whenever a sampler slot is registered
|
||||
|
||||
Reference in New Issue
Block a user