mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 12:29:57 -04:00
Add diagnostics used to find these fixes, all off by default.
NX2NAVI_TRACE=audio logs voices starting, stopping and sharing a wave buffer; NX2NAVI_DUMP_MOVIE dumps movie frames; NX2NAVI_LOG_CS_BINDS says why the stand-in for an untranslated compute program skipped a dispatch; and NX2NAVI_TRACE=perf adds heap and commit census lines on their own thread, with VMA maps when write-combined memory grows by 2 GiB. From a tester's fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,6 +68,10 @@ typedef struct Mixer {
|
||||
float voice_scratch[6][MAX_FRAME], filter_scratch[MAX_FRAME], output_scratch[MAX_FRAME * OUT_MAX];
|
||||
double level_sum, level_peak; uint64_t level_count, level_frames; int first_sound_logged;
|
||||
int prefill; // render blocks
|
||||
uint64_t trace_pass, trace_seen[1024]; // NX2NAVI_TRACE=audio: render passes; the pass each voice was last mixed in
|
||||
uint64_t trace_buf[1024]; // and the wave buffer address it read in that pass
|
||||
uint64_t trace_pair[1024]; // the last shared-buffer pair logged for each voice (other voice, address)
|
||||
unsigned trace_shared; // "voices share a buffer" lines written (capped)
|
||||
} Mixer;
|
||||
|
||||
static _Atomic float device_volume = 1.0f;
|
||||
@@ -820,6 +824,7 @@ void audio_mixer_render(AudioRenderer *r, double seconds) {
|
||||
if (at > m->nbuf) { rt_log("audio: mixes use %d buffers, renderer has %d", at, m->nbuf); rt_fatal("audio mix buffer layout"); }
|
||||
|
||||
float (*vs)[MAX_FRAME]=m->voice_scratch,*filtered=m->filter_scratch;
|
||||
m->trace_pass++;
|
||||
for (int i = 0; i < r->param.voice_count; i++) {
|
||||
ServerVoice *v = &r->voices[i];
|
||||
if (!v->in.in_use || v->state != SV_STARTED || !v->in.sample_rate || !v->valid[v->index]) continue;
|
||||
@@ -832,6 +837,18 @@ void audio_mixer_render(AudioRenderer *r, double seconds) {
|
||||
v->in.sample_format == FMT_ADPCM || fmt_bytes(v->in.sample_format) ? "decoded" : "NOT decoded: silent",
|
||||
cc, (unsigned)v->in.sample_rate);
|
||||
}
|
||||
if ((rt_trace & RT_TRACE_AUDIO) && i < 1024) { // mixed now and not in the last pass: what it plays and where to
|
||||
const AudrenWaveBuffer *wb = &v->buffers[v->index & 3];
|
||||
if (m->trace_seen[i] + 1 != m->trace_pass) // pass: 5 ms each at 48 kHz (frame samples per pass)
|
||||
rt_log("audio: voice %d plays at pass %llu: format %u, %d channel(s) at %u Hz, buffer %u at %#llx+%#llx "
|
||||
"(%s%s), volume %.3f, pitch %.3f, mix %d, splitter %u, priority %d", i,
|
||||
(unsigned long long)m->trace_pass, (unsigned)v->in.sample_format, cc, (unsigned)v->in.sample_rate,
|
||||
v->index, (unsigned long long)wb->address, (unsigned long long)wb->size,
|
||||
wb->loop ? "loop" : "once", wb->end_of_stream ? ", end of stream" : "", v->in.volume, v->in.pitch,
|
||||
(int)v->in.mix_id, (unsigned)v->in.splitter_id, (int)v->in.priority);
|
||||
m->trace_seen[i] = m->trace_pass;
|
||||
m->trace_buf[i] = wb->address;
|
||||
}
|
||||
voice_render(r, v, vs, frames);
|
||||
for (int f = 0; f < 2; f++) if (v->in.biquads[f].enable) {
|
||||
const AudrenBiquad *b = &v->in.biquads[f];
|
||||
@@ -867,6 +884,31 @@ void audio_mixer_render(AudioRenderer *r, double seconds) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rt_trace & RT_TRACE_AUDIO) {
|
||||
// Voices mixed in the last pass and not in this one, and why; then voices that read the same wave buffer memory
|
||||
// in this pass (one stream heard twice, offset by how far apart the two read).
|
||||
for (int i = 0; i < r->param.voice_count && i < 1024; i++) {
|
||||
if (!m->trace_seen[i] || m->trace_seen[i] + 1 != m->trace_pass) continue; // 0: never mixed
|
||||
const ServerVoice *v = &r->voices[i];
|
||||
rt_log("audio: voice %d stops at pass %llu: %s; %llu samples played, %u buffers consumed", i,
|
||||
(unsigned long long)m->trace_pass,
|
||||
!v->in.in_use ? "released by the game" : v->state == SV_PAUSED ? "paused"
|
||||
: v->state != SV_STARTED ? "stopped by the game" : "out of wave buffers",
|
||||
(unsigned long long)v->played, (unsigned)v->consumed);
|
||||
}
|
||||
for (int i = 0; i < r->param.voice_count && i < 1024; i++) {
|
||||
if (m->trace_seen[i] != m->trace_pass || !m->trace_buf[i]) continue;
|
||||
for (int j = i + 1; j < r->param.voice_count && j < 1024 && m->trace_shared < 400; j++)
|
||||
if (m->trace_seen[j] == m->trace_pass && m->trace_buf[j] == m->trace_buf[i] &&
|
||||
m->trace_pair[i] != ((uint64_t)j << 48 ^ m->trace_buf[i])) { // once per pair and buffer
|
||||
m->trace_pair[i] = (uint64_t)j << 48 ^ m->trace_buf[i];
|
||||
m->trace_shared++;
|
||||
rt_log("audio: voices %d and %d both play the wave buffer at %#llx in pass %llu (offsets %llu and %llu)",
|
||||
i, j, (unsigned long long)m->trace_buf[i], (unsigned long long)m->trace_pass,
|
||||
(unsigned long long)r->voices[i].offset, (unsigned long long)r->voices[j].offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* submixes: deepest first, so every mix is complete before it is folded into its destination */
|
||||
int order[256], n = 0, depth[256];
|
||||
for (int i = 1; i < mc && n < 256; i++) if (r->mixes[i].in_use) { depth[n] = mix_depth(r, i); order[n++] = i; }
|
||||
|
||||
Reference in New Issue
Block a user