mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 13:39:58 -04:00
Land the shader and pipeline stutter pass, and the fixes it needed.
Large compute shaders that no cache holds are built on one background thread after the boot prebuild, smallest first, so their first dispatch no longer compiles them on the replay thread. NX2NAVI_BIG_BUILD_MAX_MB stops that builder once the process has grown by that much: on a 31 GB machine one of these shaders took the process up by 12.8 GB and the game stuttered while Windows paged. The builder takes the queue under its lock and copies each entry out before compiling it, so a shader queued meanwhile cannot free the arrays under it. The same change reports what pipeline-cache.bin gives back, and starts over when the file grows past NX2NAVI_PIPELINE_CACHE_MAX_MB. A tensor-core program is now tested before its shader is asked for, in both dispatch paths. It runs the stand-in while NX2NAVI_NATIVE_TENSOR is off, and translating it anyway recorded four AI-upscaler shaders of 0.87 to 4.4 million SPIR-V words that this game never dispatches natively. Process memory went from 29.3 GB to 24 GB and the multi-gigabyte builds during play are gone. The frame-time summary says which part a slow frame went to, and with NX2NAVI_REPLAY_TIME how the replay splits between draws, binds and transfers; NX2NAVI_SVC_SLOW_MS logs the kernel services that block, with the thread they blocked on. prof_report.py reads the map this build writes and adds the image base to a runtime Rip, so a profile resolves to function names instead of question marks. build_xlate.py applies the patches with GIT_CEILING_DIRECTORIES set to the build folder's parent. Inside a checkout git read 0021-prmt-byte-permute.patch's paths from the repository's top, skipped every file of it and still exited 0, so PRMT was missing from locally built translators and every byte permute was a no-op. A Skipped patch line now fails the build. The note in AmpereLowering.cs that said the translator emits nothing for PRMT is corrected.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "kernel.h"
|
||||
#include "prof.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define R_OK 0u
|
||||
@@ -1675,7 +1676,7 @@ static void cv_hook(void) {
|
||||
if (h) h();
|
||||
}
|
||||
|
||||
int kern_svc(Cpu *c, uint32_t imm) {
|
||||
static int kern_svc_inner(Cpu *c, uint32_t imm) {
|
||||
uint64_t *x = c->x;
|
||||
if (g_diag > 0 && tcur) tcur->dg_svc = imm;
|
||||
switch (imm) {
|
||||
@@ -2397,3 +2398,21 @@ HOST_OVERRIDE(KERN_SYM_INITIALIZE_FIBER, kern_fiber_initialize);
|
||||
HOST_OVERRIDE(KERN_SYM_FINALIZE_FIBER, kern_fiber_finalize);
|
||||
HOST_OVERRIDE(KERN_SYM_SWITCH_TO_FIBER, kern_fiber_switch);
|
||||
HOST_OVERRIDE(KERN_SYM_GET_CURRENT_FIBER, kern_fiber_current);
|
||||
|
||||
// NX2NAVI_SVC_SLOW_MS (default 0, off): logs each kernel service that blocks longer than that, with the service number.
|
||||
// A stalled frame shows up as time in the replay; this says whether the guest was waiting in a service, and which one,
|
||||
// instead of leaving it to a sampler to find.
|
||||
int kern_svc(Cpu *c, uint32_t imm) {
|
||||
static double lim = -1;
|
||||
if (lim < 0) lim = strtod(cfg_value("NX2NAVI_SVC_SLOW_MS"), NULL);
|
||||
if (lim <= 0) return kern_svc_inner(c, imm);
|
||||
uint64_t t0 = plat_now_ns();
|
||||
int r = kern_svc_inner(c, imm);
|
||||
double ms = (plat_now_ns() - t0) / 1e6;
|
||||
if (ms >= lim) {
|
||||
uint32_t tid = plat_thread_id();
|
||||
rt_log("kernel: service %#x blocked %.1f ms on thread %u%s", imm, ms, tid,
|
||||
tid == prof_replay_tid ? " (the replay thread)" : "");
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user