Repository navigation
Conversation
A read error deleted the whole vulkan.bin, while the hashes already read stayed in disk_pipelines, so those pipelines were never written again. LoadPipelines now cuts the file after the last complete record, and a failed append is cut back to the size before it instead of deleting the file. The append also flushes inside the try so a write error is seen.
SaveUsedPipelines truncated vulkan_used in place, so a crash while writing it left a short list and the next boot built few cached pipelines.
…ver cache On drivers that can't read the Vulkan pipeline cache during a build (Intel on Windows), a shader cache reload serialized it while translations, disk replays, background prebuilds and the precache could still build. They now end first, the same as at exit, which also waits for disk replays now. The background and precache stop flags are cleared when those builds start again.
… is gone The precache marker only covered the warm file, driver, device and cache version, so after the driver pipeline cache was removed or dropped the precache stayed skipped. Removing the Vulkan shader cache from the game list now deletes the marker, and where our own Vulkan pipeline cache holds the builds (Mesa, Intel) a boot that didn't find that file runs it again.
…e draws TickFrame changes graphics_cache, the deferred build candidates and frame_count without a lock, and a composite run by a syncpoint action may call it off the GPU thread. Log it once to find out before changing it.
…changes vulkan_pipelines.bin carried CACHE_VERSION, so every translation change deleted it and the next boot rebuilt every pipeline in the driver, even those whose SPIR-V didn't change. The driver checks its own header and finds pipelines by their SPIR-V, so the file gets its own version, DRIVER_CACHE_VERSION, starting at 35 so existing files are kept. Only matters where Eden saves this file (Mesa, Intel, others; not the NVIDIA and AMD proprietary drivers).
…r version ran A build that finds a vulkan.bin of another version renames it to vulkan.bin.v<version>, but nothing ever read those files back: switching between two builds (branches, an older release) re-translated the whole cache each way, and the backups piled up. LoadPipelines now restores <file>.v<expected version> when the file is missing or of another version, before upgrading the other build's cache in place, and keeps the two most recently written backups. Removing a title's Vulkan shader cache in the game list deletes the backups too, so they don't come back. Duplicate records, the other half of this plan item, were not worth a compaction pass: 8 compute duplicates in four titles' caches.
RADV stores compiled shaders in Mesa's on-disk shader cache, like the NVIDIA and AMD proprietary drivers do, so treat it the same way: Eden no longer saves vulkan_pipelines.bin on RADV unless Mesa's cache is turned off with MESA_SHADER_CACHE_DISABLE (or the older MESA_GLSL_CACHE_DISABLE). A log line says when the driver's cache is used instead. Tested on an RX 9070 XT (Mesa 26.2.6) with Ocarina of Time: a 50 minute session left vulkan_pipelines.bin untouched while Mesa's cache grew; with MESA_SHADER_CACHE_DISABLE=1 Eden writes it as before. Assisted-by: Claude Opus 5.5 (implementation, testing, commit message draft) Signed-off-by: Austin <16418832+ALHughes466@users.noreply.github.com> Signed-off-by: Austin <16418832+auz466@users.noreply.github.com> (cherry picked from commit dab0332)
A damaged pipeline cache, or one written by a build whose record layout has since moved without a CACHE_VERSION bump, dictates its own allocation size: FileEnvironment::Deserialize reads code_size and five map counts straight out of the file and calls code.resize() on them. A garbage length throws std::bad_alloc, which LoadPipelines does not catch, so it reaches OnTerminate and aborts the process on every boot until the user deletes the cache by hand. Walk the bytes still left in the file against the size each field will cost and refuse the record with the std::ios_base::failure the truncation path already handles (delete the cache, rebuild). Likewise refuse a record whose environment count cannot fit, which also covers the empty vector that envs.front() reads from. Valid caches are unaffected: every length they declare is present in the file, so no guard can trip on one.
StartShaderPrecache read each compute environment with the unbounded default, so a damaged warm-compute.bin could declare a large code_size past the magic and version checks, get it accepted by the new budget, and have code.resize allocate and zero-fill it before the short read failed. Its reader is separate from the disk cache on purpose — it deletes nothing — so the guard, not the file handling, has to reject the record. Pass the bytes left after num_envs, as LoadPipelines already does. Reported by CodeRabbit on #906.
…isk cache RADV doesn't use Mesa's disk cache for pipeline caches with RADV_DEBUG=nocache or ACO_DEBUG flags that change code generation (radv_device.c, disable_internal_cache). Relying on it then left no cache at all, and every boot built every pipeline again.
Mesa (RADV, ANV, its OpenGL drivers) keeps one shader cache for every application, 1 GiB by default, so other applications' entries evict ours; with RADV now relying on that cache instead of vulkan_pipelines.bin, an evicted pipeline means a rebuild. The private driver shader cache setting now also points MESA_SHADER_CACHE_DIR at <shader dir>/mesa with its size limit (MESA_SHADER_CACHE_MAX_SIZE), as it already did for NVIDIA. A cache path or a disabled cache in the user's environment is left alone.
The per-draw warning is capped per (vs, ps, reason), so it can't tell how many draws a change skips. The counter can.
…efers A deferred draw queued nothing, so its pipeline started only when a later frame drew it again, often deferred again. It is still skipped, but a worker translates it meanwhile. MKW cold to the cup load: 3.1-3.5k skipped draws without this, 1.2-1.9k with it; budget deferrals 696-996 -> 94-189. EDEN_NX2_PERF_OFF=queue_deferred_translation turns it off.
Pipelines of a burst that share a stage each translated it: the stage cache only knows a translation once its pipeline inserts it. Stages are now looked up first; a stage another thread is translating is waited for (threads that claim none themselves, never the GPU thread) and looked up again, the rest are claimed until inserted. MKW cold: ~70-80 waits reused, 806 stages translated against 880 without it. EDEN_NX2_PERF_OFF=stage_in_flight turns it off. The stage cache also merges a translation another thread inserted first and drops its least recently used entries past 256 MiB instead of everything.
… order With replay_disk_recordings on (the default) the pipelines boot skipped were only built at their first draw, and the prebuild threads sat idle. They now build those too, newest records first, taking the environments from the replay table so a pipeline is never built twice; a skippable draw whose pipeline is building skips (miss=background-build). Background builds now take turns: prebuild waits for run-time translations, driver builds and disk replays; the precache also waits for the prebuild. RuntimeBuildsBusy ignored replays before.
Every stage of a pipeline reads the same texture pool, so its range and dirty checks run once per pipeline instead of once per stage. The texture read recheck at adoption is a diagnostic: it now needs EDEN_NX2_CHECK_TEXTURE_READS=1.
Fixed MKW (boot to the cup load, ~85 s) and OoT (boot to the save and a short walk, ~180 s) routes with launch-time key scripts. Backs up and restores the title's shader cache and eden_log.txt, and waits on the emulator by pid.
Native instructions using R216 and up (the lowering's uniform mirrors and scratch) had each register quartet copied into a free low quartet and back: 16 to 32 MOVs per instruction, each decoded and turned into IR before SSA removed it. The lowering now records the renaming as a remap table appended to the code (before the native address map), and TranslatorVisitor::X reads and writes the high registers directly for those instructions. OoT shader dump: identical SPIR-V for all 1,952 programs, fragment translation 1.78 s -> 1.43 s, emission 248 -> 190 ms. Lowered code and so the native program hashes change for programs using high registers: their pipelines are translated once more (driver caches still hit, the SPIR-V is the same). The copy form stays readable for old caches and behind LoweringOptions::register_copies; precache files are rebuilt (builder 4).
Verbatim from 432bce0 (merge/nvn-renderer), so the merge meets the same files. Not used yet.
Opt-in with EDEN_NX2_GPL=1 (needs fast linking, independent interpolation and maintenance4). Pipelines whose stages are the same SPIR-V share one module set (keyed by per-stage hash and size), which GraphicsPipeline- LibraryCache keys its shader parts by; pipelines with a set link from parts, the rest (mesh emulation, warp-size stages, statistics) compile whole as before. The device hunks follow #913's so the merge only differs in the enabling condition. OoT cold load burst with NVIDIA's disk cache off: 664 of 854 pipelines linked, 366 of them from parts already compiled (under 5 ms), but new parts compile one after another, so driver time only drops ~9% and skipped draws don't change (translation decides most of them). Off by default until parts compile in parallel and GPU time is checked.
graphics_pipeline_library (off, per game too) turns on the library path in place of EDEN_NX2_GPL=1, which still overrides it (0 or 1). The tooltip says what the OoT measurement found: 43% of new pipelines linked from cached parts, but driver time only -9% and skipped draws unchanged.
The parts a link still misses go to a pool of their own (VkPipelineLibraryPart), never the builder pool whose threads wait for them. The linking thread compiles the first part, then helps with the ones no worker has started yet (from the back), so a busy pool costs no more than the serial compile. The helping loop is the one change to #913's vk_pipeline_library.cpp. OoT cold load burst, NVIDIA disk cache off: 664 linked (412 from cached parts, was 366), but new-part links still ~110 ms and driver time is the same ~38 s: the CPU is the limit during a load, not the order of the parts. The option's tooltip no longer blames the serial compile.
Creating a pipeline layout and update template waits on a driver lock while other pipelines compile: in OoT's cold load burst, 2.4 s of the 6.7 s spent translating on the workers (174 ms of it CPU). Graphics pipelines with the same descriptor layout now share one set layout, pipeline layout and update template (PipelineLayoutCache, keyed by the bindings and the push descriptor / descriptor buffer choice); each pipeline holds them by shared pointer. Mesh emulation keeps its own. Same burst (NVIDIA disk cache off, pipeline library on): 175 layouts for 1,028 pipelines; pipeline object phase 2.49 -> 1.43 s, translation on workers 5.7 -> 4.3 s, latency 16 -> 12.5 ms. Shared layouts also give library parts the identical layouts they need. Off with EDEN_NX2_PERF_OFF=shared_pipeline_layouts.
Translation and compile workers both ran at low priority, so in a load burst the translators waited for a CPU behind the driver's compiles (38% of their time in OoT, from schedstat), though every skipped draw waits for its translation first. A translation thread now raises itself to normal priority on its first task, still below the emulation's threads. OoT cold burst, two runs each: translation on workers 3.0-3.3 s against 3.9-4.1 s, mean latency 5.1-8.7 ms against 8.4-11.3 ms; skipped draws are within run-to-run noise. Off with EDEN_NX2_PERF_OFF=translation_priority.
The layouts a load burst still creates (161 in OoT) each wait 2.8 ms or more on the driver lock the compiles hold. Their keys are now saved per title (<title>/layouts.mythos.bin, at shutdown) and the layouts created at boot before the disk replay: 161 in 88.5 ms. Keys this device can't create (push descriptors, descriptor buffers, mesh) are skipped. OoT cold load burst, layouts known from an earlier session: pipeline object phase 591 -> 18 ms, translation latency 4.4 -> 3.5 ms. Off with EDEN_NX2_PERF_OFF=saved_pipeline_layouts.
A translation thread whose stage another thread is translating (M4.1) idled for up to 500 ms: 0.93 s in OoT's cold load burst. It now runs other queued translations meanwhile (ThreadWorker::TryRunOne), one level deep, and sleeps as before when the queue is empty. Queue order is kept, so a draw that can't be skipped never waits behind a requeued pipeline. OoT cold burst: 72-75 translations run while waiting; 1,424 skipped draws on a first play and 1,399 with saved layouts, against 1,800-2,900 in earlier runs; latency 3.5-4.4 ms against 7.4 ms with this off. Off with EDEN_NX2_PERF_OFF=help_while_in_flight.
…ackground With the pipeline library option on, every pipeline sharing shaders compiled its parts first, which the driver's cache doesn't hold: boot went from 0.2 to 34.7 ms per pipeline on a warm OoT cache, and in play unskippable 2560x1440 depth passes waited up to 1 s (user session). A pipeline now links only when every part is compiled already (Link with cached parts only); otherwise it compiles whole, as with the option off, and when it is new this session (run-time builds, not boot) its parts compile afterwards on the part workers: two threads, after the build queue is empty, cancelled if the pipeline goes first. Linking itself never compiles parts any more. Warm OoT cache: boot 3,890 pipelines at 0.2 ms mean with the option on as off; background part sets 0.2-1.2 ms each. The one wait over 100 ms left was a first whole compile of a pipeline earlier runs had only linked.
…y fills A pointer-table entry that was not mapped when a compute program was translated is classified as no pointer, and the translation leaves out every access through it. The stale-slot rebuild only checked direct constant buffer slots, so such a program never got rebuilt. A disk cache record of Ocarina of Time's spin-attack foliage list build was translated with c4[0xc0]'s table empty: the far forest behind Hyrule Castle vanished during every spin. Unmapped table entries are now kept with the entry and re-read like null slots. Assisted-by: Claude Opus 5.5
Task and mesh programs inlined the helpers since the NVIDIA tree-wall bug. Measured on Ocarina of Time (1,068 task/mesh pipelines, NVIDIA disk cache off): the bug is in the task stage only, and the mesh stages carry the compile time. Calls in mesh programs: 102 s -> 42 s in total, the pipelines that took 1-2.5 s now take 0.3-0.7 s, and the far forest still draws right. Those pipelines stalled draws that cannot be skipped for up to 1.2 s. Assisted-by: Claude Opus 5.5
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Parts are keyed by the shader set, so a set only one pipeline uses got four part compiles nothing linked from, beside its whole pipeline. Tester logs showed 0-24 links per 10 s against 100-337 whole compiles, roughly double the driver work, and both GPL-on deadlocks (#926, #927) came on that load. The shader set now counts its pipelines; parts are queued from the second. The 10 s library report counts the whole compiles that got no parts.
A method whose data continued across GP entries took the next entry's words as its data wherever that entry was. NVN also calls another command buffer mid-method and continues the method right where the split entry ended; on OoT/Intel (#926) a 6-word call owed 4 words was consumed as data, a header was read from the real rest, and a channel waited on a semaphore made of pushbuffer data. Park the method when the entry cannot be its rest (its size differs from the words left, unlike title 4's subroutine entry) and a later entry of the submission starts at the split point. EDEN_NX2_PARK_SPLIT_METHODS still parks every split. Refs #926
#927 left a channel waiting one value short with no way to tell whether the release was never issued, queued behind a host fence that never signaled, or dropped when its query was invalidated. Record release events (queued fence releases, written values, invalidated queries) in a 512-entry ring and print the latest ones on the waited 16 bytes with the stall warning. Refs #927
…-remap' of github.com:Djihads80/Eglantine into perf/shader-gpl-bank-remap
Collaborator
Author
|
Conflict resolution pulled the changes from
|
292bbb9 parked split methods whose next entry had another size than the words left. MKW streams macro 0xe59's 381 parameter words through 1-, 5- and 24-word entries elsewhere; parking them ran its data as commands, misread the stream (billion-index draws, MME instruction limits) and crashed minutes later. Macro parameters keep continuing across entries (as title 4's do); only register-write splits like #926's 0x4c7 park. Refs #926
capy-ai Bot
added a commit
to zortos293/Lichii
that referenced
this pull request
Nov 22, 2026
…ls (#2415) * dma_pusher: resume split register writes after interleaved GPFIFO calls Port kraibse's 292bbb9fd8 and 9cd4f3df21 together from Eglantine-Community/Eglantine#924. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * dma_pusher: prefer a known parked return over a word-count match Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * dma_pusher: keep macro continuation cleanup unchanged Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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.
Summary
This is a bundle around one wait: the time a draw loses when its pipeline isn't ready yet, plus
the ways the on-disk caches behind those pipelines go stale, get damaged or get thrown away and
rebuild everything.
Most measurements are Ocarina of Time (
0400486024DEC000) and Mario Kart World cold-cache runson NVIDIA with the driver disk cache off, unless a line says otherwise. New toggles are behind
EDEN_NX2_PERF_OFF=<name>; off-by-default settings are noted.Translation
first, waits for an in-flight translation instead of racing it, and the stage cache merges a
translation another thread inserted first and evicts least-recently-used entries past 256 MiB
instead of everything (
stage_in_flight). MKW cold: ~70–80 waits reused, 806 stagestranslated against 880.
(
queue_deferred_translation). MKW cold to the cup load: 3.1–3.5k skipped draws → 1.2–1.9k,budget deferrals 696–996 → 94–189.
meanwhile, one level deep, queue order kept (
help_while_in_flight). OoT cold burst: 72–75extra translations; 1,424 skipped draws on a first play and 1,399 with saved layouts, against
1,800–2,900; latency 3.5–4.4 ms against 7.4 ms.
emulation's threads (
translation_priority). OoT cold burst, two runs each: 3.0–3.3 s on theworkers against 3.9–4.1 s, mean latency 5.1–8.7 ms against 8.4–11.3 ms.
Layouts and pipelines
update template (
shared_pipeline_layouts). OoT cold burst (NVIDIA disk cache off, librarypath on): 175 layouts for 1,028 pipelines; pipeline object phase 2.49 → 1.43 s, translation on
workers 5.7 → 4.3 s, latency 16 → 12.5 ms.
<title>/layouts.mythos.bin) and created at bootbefore the disk replay: 161 in 88.5 ms; pipeline object phase 591 → 18 ms, latency
4.4 → 3.5 ms (
saved_pipeline_layouts).VK_EXT_graphics_pipeline_library: pipelines whose stages are the same SPIR-V link fromlibrary parts (
GraphicsPipelineLibraryCacheis taken verbatim from nvn: add VTX-HLE high-level NVN graphics path #913 so the merge meetsthe same files). A link uses only already-compiled parts and otherwise compiles whole; a new
pipeline's parts compile afterwards on their own two part workers, cancelled if the pipeline
goes first. Off by default,
Performance > Shadersoption (per game too,EDEN_NX2_GPL=0/1overrides it). Warm OoT cache: boot of 3,890 pipelines at 0.2 ms mean with the option on as
off. Without the "compiled parts only" link condition boot was 34.7 ms per pipeline instead of
0.2 ms, and unskippable 2560x1440 depth passes waited up to 1 s.
Shader translation
MOVs per instruction, each decoded and turned into IR before SSA removed it). OoT shader dump:
identical SPIR-V for all 1,952 programs; fragment translation 1.78 → 1.43 s, emission
248 → 190 ms. Native program hashes change for programs using high registers, so those
pipelines are translated once more; the copy form stays behind
LoweringOptions::register_copiesand precache files are rebuilt (builder 4).
bug is task-stage only, and the mesh stages carry the compile time). OoT, 1,068 task/mesh
pipelines, NVIDIA disk cache off: 102 s → 42 s total; the pipelines that took 1–2.5 s now take
0.3–0.7 s, and the far forest still draws right.
Correctness
fills in. Such a program kept a translation with every access through the table left out,
which is what made the far forest behind Hyrule Castle vanish during OoT's spin attack.
Pipeline caches
vulkan_pipelines.binis nolonger written there unless Mesa's cache is disabled. Tested on an RX 9070 XT (Mesa 26.2.6)
with OoT: a 50 minute session left
vulkan_pipelines.binuntouched while Mesa's cache grew,and Eden writes it as before with
MESA_SHADER_CACHE_DISABLE=1. (Cherry-pick of vk_pipeline_cache: let RADV keep its own pipeline cache #714, keepsthe original sign-off.)
DRIVER_CACHE_VERSION, starting at 35), so atranslation change no longer deletes it and rebuilds every pipeline in the driver, even those
whose SPIR-V didn't change.
<file>.v<version>instead ofre-translating each way, and keeps the two most recently written backups.
deletes the precache marker and the backups too.
disk cache and the warm-precache reader (video_core: bound pipeline cache records before allocating #906), instead of reaching
std::bad_allocandaborting the process on every boot until the user deletes the cache by hand.
append is cut back to the size before it, and the used-pipeline list is written through a
temporary file.
writing the driver cache, which matters on drivers that can't read the cache during a build
(Intel on Windows).
(
MESA_SHADER_CACHE_DIR/MESA_SHADER_CACHE_MAX_SIZE), so other applications' entries stopevicting ours now that RADV relies on that cache. A cache path or a disabled cache in the
user's environment is left alone.
Tools
tools/nx2/cold_cache_run.sh: fixed MKW (boot to the cup load, ~85 s) and OoT (boot to thesave and a short walk, ~180 s) A/B routes that back up and restore the title's shader cache
and
eden_log.txt, and wait on the emulator by pid.Type of change
Related issues
Possibly related, not claimed as fixed:
commits here are about the states that report describes (another build ran against the profile,
a kill during the cache write: versioned driver cache, per-build backups, bounded and cut-back
records, atomic used-list write), but the "spins a core and never presents" part is not
reproduced here, so no
Fixes.Two commit pairs are already proposed upstream and can be dropped from this PR if reviewers
prefer:
video_core: bound pipeline cache records before allocatingandvideo_core: bound the warm-precache record read tooare #906, andvk_pipeline_cache: let RADV keep its own pipeline cacheis the cherry-picked #714.Testing
Games tested:
0400486024DEC000, NVIDIA): cold load burst latency 16 → 12.5 ms, pipelineobject phase 2.49 → 1.43 s, skipped draws 1,800–2,900 → ~1,400; boot of 3,890 pipelines at
0.2 ms mean with and without the library path; fragment translation 1.78 → 1.43 s; task/mesh
compile 102 → 42 s.
vulkan_pipelines.binuntouched with Mesa's cache in use, and writes it again with
MESA_SHADER_CACHE_DISABLE=1.translated 880 → 806.
No visual regressions seen in the games above; the pointer-table fix changes behaviour, so the
OoT scenes it touches were re-checked.
Checklist
AI Disclosure
Assisted-by: Claude Opus 5.5on two commits —shader: keep the global memory helpers as calls in mesh programsandvk_pipeline_cache: rebuild compute programs when a pointer-table entry fills— used for the implementation, the measurements and the commit message drafts. Theremaining commits are my own work; the RADV pipeline cache commit is a cherry-pick of #714 and
carries that PR's own disclosure and sign-off. Every line here is reviewed by me and I can defend
it in review.
Screenshots / logs
Before/after numbers are per commit message, with the GPU, cache state and title they were taken
on. No screenshots: nothing here changes rendering, except the far-forest case above.
Overlaps with open PRs
Build state
build/bin/eglantinewas built at 22:56 on 2026-11-21, after the HEAD commit at 17:40, so thebranch has been built locally at HEAD — but the "compiles without new warnings" claim was not
re-verified by the agent, so that box stays yours.