Merge main into the test line: the pull requests taken there and two render target fixes.

Main brought the fixes of eleven pull requests (the texture pool set sealed when an early replay part is submitted, every location reflected in interface arrays, RGB9E5 texels recognised for integer storage views, the upscaler a frame started with kept, GPU pass timestamps without vendor breadcrumbs, the Linux build, window and NGX fixes), render targets released when drawn over at another address, the vertex layout kept in the pipeline on newer AMD drivers, and the upscaler choice read once per evaluation.

Four hunks conflicted and take both sides: pool_sync returns for a sealed set before the per-frame creation budget's clock (vk_exec_draw.c); make_module keeps the test line's early_ok argument and main's module hash (vk_pipeline.c); a texture taken back counts as sampled again and records how long it was away, and the texture line logs the disuse counters and the overwritten render targets (vk_texture.c).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-09 21:10:23 -05:00
27 changed files with 1205 additions and 144 deletions

View File

@@ -578,6 +578,7 @@ static int texel_bytes(VkFormat f) {
case VK_FORMAT_R16G16_SINT: case VK_FORMAT_R16G16_SFLOAT: case VK_FORMAT_R16G16_UNORM: case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R8G8B8A8_SINT: case VK_FORMAT_R8G8B8A8_UNORM: case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_A2B10G10R10_UINT_PACK32: case VK_FORMAT_A2B10G10R10_UNORM_PACK32: case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
return 4;
case VK_FORMAT_R32G32_UINT: case VK_FORMAT_R32G32_SINT: case VK_FORMAT_R32G32_SFLOAT: case VK_FORMAT_R16G16B16A16_UINT:
case VK_FORMAT_R16G16B16A16_SINT: case VK_FORMAT_R16G16B16A16_SFLOAT: case VK_FORMAT_R16G16B16A16_UNORM: return 8;
@@ -1706,8 +1707,13 @@ static void tex_info_full(VkExec *ex, const GfxShaderRes *r, uint64_t h, int sto
// dialogue frames, a fifth of them; none once each submission waited for its GPU work, NX2NAVI_SUBMIT_FINISH). A
// submission's first pool_sync takes the next set (pool_take_set), waits for the GPU only if that set's last
// submission is still running, and brings it up to date from the change log (every entry written since the set was
// last current; the whole set when the log has wrapped). Writes within a submission go to its own set at once, as
// before.
// last current; the whole set when the log has wrapped). Writes within a submission go to its own set at once, until a
// part of the submission goes to the queue early (vk_exec.c maybe_split): that part may read any entry of the set, so
// the set is sealed (vk_exec_pool_split) and the next sync takes the following set as if a new submission began.
// Writing into it instead updated descriptors a pending command buffer reads, which Vulkan does not allow: the part
// sampled textures registered after it went, and on RADV a texture whose memory was mapped after the part's submit is
// absent from that submit's page tables, a GPU page fault on the 128x128 probe pass of Kokiri Forest's first frame
// (RADV's radv_wait_for_vm_map_updates hid it, as did NX2NAVI_SPLIT_DRAWS=0).
volatile uint32_t vk_pool_kinds_used;
#define POOL_SETS 4
#define POOL_LOG (1u << 20) // entries of the change log: binding * VK_POOL_TEX + id, one per write
@@ -1726,7 +1732,7 @@ static struct {
uint64_t switches, waits, catchup, written, rewrites, catch_ns, sync_ns, n_slots, n_refill, n_fresh;
uint64_t n_by_reg, n_by_addr; // refills whose token changed by a registration, by an address generation only
uint64_t dirty_pos; // vk_texture_dirty_slots_locked position (0: the next sync walks every slot)
int ready, uab;
int ready, uab, sealed; // sealed: a part of the current submission already reads sets[cur]
uint32_t kinds, gen, epoch, sgen;
int retry; // the last sync left slots to the creation budget
uint64_t frame, frame_ns; // the frame of the last sync, and the sync time spent in it (pool_create_ns)
@@ -1991,18 +1997,29 @@ static void pool_entry_to(VkDescriptorSet set, uint32_t e) {
// A submission's first pool use: the next set of the ring, once the GPU is done with it. 1 when it switched; *from is
// the log position the set holds writes up to (pool_catch_up brings it level once pool_sync has refreshed the entries:
// a view written into a set must be alive, and the refresh is what replaces the views of destroyed textures).
static int pool_current(void);
static int pool_take_set(VkExec *ex, uint64_t *from) {
if (PL.cur_fence == ex->fence) return 0;
// a sealed set stays bound while it is current: reading it is what the pending part does too
if (PL.cur_fence == ex->fence && (!PL.sealed || pool_current())) return 0;
int i = (PL.cur + 1) % PL.nsets;
if (PL.nsets > 1) {
const GfxBackend *b = gfx_backend();
if (b->fence_done() < PL.set_fence[i]) PL.waits++, b->fence_wait(PL.set_fence[i], UINT64_MAX);
}
*from = PL.set_synced[i];
PL.cur = i, PL.set = PL.sets[i], PL.cur_fence = ex->fence, PL.set_fence[i] = ex->fence;
PL.cur = i, PL.set = PL.sets[i], PL.cur_fence = ex->fence, PL.set_fence[i] = ex->fence, PL.sealed = 0;
return PL.nsets > 1;
}
int vk_exec_pool_split(uint64_t fence) {
if (PL.cur_fence != fence || PL.sealed) return 1; // no part of this submission has the current set unsealed
// pool_take_set moves to the next set of the ring: it must not be bound by this submission's earlier parts too
if (PL.nsets < 2 || PL.set_fence[(PL.cur + 1) % PL.nsets] == fence) return 0;
PL.sealed = 1;
return 1;
}
// The current set gets the entries written into other sets in [from, to) of the log, as PL.view / PL.samp hold them now.
static uint64_t pool_memo_hits; // pool_fill: slots that shared another slot's lookup (defined with pool_memo below)
@@ -2130,6 +2147,7 @@ static void pool_sync(VkExec *ex) {
if (!PL.layout) vk_pool_set_layout();
uint64_t from = 0, pre = PL.logn;
int switched = pool_take_set(ex, &from); // every submission its own set, before the shortcut
if (PL.sealed) return; // current when checked: a change since waits for the next sync, which takes a new set
uint64_t t0 = kern_now_ns(), f = __atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED);
if (f != PL.frame) PL.frame = f, PL.frame_ns = 0;
pool_sync_entries(ex);
@@ -2169,6 +2187,12 @@ static void pool_dirty_slot(int id, void *arg) { // vk_texture_dirty_slots_loc
else d->retry = 1;
}
// Every entry as the slots, kinds and samplers are now (pool_sync_entries has nothing to write).
static int pool_current(void) {
return PL.ready && !PL.retry && __atomic_load_n(&vk_pool_kinds_used, __ATOMIC_RELAXED) == PL.kinds &&
vk_texture_slots_gen() == PL.gen && vk_texture_epoch() == PL.epoch && vk_sampler_gen() == PL.sgen;
}
static void pool_sync_entries(VkExec *ex) {
uint32_t used = __atomic_load_n(&vk_pool_kinds_used, __ATOMIC_RELAXED);
uint32_t gen = vk_texture_slots_gen(), ep = vk_texture_epoch(), sg = vk_sampler_gen();