mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 15:09:58 -04:00
Make the ASTC scratch trim only try the upload lock, so it can no longer deadlock with an upload.
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>
This commit is contained in:
@@ -567,6 +567,8 @@ void vk_defer_view(VkImageView view);
|
||||
void vk_defer_free(void *p);
|
||||
int vk_exec_image_gone(VkImage image); // texture lock held: the replay's views of image go with it; returns how many
|
||||
void vk_defer_buffer(VkBuffer buf, VmaAllocation alloc);
|
||||
// As vk_defer_buffer without waiting: 0 when another thread holds the upload lock, and nothing is deferred.
|
||||
int vk_defer_buffer_try(VkBuffer buf, VmaAllocation alloc);
|
||||
// ---- ASTC (vk_astc.c). NX2NAVI_ASTC = auto | gpu | native | cpu | check; see vk_astc.c.
|
||||
enum { VK_ASTC_CPU, VK_ASTC_GPU, VK_ASTC_NATIVE, VK_ASTC_CHECK };
|
||||
int vk_astc_mode(void); // decided once per device (logged); VK_ASTC_CPU before vk_init
|
||||
|
||||
Reference in New Issue
Block a user