mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-23 05:25:56 +00:00
Stamp deferred frees with the submission being recorded, whichever thread destroys the object
With the synchronous replay (the default since 7be68ec) a game thread finalizing a texture destroys released texture
cache entries while another game thread records a submission that slot_resolve may already have handed one of them.
defer() saw the recording's value only on the recording thread and stamped the others with the last submitted value,
so the completion thread freed the image before the submission naming it ran: "write invalid" device faults on NVIDIA
(#788, #802). vk_sync_submit now notes the value at the start of the recording, and every deferral made from then on
waits for it. A fight run counted 10 such deferrals during the world load.
Device faults now log the deferred-free state, and with VK_EXT_device_address_binding_report the object that held the
faulting address and whether it was unbound before the fault (TOTK_ADDR_REPORT=0 turns the map off). The census line
counts deferrals made off the recording thread during a recording.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6e5074e203
commit
dc45de0e9a
4 files changed
+128
-27
No files matched your search
+4
-3
@@ -309,7 +309,7 @@ void vk_sync_start(void) {
|
||||
if (reserved < now) reserved = now;
|
||||
stop = 0;
|
||||
plat_mutex_unlock(&st_lock);
|
||||
vk_mem_note_submit(now);
|
||||
vk_mem_note_fence(now);
|
||||
completion_thread = plat_thread_new(completion_main, c, "vk completion");
|
||||
if (!completion_thread) rt_fatal("vk: cannot start the completion thread");
|
||||
__atomic_store_n(&started, 1, __ATOMIC_RELEASE);
|
||||
@@ -379,7 +379,6 @@ VkCommandBuffer vk_sync_split(void) {
|
||||
vk_device_fault_report(r);
|
||||
rt_fatal("vk: vkQueueSubmit2 of a part of value %llu failed (%d)", (unsigned long long)cur_fence, (int)r);
|
||||
}
|
||||
vk_mem_note_submit(cur_fence); // objects destroyed from here on may be in use by the part just submitted
|
||||
CmdSlot *s = take_slot(c, cur_fence); // the submitted part keeps its slot until the value is reached
|
||||
rec_begin(s->cb, cur_fence, VK_CRUMB_SUBMIT, cur_fence);
|
||||
ts_begin(s->cb);
|
||||
@@ -404,6 +403,9 @@ uint64_t vk_sync_submit(const uint64_t *handles, int n) {
|
||||
vk_mem_dirty_submit(); // TOTK_TRACE=perf: what a mirror would upload before this submit
|
||||
uint64_t fence = __atomic_load_n(&issued, __ATOMIC_ACQUIRE) + 1;
|
||||
cur_fence = fence;
|
||||
// Before the first object is resolved: what any thread destroys from here on waits for this value (vk_memory.c
|
||||
// defer), since the recording may already name it.
|
||||
vk_mem_note_fence(fence);
|
||||
CmdSlot *s = take_slot(c, fence);
|
||||
uint64_t t0 = perf_begin();
|
||||
rec_begin(s->cb, fence, VK_CRUMB_SUBMIT, fence); // begun by the recorder when it records the part
|
||||
@@ -434,7 +436,6 @@ uint64_t vk_sync_submit(const uint64_t *handles, int n) {
|
||||
rt_fatal("vk: vkQueueSubmit2 of value %llu failed (%d)", (unsigned long long)fence, (int)r);
|
||||
}
|
||||
s->fence = recorded ? fence : 0;
|
||||
vk_mem_note_submit(fence);
|
||||
plat_mutex_lock(&st_lock);
|
||||
__atomic_store_n(&issued, fence, __ATOMIC_RELEASE);
|
||||
plat_cond_broadcast(&cv_work);
|
||||
|
||||
Reference in new issue
Block a user