mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 15:19:58 -04:00
Keep samples-passed counters inside parallel groups, and lock the shared tables only while a chunk records.
Samples-passed resets and reports ended most groups in Hyrule Field (the game reports twice without a reset there, so counting stays on): the front pass now replays them in the order of the stream, makes each occlusion segment and queues its completion callback in that order, and each worker follows the counting from its chunk's first op and adds the queries it closes to the segment the stream gives them. Per-object motion takes a lock instead of waiting for the earlier chunks: its list's order does not change the picture. The locks the chunks share are taken only inside a chunk, as outside groups the submitting thread alone replays; taken always, they cost the replay about 1 ms a frame. The perf line counts the draws by what ended their group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2541,8 +2541,9 @@ void vk_mem_shadow_sync(uint64_t fence) {
|
||||
plat_mutex_unlock(&shadow_lock);
|
||||
}
|
||||
|
||||
// The replay workers (vk_exec.c) bind and write from several threads at once: a mirror's first use in a submission
|
||||
// (creation, sync) and the notes of GPU writes go under use_lock. A use the submission already synced takes no lock.
|
||||
// The replay workers (vk_exec.c) bind and write from several threads at once: while a chunk records, a mirror's first
|
||||
// use in a submission (creation, sync) and the notes of GPU writes go under use_lock. A use the submission already
|
||||
// synced takes no lock, nor does the replay outside a parallel group (it alone records then).
|
||||
static PlatMutex use_lock = PLAT_MUTEX_INIT;
|
||||
|
||||
static void mem_use_locked(VkMemSpan *sp);
|
||||
@@ -2553,9 +2554,12 @@ void vk_mem_use(VkMemSpan *sp) {
|
||||
sp->buffer = r->mbuf;
|
||||
return;
|
||||
}
|
||||
plat_mutex_lock(&use_lock);
|
||||
// a refused pool not due for another try stays imported: nearly every pool in the field (two have mirrors)
|
||||
if (r->mstate == MS_REFUSED && !(r->retry_sub && (int32_t)(msub - r->retry_sub) >= 0)) return;
|
||||
int lk = vk_exec_in_chunk();
|
||||
if (lk) plat_mutex_lock(&use_lock);
|
||||
mem_use_locked(sp);
|
||||
plat_mutex_unlock(&use_lock);
|
||||
if (lk) plat_mutex_unlock(&use_lock);
|
||||
}
|
||||
|
||||
static void mem_use_locked(VkMemSpan *sp) {
|
||||
@@ -2577,9 +2581,10 @@ void vk_mem_pick(VkMemSpan *sp) {
|
||||
PoolRec *r = sp->pool;
|
||||
if (!r || r->mstate != MS_ON) return;
|
||||
if (r->acc_sub != msub) {
|
||||
plat_mutex_lock(&use_lock);
|
||||
int lk = vk_exec_in_chunk();
|
||||
if (lk) plat_mutex_lock(&use_lock);
|
||||
if (r->acc_sub != msub) mirror_sync(r);
|
||||
plat_mutex_unlock(&use_lock);
|
||||
if (lk) plat_mutex_unlock(&use_lock);
|
||||
}
|
||||
sp->buffer = r->mbuf;
|
||||
}
|
||||
@@ -3168,14 +3173,16 @@ static void gpu_wrote_range(const VkMemSpan *sp, uint64_t size, int shader) {
|
||||
range_add(&wbl, &nwbl, &cwbl, r, sp->offset + o, size - o); // what found no snapshot room
|
||||
}
|
||||
void vk_mem_gpu_wrote(const VkMemSpan *sp, uint64_t size) {
|
||||
plat_mutex_lock(&use_lock);
|
||||
int lk = vk_exec_in_chunk();
|
||||
if (lk) plat_mutex_lock(&use_lock);
|
||||
gpu_wrote(sp, size, 0);
|
||||
plat_mutex_unlock(&use_lock);
|
||||
if (lk) plat_mutex_unlock(&use_lock);
|
||||
}
|
||||
void vk_mem_gpu_wrote_shader(const VkMemSpan *sp, uint64_t size) {
|
||||
plat_mutex_lock(&use_lock);
|
||||
int lk = vk_exec_in_chunk();
|
||||
if (lk) plat_mutex_lock(&use_lock);
|
||||
gpu_wrote(sp, size, 1);
|
||||
plat_mutex_unlock(&use_lock);
|
||||
if (lk) plat_mutex_unlock(&use_lock);
|
||||
}
|
||||
|
||||
// Adds [a, b) to l, n sorted ranges that do not touch; returns the new count. Above cap ranges (l holds cap + 1) the two
|
||||
|
||||
Reference in New Issue
Block a user