Repository navigation
Conversation
davdxpx
marked this pull request as ready for review
November 25, 2026 11:18
…atch) The quick menu's coming Peanuts tab shows Smoother next start, marked experimental: stutters counted from the frame times the tab reads anyway, and shaders learned during play so the next start prepares them. This class is the contract between the tab and the backend that records the host's run-time shader builds; until a backend registers, the feature says it is not active.
… again The host learns every pipeline a run makes (the prewarm list), but on Qualcomm's driver before 512.800, the AYN Thor's own, the list is never made ahead: each pipeline holds memory outside the process there, so every start made its pipelines again while the game played and skipped their draws meanwhile. With Learn shaders while playing on for a game (the Peanuts tab, PN_SHADERWATCH=1), each run keeps the list's records it used, per game and driver (dm/peanuts/peanuts_swhot.h: hashes and the runs since each was used, at most 4,096, 64 KB), and the next start makes those first and before the game starts, behind Preparing shaders; where the driver does not prewarm, only those, by two threads that stop when memory is short. Records a game update or another shader library no longer has match nothing and age out. Off, nothing of it is read or written. dev.peanuts.shaders.HostWatch is the ShaderWatch backend, registered at the game's start: its numbers are the list's (vka_pso_watch through Bridge.shaderWatch), and the switch turned while the game runs applies at once (Bridge.shaderWatchLearn). Tests: peanuts/tests/test_shader_watch.py, HostCountsJvmTest, dm/host/tests/t_peanuts_swhot.c (make peanuts-swhot).
…edits docs/reference/rendering.md "Pipelines made again while playing at every start (Android)" with its symptom line, the Found on lines of Pokémon Legends: Z-A and Tomodachi Life: Living the Dream, the hook sites in PEANUTS.md and the section in peanuts/UPSTREAM-EDITS.md.
…in words The class comment of dev.peanuts.shaders.ShaderWatch named a page and a board of the design canvas, which readers of the repository cannot see (test_no_canvas_pointers). It now says what it means: a switch per game in the quick menu's Peanuts tab.
… and made ahead too The prewarm list never holds a capture pipeline: it draws with its vertex shader's capture variant (vka_tf.c), whose modules carry the layout the game's program declares at nvnProgramSetShaders, and a start that makes pipelines before the game has no layout noted yet. So every start made them again while the game played. With learning on, pw_note hands such a pipeline to sw_tf_note, which keeps its record (the variant's base vertex shader), key bytes and layout in a file of the game and driver beside the .hot file (<list>.<driver>.tf, dm/peanuts/peanuts_swtf.h: at most 64 entries, each with an entry in the .hot file, so it ages out with it). The next start makes those first, before the list's records, and waits for them with the others: vka_tf_learned makes the variant with the stored layout and the same checks as a draw's, then sw_tf_make asks for its pipeline as the frame path will. A draw's first use of such a variant checks that this run's program declares the same layout; else the variant is dead and the draw makes its own as before. Entries whose shaders are gone, of the other vertex input form, or on a device without transform feedback are skipped and age out. Off, pw_note returns at a capture variant as before and nothing is read or written. vka_tf.c's variants are appended under its lock (a prewarm thread adds them now too), caps() runs once.
…nd the startup line counts what the start waits for
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.
Every pipeline a game makes while you play is already kept in its prewarm list, and the next start makes the list ahead. On Qualcomm's own driver before 512.800, the AYN Thor's system driver, that has always been off: the driver keeps memory outside the app for each pipeline, so making a game's whole list ahead ran games out of memory. So on that driver every start made the same pipelines again while you played, with objects missing for a moment and hitches each time, and the next start forgot it again.
Smoother next start (a switch per game in the quick menu's Peanuts tab, Experimental, off by default) fixes that from the second start on, for every game. This PR is the part behind the switch; the Peanuts tab itself comes in its own PR.
Goes straight onto main. The first commit, "Peanuts tab: the contract for learning shaders while playing (ShaderWatch)", is the Peanuts tab's contract with this backend: one file,
dev.peanuts.shaders.ShaderWatch, which the tab's own PR carries the same way. The commits after it are this PR's own.What players get
Where it helps (AYN Thor, Pokémon Legends: Z-A)
On a copy of a save, each start the same: load the save, then 60 s standing in Lumiose.
The first start with the switch on plays as before and learns; from the second start on, what it used is there before the game shows its first frame. Of the 226, 2 are Z-A's capture pipelines, and the second start drew with the ones made ahead.
On Turnip T30 nothing gets worse: 642 or 643 pipelines made ahead in 0.1 to 0.2 s and no draw skipped, with the switch on or off. The one pipeline still made on the frame path without the switch, Z-A's capture pipeline, is made ahead from the second start on.
Earlier logs without the switch, on the Thor's own driver: Z-A skipped 11,253 draws in 70 s of one start's play; Tomodachi Life 2,300 to 2,700 at each of 8 starts, with a warm pipeline cache.
How it is built
dm/gfx/vk_android/vka_pso.c: onePEANUTS begin/endblock (sw_*) and marked one-line hooks. A run with learning on (PN_SHADERWATCH=1) notes the list record of every pipeline it makes while the game plays (pw_note) and the first use of every pipeline the prewarm made for it (gfx_obtain,cs_obtain: one field test, no hashing on the frame path). The saver writes them beside the list; the next start orders those records first in the prewarm and waits for them alone.dm/peanuts/peanuts_swhot.h: the file (record hashes and runs since used), its check, the merge with aging and the cap, the order. Free of Vulkan:dm/host/tests/t_peanuts_swhot.c.pw_notehands a capture variant's pipeline tosw_tf_note(record, key bytes and the capture layout,<list>.<driver>.tf,dm/peanuts/peanuts_swtf.h: at most 64, each with an entry in the.hotfile so it ages out with it;dm/host/tests/t_peanuts_swtf.c). The next start's prewarm takes those first (sw_tf_make):vka_tf.cvka_tf_learnedmakes the variant with the stored layout and the draw's own checks, and a draw's first use checks this run's layout (learned_holds); a mismatch makes it again as before.dev.peanuts.shaders.HostWatch: the backend of the tab'sShaderWatchcontract, registered in the game's process (GameActivity.settingsEnv, one line), its numbers from the list (Bridge.shaderWatch), the switch applied live (Bridge.shaderWatchLearn).docs/reference/rendering.md"Pipelines made again while playing at every start (Android)",PEANUTS.md,peanuts/UPSTREAM-EDITS.md.Tested
peanuts/tests/test_shader_watch.py(withHostCountsJvmTest,t_peanuts_swhot.candt_peanuts_swtf.cunder ASan and UBSan), the prewarm and docs tests,upstream-update.sh --check,check-publish.sh,check-min-api.pyon the APK (nothing newer than API 33)..hotor.tffile is read or written; with it on both are written while the game plays and read by the next start.