mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 21:05:56 +00:00
Count NVN calls per thread and add them to the shared counter 1024 at a time: the main thread and the job workers record command buffers, and a locked add per call kept the counter's cache line moving between their cores
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e15d70fd4
commit
5b783728e5
1 file changed
+8
-1
@@ -24,8 +24,15 @@
|
||||
#define EVENT_MAGIC MAGIC('E', 'V', 'N', 'T')
|
||||
|
||||
// ---------- shared helpers (nvn_api.h)
|
||||
// The call count goes to the shared counter 1024 at a time: the main thread and the job workers all record command
|
||||
// buffers, and one locked add per call kept the counter's cache line moving between their cores (0.8k samples a
|
||||
// fight). The count lags by at most 1023 calls per thread.
|
||||
void nvn_called(uint8_t *seen, const char *name) {
|
||||
__atomic_fetch_add(&gfx_counters.nvn_calls, 1, __ATOMIC_RELAXED);
|
||||
static _Thread_local uint32_t calls;
|
||||
if (++calls == 1024) {
|
||||
__atomic_fetch_add(&gfx_counters.nvn_calls, calls, __ATOMIC_RELAXED);
|
||||
calls = 0;
|
||||
}
|
||||
if (__atomic_load_n(seen, __ATOMIC_RELAXED) || __atomic_exchange_n(seen, 1, __ATOMIC_RELAXED)) return;
|
||||
uint64_t n = __atomic_add_fetch(&gfx_counters.nvn_distinct, 1, __ATOMIC_RELAXED);
|
||||
NVN_LOG("first call %llu: %s", (unsigned long long)n, name);
|
||||
|
||||
Reference in new issue
Block a user