mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 21:49:57 -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:
@@ -4606,6 +4606,10 @@ static void op_dispatch(VkExec *ex, const p_dispatch *d) {
|
||||
vk_contact_flush(ex);
|
||||
cb_res(ex);
|
||||
dummies_init();
|
||||
// A tensor-core program runs the stand-in while NX2NAVI_NATIVE_TENSOR is off, so ask that before translating it.
|
||||
// Translating it anyway recorded four AI-upscaler compute shaders of 0.87-4.4M SPIR-V words that this game never
|
||||
// dispatches natively, and building them cost gigabytes of memory at boot (NX2NAVI_LIB_PREBUILD_BIG, bg_main).
|
||||
if (!native_tensor(ex)) { untranslated_dispatch_fallback(ex); return; }
|
||||
int present;
|
||||
const GfxShader *cs = shader_for(ex, NVN_STAGE_CS, &present, NULL, 0); // synchronous: a skipped dispatch changes results
|
||||
if (knob_log_cs_binds()) { // diagnosis: the compute bindings of the first dispatch of each program
|
||||
@@ -4657,6 +4661,7 @@ static void op_dispatch_ind(VkExec *ex, const p_dispatch_ind *d) {
|
||||
return warn_once(W_INDIRECT, "indirect dispatch arguments at %#llx are not backed or not aligned: skipped", (unsigned long long)d->ind);
|
||||
cb_res(ex);
|
||||
dummies_init();
|
||||
if (!native_tensor(ex)) { untranslated_dispatch_fallback(ex); return; } // as in op_dispatch: never translate it
|
||||
int present;
|
||||
const GfxShader *cs = shader_for(ex, NVN_STAGE_CS, &present, NULL, 0);
|
||||
if (!cs || !native_tensor(ex)) { untranslated_dispatch_fallback(ex); return; }
|
||||
@@ -4730,7 +4735,7 @@ static void bind_handles(uint64_t *dst, int cap, const p_bind_handles *b) {
|
||||
memcpy(&dst[b->first], b->h, sizeof(uint64_t) * (size_t)b->n);
|
||||
}
|
||||
|
||||
void vk_exec_op_draw(VkExec *ex, uint32_t op, const void *payload) {
|
||||
static void op_draw_impl(VkExec *ex, uint32_t op, const void *payload) {
|
||||
switch (op) {
|
||||
case OP_BIND_PROGRAM: {
|
||||
const p_bind_program *b = payload;
|
||||
@@ -4840,3 +4845,27 @@ void vk_exec_op_draw(VkExec *ex, uint32_t op, const void *payload) {
|
||||
|
||||
// The last executed list's draws as " <position banks>/<changed banks>:<draws>" (bit n: cn), for NX2NAVI_MV_CHECK's lines.
|
||||
const char *vk_mvobj_frame_masks(void) { return fm_last; }
|
||||
|
||||
// NX2NAVI_REPLAY_TIME (default 0, off): times each op so the frame-time summary can say how the replay splits between
|
||||
// draws, binds and transfers. The clock reads cost a fraction of a millisecond a frame, which is why it is off by
|
||||
// default and why the wrapper is the only thing between the walk and the switch.
|
||||
static int op_is_draw(uint32_t op) {
|
||||
switch (op) {
|
||||
case OP_DRAW: case OP_DRAW_IDX: case OP_DRAW_IDX_IND:
|
||||
case OP_DISPATCH: case OP_DISPATCH_IND:
|
||||
case OP_DRAW_MESH: case OP_DRAW_MESH_IND:
|
||||
case OP_UPDATE_UB:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void vk_exec_op_draw(VkExec *ex, uint32_t op, const void *payload) {
|
||||
static int on = -1;
|
||||
if (on < 0) on = cfg_bool("NX2NAVI_REPLAY_TIME");
|
||||
if (!on) { op_draw_impl(ex, op, payload); return; }
|
||||
uint64_t t0 = plat_now_ns();
|
||||
op_draw_impl(ex, op, payload);
|
||||
perf_replay_op(op_is_draw(op) ? PERF_RP_DRAW : PERF_RP_BIND, plat_now_ns() - t0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user