Repository navigation
Prevent synchronous shader compilation during TOTK pipeline lookahead - #29
Merged
ly05010419 merged 1 commit intoOct 19, 2026
Conversation
This was referenced Oct 19, 2026
tvc97
added a commit
to tvc97/MacNativeGames
that referenced
this pull request
Oct 19, 2026
…05010419#30) Brings in upstream ly05010419#29 (bounded pipeline prediction without translation, stale guesses reclaimed) and ly05010419#30 (in-game libraries and pipelines in the background, plus the present residency and compile-options fixes). Conflict resolution in nvn_mtl.m / hle_nvn.c: took the branch side, re-applied what main has since ly05010419#29's base (ly05010419#13 warm_precompile, ly05010419#17 compact HUD), and kept main's prebuilt-library hit/miss diagnostic. Our earlier prediction-table drain (pso_pend_drain into g_pso, prog_get_cached, mtl_pp_stats and its log line) is replaced by ly05010419#29's version. It no longer skips pso_user.tsv for drained pipelines. Checked: make runtime-v143 (58 warnings, none new), 38 source tests, probe-gfx pass, 3 empty-cache async boots without a GPU fault. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ly05010419
added a commit
that referenced
this pull request
Oct 19, 2026
…uesses for depth export; limits, statistics and negative controls Follow-ups to PR #29: - prog_prediction_stages: a program with a stage not translated yet (iOS, pr->missing) is not predicted; its draws are skipped and its fragment stage can be absent. - pred_guess_wanted: a fragment function that exports depth gets no guesses without the depth buffer. ds_scan attaches depth for it, so those guesses were never used, and pso_desc compiled their depth-less library on the submission thread. - Scan limits TOTK_PSO_PREDICT_SCAN / _KEYS (up to 160) / _US, defaults as in the PR (8192 commands, 32 keys, 2000 us), logged once. - A statistics line every 100 scans: scans and the budget that ended them, pipelines started and taken, waits for the background, guesses refused (table full) and stale guesses freed. - probe-gfx: a program with an untranslated stage is not predicted; no depth-less guess for depth export. verify_gfx.py runs negatives 24-27 (active variant taken, every slot freed, untranslated stages ignored, depth-less guesses made); each fails at its own check. - The deferred-binds probe now reacts only to TOTK_PROBE_NEGATIVE=1, as its comment says: any value used to reach it first, so later probe-gfx negatives could not be reached. - docs/pipeline-prediction-stalls.md: contributor-local paths removed; what still runs on the submission thread; the in-game comparison (one session per configuration, no speed-up claimed). Co-Authored-By: Claude Opus 5.5 <[email protected]>
tvc97
added a commit
to tvc97/MacNativeGames
that referenced
this pull request
Oct 19, 2026
Upstream merged ly05010419#29 with follow-ups (c5b3ae7): prediction limits and statistics, and probe-gfx negative controls 24-27. Conflicts in nvn_mtl.m: - prog_prediction_stages: upstream's missing-stage skip with negative 26; pr->missing also covers stages still loading in the background. - pso_pend_reclaim: keeps demand slots (a draw waits for them), and takes upstream's negative 25 and reclaim count. - pso_pend_kick: keeps the demand flag and upstream's table-full count. - pso_predict_rest: upstream's max_keys bound, guesses kicked with demand 0. pso_pend_poll, the async path's wait, now adds to upstream's waited-for statistics as pso_pend_take does. Checked: nvn_mtl.m and hle_nvn.c compile, nvn_mtl.m with 58 warnings, the same as upstream main; 79 source tests pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scene changes can stall the submission thread while the pipeline predictor synchronously translates and compiles shaders for later draws. This PR makes lookahead use only already-resolved binding variants, bounds the scan, and reclaims completed predictions that were never consumed.
Changes
probe-gfxwith unknown-program, alternate-binding and pending-slot lifetime regressions; preserve the existing scissor/conditional-counter checks.Evidence and scope
An Apple M3 / 24 GiB / macOS 27.2, game 1.0.0 session recorded 32 relative long-frame entries above one second, all accompanied by shader-library or pipeline creation. The worst frame was 10,384.9 ms (submission/presentation 10,378.8 ms; GPU execution 17.5 ms). Nested compilation timers are not summed as independent wall time.
The player reports substantially fewer severe stalls with a broader local candidate that also contains opportunistic shader prefetching. That is not an isolated performance measurement of this PR. This narrower branch has build and CPU regression coverage, but has not been installed for a separate gameplay A/B. It does not claim to eliminate first-use compilation, fix global 1% lows, or deliver a particular FPS gain.
This PR contains only three source/documentation files. The prefetch queue, worker-process signal-mask changes, frame pacing, resolution, interpolation, keys, game files, saves, shader caches and generated apps are excluded. Further frame-rate optimization will be a separate PR.
Validation
hle_nvn.candtotk_shader_rt.mso the test binary excludes the local prefetch feature. Renderer compilation emits 58 warnings; not described as warning-free.probe-gfx: passed, including all three added checks. No Metal device or GPU drawing; the normal probe initialization maps the existing game modules, without booting the game or changing its profile.git diff --check: passed.Raw local evidence stays outside the repository;
docs/pipeline-prediction-stalls.mdrecords the method, evidence locations and limits.Related work