mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 09:39:58 -04:00
vk_astc_scratch_trim runs at every present and held the decoder's lock while vk_defer_buffer waited for cmd_lock. The upload path takes the two locks the other way round: vk_upload_begin takes cmd_lock, then vk_astc_record and scratch_get take the decoder's lock. A present that trimmed while another thread was between vk_upload_begin and scratch_get therefore hung both threads. Without the hang, the present still waited for as long as an upload flush held cmd_lock through its fence waits. vk_memory.c gets vk_defer_buffer_try, which defers only when it gets cmd_lock at once. When the lock is busy the trim leaves the scratch as it is, and the next present tries again. tests/astc_trim_check builds the real vk_astc.c with platform/common.c's recursive lock. It checks that the trim gives way while another thread holds cmd_lock, that it goes through once the lock is free, and that the forced interleaving ends. Before the change the check reported the deadlock (exit 2). Checks that passed: astc_trim_check, pass_cc_check on every runtime file (vk.h changed), no new -Wall -Wextra warnings in vk_astc.c and vk_memory.c, and the pass's test matrix (35 ok; the 6 failures are the baseline's). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8.0 KiB
8.0 KiB