Skip to content

perf(agc): reuse cached draw stages when only buffer base addresses moved - #5609

Open
TheAggie wants to merge 14 commits into
boykopovar:mainfrom
TheAggie:perf/agc-draw-stage-relocation
Open

TheAggie wants to merge 14 commits into
boykopovar:mainfrom
TheAggie:perf/agc-draw-stage-relocation

Conversation

@TheAggie

@TheAggie TheAggie commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Second step for #4054, stacked on #4943. That PR finds a cached draw when the user-data pointers moved and the data behind them is equal. A guest driver that keeps its buffer descriptors in a table reached through such a pointer (RADV's descriptor sets) still missed on every draw whose buffers moved, because the descriptor's base address is among the words a stage is validated against.

  • A stage whose captured words differ from the cached ones only in buffer base addresses is reused: the base words of the bound buffers are patched in the cached result, and the buffers themselves are read by the draw as usual, so their contents stay out of the match.
  • Cached stages are relocated one by one, keyed by their prepared shader, so a draw can take its vertex stage from one earlier draw and its pixel stage from another.
  • A patched stage replaces its donor, so the next draw with the same bases matches without another patch.
  • Reusing draw snapshots across draws that nothing wrote between was a commit of this PR; it landed on its own as perf(agc): reuse draw snapshots across draws that nothing wrote between #5906.
  • The second-sight admission (perf(agc): cache a draw key the second time it is seen #5216) counts a repeat of a stage's relocated contents as a second sighting, since a draw's stages are now matched one by one.
  • At their limit the stage donor and decode maps drop every other entry, not all of them.
  • The shader disk cache carries the new bufferBaseSlots field of a result, and its Linux-only size asserts expect the grown structs.
  • Two per-draw costs that showed up once the cache hit: the dynamic state of an open render pass is only set again when it changed, and AnyPendingOverlaps consults the pending image range index first. The state the filter compares against is kept per command buffer, in the recorder batch's open render pass: it is reset when a new pass starts and marked unknown after the back-face and second-channel splits and after stencil replay (which sets the stencil reference itself).
  • A stage that upstream's stage-data hits would verify (APS5_VERIFY_DRAW_DATA_HITS=1) is left to that verification instead of being reused.

APS5_NO_DRAW_RELOCATION=1 turns the relocation off, APS5_NO_DRAW_STATE_FILTER=1 the dynamic state filter.

Only the commits after #4943's head are this PR.

Tested

Windows 11, NVIDIA GeForce RTX 5070 Ti, MinGW-w64 GCC 15.2.0, rebased on main 940eba9a2.

  • ctest: 1270 of 1292 pass, 14 skipped. guest_call_trace_abort, windows_backtrace_report and agc_driver_store_over_untracked fail, and fail the same way on plain main here. agc_driver_prepared_shaders_debug failed once in a parallel run and passes alone. Three newer tests, agc_driver_prepared_graphics_prebuild_0/_1 and undeliverable_host_exception, fail under my test runner because it skips their environment changes and pass pattern; run with those, all three pass.
  • The size asserts in ShaderDiskCache.cpp only compile on Linux. I have no Linux build; I compiled the structs under MinGW libstdc++ on x86_64, where all asserted sizes match. agc_shader_disk_cache's result round trip now also sets and compares bufferBaseSlots.
  • New test agc_driver_draw_cache_moved_buffer: a pixel shader loads a buffer descriptor through a user-data pointer and reads its colour from that buffer. Once the draw has been seen twice, drawing it again with the descriptor's base changed, with the same or other contents, hits the cached draw. It fails with APS5_NO_DRAW_RELOCATION=1.
  • On main 940eba9a2, this PR and perf(agc): find cached draws across moved user-data pointers #4943 against the same build without them (both with the same local changes the frontend needs to boot, immediate present, audio muted, three alternating unprofiled runs): audio produced at 34.5%, 35.7% and 35.6% of real time without, against 45.7%, 44.1% and 42.8% with.
  • RetroArch (PPSA99169) with its Flycast core running Crazy Taxi's attract demo, measured before the rebase, on main 4430780bd (without perf(agc): cache a draw key the second time it is seen #5216) plus local changes outside this PR that the frontend needs to boot. perf(agc): find cached draws across moved user-data pointers #4943 alone against perf(agc): find cached draws across moved user-data pointers #4943 plus this PR, same local base, one thread, ANYPS5_PRESENT_MODE=immediate, two unprofiled runs each: audio produced at 43.6% and 43.4% of real time against 57.6% and 57.9%. One profiled run each: queue worker 41.5 µs against 30.7 µs per draw packet; stage captures per 10 s 92,728 in 185,141 draws against 14,859 in 238,439; draws with every stage reused 75% against 96.8%.
  • Same demo and base with perf(agc): cache a draw key the second time it is seen #5216 cherry-picked, two unprofiled runs each: the chain without the admission 59.1% and 58.8%; with perf(agc): cache a draw key the second time it is seen #5216 as merged 51.0% and 50.7%; with the admission change of these two PRs 58.8% and 58.5%.
  • Same demo with APS5_VERIFY_DRAW_ENTRIES=1, which captures every hit again and compares: 0 stages differed in every report (118,722 hits in the largest).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: perf(agc): find cached draws across moved user-data pointers #4943
  • AI-assisted: yes. Written with Claude Code under my direction.

🤖 Generated with Claude Code

@CnRJay CnRJay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per-stage relocation is a sensible next step after #4943. The verify mode (APS5_VERIFY_DRAW_ENTRIES=1, 0 differing stages) is good evidence for the demo. I found two correctness gaps that the demo probably doesn't reach, and one gap in the evidence.

1. The content hash stops at 64 words of each read. In relocatedContentKey, each (offset, words) read is hashed as count = std::min<std::size_t>(words, MaxContentWords). words is the length of a run that learnPendingRelocation derives from variant.runs, which follow the captured regions. A descriptor table reached through a relocatable base can easily be longer than 64 dwords; eight 8-dword T#s are already 64. Words past the first 64 are then never compared. A table that moved, with the same first 64 words and different descriptors after them, produces the same alias key and reuses the donor stage with stale descriptors. Either hash the whole run (in chunks of MaxContentWords), or ban the register in learnPendingRelocation when a run is longer than the limit, so such a stage stays on the capture path.

2. RecordedDrawState is one process-wide object with no lock. recordedDrawState() returns a function-local static that apply and setLibraryState read and write without synchronization. The recorded.commands == commands check only protects against a different command buffer when two command buffers are recorded one after the other. Suppose two queue workers record concurrently (the measurements say "one thread", so I assume multi-threaded recording is a supported mode). Thread A checks that recorded.commands is its own buffer, thread B then stores its own viewport and stencil values, and A compares its new values against B's. A then skips a vkCmdSet* whose value differs from what A's command buffer actually holds, so state set for one queue's draws leaks into another's. Keeping this state per command buffer (in the recorder's batch, next to commands) avoids both the race and the handle comparison. thread_local would also work if a command buffer is only ever recorded on one thread. Besides that, the filter looks right: Begin re-applies everything with known = false, and the two other graphics binds reset recorded.commands.

3. The MaxAliases limit clears both maps outright. drawStageDonors.clear() / drawDecodes.clear() at 16384 entries means a title that crosses the limit loses every donor at once. For several frames, every moved draw then goes back to full capture. That is exactly the stall pattern this PR is trying to remove, and it would show up as a periodic hitch rather than a lower average. An LRU, or evicting the oldest half, keeps the steady state. At least a counter in the profile output would make the cliff visible.

Evidence:

  • The per-packet times (41.5 → 30.7 µs) and capture counts come from profiled runs.
  • The unprofiled metric, audio produced as a share of real time, is a reasonable proxy for this demo. It is still not the aps5-summary.jsonl lines plus traces captured with no APS5_PROFILE_* switch that the Performance report form asks for.
  • The base also includes local changes outside the PR.

The summary lines of #4943 alone and of #4943 + this PR, on the same machine, would make the claim checkable. So would a run on a second title that doesn't use a RADV-style descriptor-set layout, which would show that the extra per-draw content hashing (CopyMapped plus the hash of every relocatable read) costs nothing where relocation never hits.

Also, since only the commits after #4943's head belong to this PR, Depends on: #4943 should be filled in the checklist, if it isn't already.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
0xcrstn added a commit to 0xcrstn/AnyPS5 that referenced this pull request Oct 14, 2026
…eir read ranges

Two kinds of draw snapshot were always copied whole.

A moved buffer is a read-only guest buffer of a draw that reuses a cached
resource build whose V# pointed elsewhere (MovedReadOnlyBuffers, the draw
relocation of boykopovar#5609): the snapshot copies the buffer at the draw's own
address and size instead of the build's. Its read ranges are relative to
the V# base, so they hold at the new address; they are now placed from
the draw's own binding and V# when the move is found and used like an
unmoved buffer's.

A formatted load (buffer_load_format_*, tbuffer_load_*) addresses its
element like any MUBUF/MTBUF load, index * stride + offset + instruction
offset + soffset (RDNA 2 ISA, buffer addressing), and reads its components
at byte offsets within one element of its data format, whose largest is
32_32_32_32 (16 bytes); SpirvRuntimeBuffer's formatted() reads each
component through the same address(). Such a load now reads up to 16
bytes from its offset instead of the whole buffer.

The "moved" and "formatted load" reasons are gone from the whole-copy
counts; the shader disk cache format goes to 32.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10 adriadam10 self-assigned this Oct 14, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the diff; two correctness problems, and the PR still needs a rebase once #4943 lands.

  • DrawRelocate.cpp relocatedContentKey: each read is hashed as min(words, MaxContentWords) (64). A descriptor table longer than 64 dwords that moved, with the same first 64 words and different descriptors after them, gets the same alias key and reuses the donor stage with stale descriptors. Hash the whole run in chunks, or stop treating the register as relocatable in learnPendingRelocation when a run is longer than the limit.
  • Pipeline.cpp recordedDrawState(): a function-local static with no lock, read and written by apply/setLibraryState. With two queue workers recording, the recorded.commands == commands check does not stop one worker comparing against the other's viewport/stencil values and skipping a vkCmdSet* its command buffer needs. Keep this state per command buffer (next to commands in the recorder's batch) or make it thread_local if recording is single-threaded; please say which holds.
  • MaxAliases: drawStageDonors.clear() / drawDecodes.clear() at 16384 drops every donor at once, so every moved draw goes back to full capture for a while. Evict the oldest part instead, or at least count it in the profile output.
  • Evidence: the 41.5 → 30.7 µs numbers come from profiled runs and the base has local changes outside the PR. The unprofiled aps5-summary.jsonl lines of #4943 alone vs #4943 + this PR, plus one title without a RADV-style descriptor layout showing the extra hashing costs nothing, would make it checkable.
  • The branch conflicts with main and is stacked on #4943, which is open and conflicting too; rebase after it merges.

Welcome back once these are addressed.

@TheAggie
TheAggie force-pushed the perf/agc-draw-stage-relocation branch from 8417747 to 00816c0 Compare October 14, 2026 12:55

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. The 64-word hash and the all-at-once eviction are fixed (chunked hashing, dropEveryOther with the evicted counter). One point from the last review is still open:

  • Pipeline.cpp:690 recordedDrawState() is still a function-local static with no lock. With two queue workers recording, the recorded.commands == commands check does not stop one worker comparing against the other's viewport/stencil values and skipping a vkCmdSet* its own command buffer needs. Keep the state per command buffer (next to commands in the recorder's batch), or make it thread_local if recording is single-threaded; please say which one holds.
  • The branch still conflicts with main and is stacked on #4943, which is open and conflicting. Please rebase once #4943 lands.

@TheAggie
TheAggie force-pushed the perf/agc-draw-stage-relocation branch from 00816c0 to d6abd55 Compare October 14, 2026 13:15
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rebase. The 64-word hash and eviction fixes are in; one point from the last review is still open:

  • Pipeline.cpp:690 recordedDrawState() is still a function-local static with no lock. With two queue workers recording, recorded.commands == commands does not stop one worker comparing against the other's viewport/stencil values and skipping a vkCmdSet* its own command buffer needs (and the writes race). Keep the state per command buffer (next to commands in the recorder's batch), or make it thread_local if recording is single-threaded; please say which one holds.
  • Still stacked on #4943, which is open; please rebase once it lands.

@TheAggie

Copy link
Copy Markdown
Contributor Author

@CnRJay thanks for the review. Rebased onto main 7181fe94d (on top of #4943's new head) and force-pushed.

  1. Content key cut off at 64 words. Fixed: a read is now hashed whole, 64 words at a time, with its offset and length mixed in. For the record, a cut-off key could not make a stale stage be reused, because a candidate is still compared word by word before it is taken; what it cost was two different buffers sharing a key and pushing each other out.

  2. RecordedDrawState is process-wide and unlocked. Not changed in this push. Recording into a command buffer already happens under the GPU mutex, so the state is not touched by two threads at once. thread_local would be wrong here: the queue worker and the committer record into the same command buffer in turn, and the filter has to see what the other one set. If you would rather not rely on that, I can move the state into the recorder object so its lifetime and its lock are the recorder's.

  3. Clearing a whole map at the limit. Fixed: at the limit every other entry is dropped instead of all of them, for the stage donors and the decodes here and the aliases in perf(agc): find cached draws across moved user-data pointers #4943, and the [draw-relocate] line reports how many were dropped.

  4. Evidence. Unprofiled captures with APS5_TRACE_SECONDS=60:30, Crazy Taxi attract demo in RetroArch/Flycast, ANYPS5_PRESENT_MODE=immediate, same machine, runs alternated. Base is main a14ae8e23 plus the local changes the frontend needs to boot (not in either PR). From aps5-summary.jsonl:

    build presents in 30 s GPU busy ms per present audio produced (of real time)
    base, neither PR 202 2.13 5.8%
    perf(agc): find cached draws across moved user-data pointers #4943 188, 194 1.29, 1.29 5.4%, 5.5%
    perf(agc): find cached draws across moved user-data pointers #4943 + this PR 1261, 1191 0.89, 0.92 36.6%, 36.0%

    I will be plain about the middle row: on current main perf(agc): find cached draws across moved user-data pointers #4943 alone does not move this workload. A profiled run shows it hits about 40% of draws, but on this base almost every draw copies a whole 2 MiB guest buffer into a snapshot (about 12,500 copies and 16 GB a second), and a cache hit still makes that copy. This PR reuses the snapshot when nothing wrote between draws (e92089d9f) and turns most draws into hits that skip the stage captures. I have not measured those two apart, so I can't say how the gain splits between them. The 27% to 38% in perf(agc): find cached draws across moved user-data pointers #4943's description is from the older base and says so; I will add this result there too.

    I have not yet run a title that does not go through RADV; none of my test titles uses Sony's own graphics driver, so that part is still owed.

The dependency is unchanged: this PR depends on #4943, and only the commits after that PR's head belong to it.

This push also fixes the Linux build that @Raghav314 reported on #4943: the size asserts in ShaderDiskCache.cpp and the result encoder now cover bufferBaseSlots.

AI-assisted (Claude Code).

@TheAggie

Copy link
Copy Markdown
Contributor Author

Restructured, no change in behaviour: the commit that reuses draw snapshots across draws nothing wrote between is now its own PR, #5906. It helps every Windows title, not only the relocation path here. On main alone it takes the Crazy Taxi demo from 5.8% to about 26.5% of real time, since on Windows each draw otherwise copies a 2 MiB buffer that is almost always unchanged.

This branch now carries #5906's two commits under its own, so it depends on #4943 and #5906. Since #5906 went up separately it has a gentler eviction (every other entry at the limit), a recorder-level test, and the debt line for #1441 updated. All three are in this branch too. Both branches are rebased onto main 84b01f9cd.

AI-assisted (Claude Code).

@Amoenus

Amoenus commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

@TheAggie I’m preparing a diagnostic-only change that shares materializeCapture with this PR: fork commit 1f5e95683bd3. It logs the last already-recorded read address/user-data origin when ResourceMaterializer::Materialize throws, then rethrows the original exception. It adds no guest reads, recovery path or success logging. This helped classify Sonic’s current capture stop; it does not fix that stop or implement buffer relocation.

Your head 09238da8206e adds noteBufferBaseWords after the same two materialization calls. I propose keeping that work intact and submitting this diagnostic separately, refreshing whichever branch lands second. The logger would wrap only materialization; your post-success bookkeeping would remain outside it.

Exact-head qualification and limits: 17 positive processes across main/change (including both physical GPU vendors), plus a test-only control failing specifically on missing context. The official overlap audit remains unresolved, and I have not opened a new upstream PR. Would that separate scope/order work for you?

AI-assisted: yes (Codex); author responsible.

@santhoshkumar-dev

Copy link
Copy Markdown
Contributor

Windows/SRT tape integration feedback from Another Crab's Treasure (PPSA20423, 02.000.000), on a local rebase/extension of this work onto pinned main 5fb1747fa7a4. This is not a qualification of the unmodified PR against current main.

Windows 11 10.0.26200, Ryzen 5 5600X, RX 6700 XT, AMD Vulkan 26.8.1, WinLibs GCC 15.2.0 r7, Release.

The tape needs to preserve readInstructions, sourceLeads and operandReads for buffer-base tagging. The local origin port now handles cached reads consumed later as operands and operations lowered away at tape roots; direct-read leads follow the interpreter's selection rules. Refused walks restore the metadata vectors. The moved-buffer canary passes with the tape enabled. CPU regressions distinguish forwarding, arithmetic use and first-lane use, and fail before the corresponding repairs.

Additional integration findings:

  • relocation_evicted passed on baseline and failed on the initial local perf(agc): reuse cached draw stages when only buffer base addresses moved #5609 stack: a donor could outlive its cache entry. Weak donor variants tied to a live owner key, with owner retention on validated hits, restored both the evicted and retained-donor cases.
  • I included the captured-buffer exclusion reported by ntamas94. A CPU contract regression fails without the range check and passes with it, including byte and strided descriptors above 4 GiB.
  • Composing descriptor patches with a previously pushed value needs to preserve the earlier effective push data. A staged-patch regression exposed and checks this transition for push and stored shader data.
  • Full-build verification needs to pair captured words with guest addresses across equivalent split/reordered capture ranges. Word values, bindings and effective push constants remain checked.

The current local extension also applies eligible reuse through the shape-matched/data-only path, including runtime-only pushed user words and the existing pure scalar-data refresh mechanism. The final mixed-input regression changes a memory value and a shader input together, checks the rendered color, and requires reuse in normal mode.

Twelve distinct GPU cases plus three CPU contracts pass on this GPU. Vulkan is required, the shader cache disabled, Khronos validation confirmed loaded, and the compared logs have no new VUID IDs. The shader-memory capture/validation/replay suite also passes. A visually confirmed beach run with both APS5_VERIFY_DRAW_ENTRIES=1 and APS5_VERIFY_DRAW_DATA_HITS=1 completed without a reported mismatch. Only this AMD GPU was tested locally.

Normal warm-scene screening of the final local composition was 11.21 FPS on baseline versus 10.73 FPS on the candidate (one run per arm; last five eligible 10-second intervals, individual frame durations, identical visually confirmed view and settings, hashes matched). This establishes no FPS benefit; the earlier buffer/table-only screen was 10.56 versus 10.57 FPS. I am sharing functional/integration evidence, not claiming that this PR or the local extension fixes this title's performance. The original runtime is restored. Game bring-up #8239.

Local SRT tape origin-port diff against pinned main 5fb1747
diff --git a/core/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cpp b/core/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cpp
index ddda8b1fc3..916f96519e 100644
--- a/core/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cpp
+++ b/core/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cpp
@@ -325,10 +325,13 @@ struct SrtTape::Frame {
     std::uint8_t* states;
     bool nullRoot = false;
     std::uint32_t addressDepth = 0;
+    std::uint32_t operandDepth = 0;
     std::size_t descriptorBytes = 0;
 };
 
 bool SrtTape::evaluate(Frame& frame, std::uint32_t index, std::uint64_t& result) const {
+    const auto& node = nodes[index];
+    if (frame.operandDepth > 0 && frame.runtime.userDataUse != nullptr && (node.op == Op::Read || node.op == Op::ReadConstBuffer)) frame.runtime.userDataUse->operandReads.push_back(node.source);
     const auto state = frame.states[index];
     if (state == 1) {
         result = frame.values[index];
@@ -336,7 +339,10 @@ bool SrtTape::evaluate(Frame& frame, std::uint32_t index, std::uint64_t& result)
     }
     if (state == 2) return false;
     std::uint64_t value = 0;
-    if (!compute(frame, nodes[index], value)) {
+    ++frame.operandDepth;
+    const bool computed = compute(frame, node, value);
+    --frame.operandDepth;
+    if (!computed) {
         frame.states[index] = 2;
         return false;
     }
@@ -438,7 +444,10 @@ bool SrtTape::compute(Frame& frame, const Node& node, std::uint64_t& result) con
                 frame.nullRoot = true;
                 return false;
             }
-            if (frame.runtime.userDataUse != nullptr) frame.runtime.userDataUse->reads.emplace_back(address, origin);
+            if (frame.runtime.userDataUse != nullptr) {
+                frame.runtime.userDataUse->reads.emplace_back(address, origin);
+                frame.runtime.userDataUse->readInstructions.push_back(node.source);
+            }
             if (node.loaded && frame.runtime.accessible != nullptr && !frame.runtime.accessible(frame.runtime.userContext, address, sizeof(std::uint32_t))) return false;
             if (auto* trace = frame.runtime.readTrace; trace != nullptr) {
                 if (node.source == trace->leaf) trace->leaves.emplace_back(trace->leafSlot, address);
@@ -556,6 +565,9 @@ bool SrtTape::Run(const IrResourcePlan& plan, const SrtRuntime& runtime, std::ve
     const auto baseBefore = use != nullptr ? use->asBase : 0;
     const auto valueBefore = use != nullptr ? use->asValue : 0;
     const auto useReadsBefore = use != nullptr ? use->reads.size() : 0;
+    const auto useReadInstructionsBefore = use != nullptr ? use->readInstructions.size() : 0;
+    const auto useOperandReadsBefore = use != nullptr ? use->operandReads.size() : 0;
+    const auto useSourceLeadsBefore = use != nullptr ? use->sourceLeads.size() : 0;
     const auto refuse = [&] {
         if (trace != nullptr) {
             trace->leaves.resize(leavesBefore);
@@ -566,6 +578,9 @@ bool SrtTape::Run(const IrResourcePlan& plan, const SrtRuntime& runtime, std::ve
             use->asBase = baseBefore;
             use->asValue = valueBefore;
             use->reads.resize(useReadsBefore);
+            use->readInstructions.resize(useReadInstructionsBefore);
+            use->operandReads.resize(useOperandReadsBefore);
+            use->sourceLeads.resize(useSourceLeadsBefore);
         }
         return false;
     };
@@ -585,6 +600,19 @@ bool SrtTape::Run(const IrResourcePlan& plan, const SrtRuntime& runtime, std::ve
         std::fill_n(states, nodes.size(), std::uint8_t {0});
     }
     Frame frame {runtime, values, states};
+    const auto noteErasedOperand = [&](IrValue* expression, std::uint32_t root) {
+        if (use == nullptr || root == NoNode || (nodes[root].op != Op::Read && nodes[root].op != Op::ReadConstBuffer) || nodes[root].source == nullptr || expression == nullptr) return;
+        auto* value = expression->Resolve();
+        for (;;) {
+            if ((value->Opcode() == IrOpcode::BitCastU32F32 || value->Opcode() == IrOpcode::BitCastF32U32) && value->ArgumentCount() == 1) value = value->Argument(0)->Resolve();
+            else if (value->Opcode() == IrOpcode::ReadConst && value->ArgumentCount() == 2) {
+                auto* slot = value->Argument(1)->Resolve();
+                if (!slot->HasImmediate() || slot->Type() != IrType::U32 || slot->ImmediateU32() >= plan.srtReads.size() || plan.srtReads[slot->ImmediateU32()].value == nullptr) break;
+                value = plan.srtReads[slot->ImmediateU32()].value->Resolve();
+            } else break;
+        }
+        if (value != nodes[root].source) use->operandReads.push_back(nodes[root].source);
+    };
 
     struct Scratch {
         std::uint32_t attempt = 0;
@@ -639,6 +667,7 @@ bool SrtTape::Run(const IrResourcePlan& plan, const SrtRuntime& runtime, std::ve
             for (const auto image : block.images) active[imageBase + image] = 1u;
             for (const auto slot : block.flatSlots) activeFlat[slot] = 1u;
             std::uint64_t condition = 0;
+            if (block.condition != nullptr && runtime.readSpecializationMemory != nullptr) noteErasedOperand(block.condition, conditionRoots[index]);
             const bool cleanEvaluable = block.condition != nullptr && runtime.readSpecializationMemory != nullptr && conditionRoots[index] != NoNode && evaluate(frame, conditionRoots[index], condition);
             if (frame.nullRoot) return refuse();
             if (cleanEvaluable) {
@@ -661,12 +690,21 @@ bool SrtTape::Run(const IrResourcePlan& plan, const SrtRuntime& runtime, std::ve
             for (std::uint32_t dword = 0; dword < source.dwordCount; ++dword) {
                 std::uint64_t word = 0;
                 frame.descriptorBytes = source.dwordCount > 1u ? static_cast<std::size_t>(source.dwordCount - dword) * sizeof(std::uint32_t) : 0u;
+                noteErasedOperand(source.dwords[dword], sourceDwords[sourceIndex][dword]);
                 const bool ok = evaluate(frame, sourceDwords[sourceIndex][dword], word);
                 frame.descriptorBytes = 0u;
                 if (!ok) return refuse();
                 value.dwords[dword] = static_cast<std::uint32_t>(word);
             }
         }
+        if (use != nullptr && source.dwordCount != 0 && source.dwords[0] != nullptr) {
+            auto* lead = source.dwords[0]->Resolve();
+            if (!lead->HasImmediate() && lead->Opcode() == IrOpcode::ReadConst && lead->ArgumentCount() == 2) {
+                auto* slot = lead->Argument(1)->Resolve();
+                if (slot->HasImmediate() && slot->Type() == IrType::U32 && slot->ImmediateU32() < plan.srtReads.size() && plan.srtReads[slot->ImmediateU32()].value != nullptr) lead = plan.srtReads[slot->ImmediateU32()].value->Resolve();
+            }
+            if (!lead->HasImmediate() && IsRawRead(plan, *lead)) use->sourceLeads.emplace_back(sourceIndex, lead);
+        }
         evaluated.push_back(value);
     }
     auto& flattened = scratch.flattened;
@@ -681,6 +719,7 @@ bool SrtTape::Run(const IrResourcePlan& plan, const SrtRuntime& runtime, std::ve
             trace->leafSlot = read.flatOffset;
         }
         std::uint64_t word = 0;
+        noteErasedOperand(read.value, flatRoots[slot]);
         const bool ok = read.flatOffset < flattened.size() && evaluate(frame, flatRoots[slot], word);
         if (pure) trace->leaf = nullptr;
         if (!ok) return refuse();

AI-assisted implementation and testing: yes, Codex, continuing the ZCode handover. No game files or assets attached.

@JJenkx

JJenkx commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

@TheAggie I have a current-main support port of the core buffer-base stage reuse path, preserving your original head/history and current main graphics-state handling:

Against main c4bff3e0c135, on Linux 7.2.14, AMD RX 6650 XT / RADV and Khronos validation 1.4.363:

Focused GPU gate Main Port
Six existing relocation cases: default, recipe verification, evicted, kept, pipelined and plan verification 6 pass 6 pass
Identical new moved-buffer fixture, built against each arm Expected cache miss Pass, including rendered pixels when the buffer value changes 1.0 → 0.5 → 1.0

Every case selected the physical GPU and inserted the validation layer; zero VUIDs and skips. Both frozen banks retained their hashes and the kernel setting was restored. GPU head a7ba64ed895c has identical production code and GPU fixtures to final head; the final commit retains the existing direct-compute cache test alongside the new indirect-table test.

The port adapts @santhoshkumar-dev’s tape metadata patch, and adds @ntamas94’s captured-buffer range exclusion using the original descriptor extent before vertex trimming. It retains current registered-view checks and ties stage donors to actual resident cache owners. During adaptation the existing recipe test caught lost donor references; these are restored for stages sharing an owner, while buffer-patched stages cannot reuse a stale recipe.

Three CPU gates pass: captured-buffer tagging, tape/interpreter origin parity and the shader disk-cache suite. The latter loads both direct-compute and indirect-table variants in fresh processes, checking actual nonempty buffer-patch metadata against a fresh compile. Targeted negative controls fail when the captured-range guard is removed or operand tracking is moved below the memoized return, then pass restored.

Additional qualification at support head c8ee0ae1c826 adds tests with unchanged production code:

  • Nine focused GPU cases pass, including fresh-process cold/warm disk-cache runs. Cold: 0 hits, 4 misses, 4 writes. Warm: 4 hits, 0 misses, 0 writes. Both still check actual changed-buffer pixels; zero cache failures, VUIDs or skips.
  • The CPU test now exercises repeated push and stored shader-data patches followed by descriptor cloning, preserving previous values and shared donors. Removing effective-push preservation fails the new assertion; restored code passes.
  • Cache/composition evidence archive, SHA-256 bb5cbaab47c75f7d59ef445f084ac6f3576c82023177fb77ec3bd7a436e61cec; downloaded and all 20 members verified.

Asterigos PPSA08194 native work is preliminary: the first cold candidate warmup exited 139 before gameplay. A later partial-cache warmup with APS5_VERIFY_DRAW_DATA_HITS=1 APS5_VERIFY_DRAW_ENTRIES=1 reached the directly reviewed stationary Outerrim scene and closed normally at 291.6 s with no mismatch diagnostic. These are not matched speed or stability samples; the pinned-main scene warmup is still in progress.

Native same-scene FPS/loading measurements remain pending. Main advanced to b87d71b58dbd during the run with no AGC, shader or VideoOut input changes; the archive records the exact pinned comparison. This is available as support for this PR and further review.

AI-assisted: yes

@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Matched warm native Asterigos comparison for the core support port at c8ee0ae1c826 against pinned main c4bff3e0c135: this stationary scene shows no demonstrated speedup.

48-present capture Main Port
p50 frame time 101.811 ms 102.083 ms
p90 112.910 ms 110.928 ms
p99 / max 120.432 ms 128.456 ms
GPU busy per present 58.655 ms 55.369 ms
Dropped events none none

One short pair does not establish statistical equivalence or a general regression. Full native GPU frames were directly reviewed: same initial stationary Outerrim checkpoint, character/camera, objective/HUD and 1920x1080 settings. Fog, leaves and idle animation vary. The code is the same production port as the preceding nine-case GPU/CPU qualification.

  • Complete native evidence: both raw traces, unmodified summary lines, digests, reviewed frames, source/bank proofs, protocol/scripts and every native outcome. SHA-256 9de98a6ddc807cf4fbc1b01d3da509630dedc1ce3b85b7a9edd0e2d2213012ed; downloaded and all 37 members verified. No binaries, modules, saves, caches or raw proprietary stacks.
  • AMD Ryzen 9 7950X/32 threads, RX6650XT, RADV Mesa 26.2.6-arch1.1, Linux 7.2.14-arch1-1. Background CPU activity was present and varied; aggregate observations are included.
  • Each scene ran once and restarted from the same original private checkpoint with its own completed cache. Disk-cache totals were main 3913 hits/0 misses/0 writes and port 3896/0/0. Separate real shader-source versions were retained; no cache-version bypass. Captures use only the 48-frame window and directory/trigger controls, default event capacity, no profiling/verification switches, and no screenshot during the trace.
  • Startup remains unresolved. Three candidate starts failed before tracing; the cold and first measured failures match an earlier e418-main null-fault signature, while the second measured failure is a distinct protection fault. Cause and any frequency effect of the port are unproven. Later menu-gated runs reached gameplay and exited normally. The accepted candidate presses Continue after the native menu is ready, whereas main used the earlier scheduled route; checkpoint and final scene match. All attempts remain in the ledger.
  • Both accepted native processes exited 0, with source/assets/checkpoint/cache seed/frozen bank unchanged, kernel setting restored, overlay unmounted and no remaining own native processes.

This is qualification of the exact pinned pair, not newer main. Upstream has since reached 7201da4f0e01 with renderer changes; that head needs a fresh integration/build before current-main claims. The traces still spend substantial inclusive time waiting on memory and preparing/releasing draws, so this result does not establish buffer-base reuse as the missing optimization for Asterigos. Scope totals overlap.

Unmodified official summary lines
{"commit":"c4bff3e0c135","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_SCREENSHOT_TRIGGER":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"0:48","APS5_TRACE_TRIGGER_FILE":"<path>"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08194","title":"Asterigos: Curse of the Stars","content_version":"01.004.001","resolution":"1920x1080","window":{"spec":"frames 0:48","first_present":4826,"ms":4918.068},"presents":48,"frame_ms":{"p50":101.811,"p90":112.910,"p99":120.432,"max":120.432},"gpu_busy_ms_per_present":58.655,"worker_busy_pct":{"queue worker 0x0":97.140,"queue worker 0x20":98.172},"phase_totals_ms":{"Driver.Completion":0.388,"Driver.Dispatch":500.784,"Driver.Dispatch.capture_resources":87.250,"Driver.Dispatch.decode_key_device_setup":32.945,"Driver.Dispatch.lookup_cache":1.914,"Driver.Dispatch.materialize":7.811,"Driver.Dispatch.prepared_invocation":5.756,"Driver.Draw":2830.139,"Driver.Draw.device_setup":86.188,"Driver.Draw.draw_enqueued":1090.670,"Driver.Draw.post_compile_prepare":14.723,"Driver.Draw.prepare":209.214,"Driver.Draw.shader_compile_and_link":1395.214,"Driver.EndSubmission":56.717,"Driver.Packet":9548.418,"Driver.Packet.device_lock":18.242,"Driver.Packet.dispatch":829.071,"Driver.Packet.draw":2847.576,"Driver.Packet.execute":424.460,"Driver.Packet.flip_flush":19.299,"Driver.Packet.flush_between_packets":80.678,"Driver.Packet.memory_wait":4557.923,"Driver.Packet.pipeline_drain":166.714,"Driver.Packet.pipeline_prepare":31.365,"Driver.Packet.prepare_memory":36.052,"Driver.Packet.rendering_wait":0.212,"Driver.Present":52.356,"Driver.Present.acquire_image":6.999,"Driver.Present.device_setup":0.047,"Driver.Present.gpu_mutex_wait":11.379,"Driver.Present.inflight_wait":0.137,"Driver.Present.present_display_buffer":21.279,"Driver.Present.queue_present":0.804,"Driver.Present.release_and_callback":0.039,"Driver.Present.render_fence_wait":11.445,"Driver.Present.resize":0.110,"Driver.Present.validate":0.015,"Driver.Suspend":0.029,"GpuMutex.wait.dispatch":10.563,"GpuMutex.wait.draw":36.697,"GpuMutex.wait.end":8.070,"GpuMutex.wait.fill":7.856,"GpuMutex.wait.flush":0.011,"GpuMutex.wait.hook":13.530,"GpuMutex.wait.label":24.655,"GpuMutex.wait.other":3.771,"GpuMutex.wait.present":11.275,"Graphics.Draw":2301.652,"Graphics.Draw.draw_and_resource_release":1826.587,"Graphics.Draw.index_upload":109.012,"Graphics.Draw.validate":185.651,"Graphics.Draw.vertex_upload":155.184,"Recorder.Reap":116.037,"Recorder.Submit":1392.733,"Recorder.Sync":41.309,"Recorder.WaitSerial":151.274,"Resources.Complete":104.908,"Resources.Prepare":91.022,"Shader.DrawStage":1109.595,"Shader.DrawStage.capture_resources":661.802,"Shader.DrawStage.materialize":324.629,"Shader.DrawStage.prepared_invocation":117.139,"VideoOut.Flip":54.096,"VideoOut.Flip.completion_mutex_wait":0.047,"VideoOut.Flip.config_mutex_wait":0.008,"VideoOut.Flip.frame_limit":0.033,"VideoOut.Flip.notify_game":0.392,"VideoOut.Flip.present":51.413,"VideoOut.Flip.validate":0.053,"VideoOut.Flip.vblank_wait":0.047,"VideoOut.Flip.window_prepare":0.088,"VideoOut.Flip.window_title":2.002,"VideoOut.Readiness":0.105,"VideoOut.Readiness.locks_validate":0.063,"Vulkan.Acquire":6.782,"Vulkan.Acquire.acquire_fence_wait":0.115,"Vulkan.Acquire.acquire_image":6.346,"Vulkan.Acquire.fence_reset":0.290,"Vulkan.Acquire.retired_swapchains":0.019,"Vulkan.Dispatch":133.449,"Vulkan.Dispatch.command_record":21.281,"Vulkan.Dispatch.shader_resources":110.769,"Vulkan.DispatchRecipe":1.954,"Vulkan.DispatchRecipe.command_record":1.927,"Vulkan.Present":20.093,"Vulkan.Present.command_record_scale":1.328,"Vulkan.Present.pixel_upload":0.120,"Vulkan.Present.queue_submit":18.582,"Vulkan.QueuePresent":0.729,"Vulkan.QueuePresent.queue_present":0.692,"Vulkan.Retire":11.343,"Vulkan.Retire.wait":10.866},"top_phases_ms_per_frame":{"Driver.Packet":198.925,"Driver.Packet.memory_wait":94.957,"Driver.Packet.draw":59.325,"Driver.Draw":58.961,"Graphics.Draw":47.951,"Graphics.Draw.draw_and_resource_release":38.054,"Driver.Draw.shader_compile_and_link":29.067,"Recorder.Submit":29.015},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":2997,"Graphics.Barrier.dcc-clear":1344,"Graphics.Barrier.dcc-keys":592,"Graphics.Barrier.dispatch-lead":1199,"Graphics.Barrier.dispatch-trail":2635,"Graphics.Barrier.draw":29832,"Graphics.Barrier.fill":975,"Graphics.Barrier.fill-clear":96,"Graphics.Barrier.indirect-args":192,"Graphics.Barrier.label-run":10253,"Graphics.Barrier.present-blit":96,"Graphics.Barrier.shadow-publish":419,"Graphics.Barrier.staging-in":9137,"Graphics.Barrier.staging-out":4423,"Graphics.Barrier.storage-upload":718,"Graphics.Barrier.storage-writeback":2622,"Graphics.BarrierMerged.dispatch-lead":1820,"Graphics.BarrierMerged.fill":657,"Graphics.BarrierMerged.label-run":651,"Graphics.BarrierMerged.shadow-publish":409,"Graphics.BarrierMerged.staging-in":4132,"Graphics.BarrierMerged.staging-out":4423,"Graphics.BarrierMerged.storage-writeback":674,"Graphics.Copy":9984,"Graphics.Copy.bytes":2109752736,"Graphics.RenderPass":18241,"Graphics.RenderPass.Close.command":5893,"Graphics.RenderPass.Close.image":7113,"Graphics.RenderPass.Close.key":1877,"Graphics.RenderPass.Close.label":651,"Graphics.RenderPass.Close.new-batch":2707,"Graphics.RenderPass.Continued":53561},"trace_dropped":false,"trace":"aps5-trace-c4bff3e0c135-4118920.json.gz"}
{"commit":"c8ee0ae1c826","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_SCREENSHOT_TRIGGER":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"0:48","APS5_TRACE_TRIGGER_FILE":"<path>"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08194","title":"Asterigos: Curse of the Stars","content_version":"01.004.001","resolution":"1920x1080","window":{"spec":"frames 0:48","first_present":4629,"ms":4909.156},"presents":48,"frame_ms":{"p50":102.083,"p90":110.928,"p99":128.456,"max":128.456},"gpu_busy_ms_per_present":55.369,"worker_busy_pct":{"queue worker 0x0":97.524,"queue worker 0x20":98.023},"phase_totals_ms":{"Driver.Completion":0.378,"Driver.Dispatch":307.936,"Driver.Dispatch.capture_resources":105.726,"Driver.Dispatch.decode_key_device_setup":28.606,"Driver.Dispatch.lookup_cache":1.792,"Driver.Dispatch.materialize":6.890,"Driver.Dispatch.prepared_invocation":5.361,"Driver.Draw":3034.915,"Driver.Draw.device_setup":90.058,"Driver.Draw.draw_enqueued":992.908,"Driver.Draw.post_compile_prepare":14.338,"Driver.Draw.prepare":204.274,"Driver.Draw.shader_compile_and_link":1696.295,"Driver.EndSubmission":54.704,"Driver.Packet":9544.594,"Driver.Packet.device_lock":18.939,"Driver.Packet.dispatch":626.268,"Driver.Packet.draw":3053.200,"Driver.Packet.execute":398.816,"Driver.Packet.flip_flush":19.899,"Driver.Packet.flush_between_packets":82.419,"Driver.Packet.memory_wait":4537.620,"Driver.Packet.pipeline_drain":197.001,"Driver.Packet.pipeline_prepare":34.158,"Driver.Packet.prepare_memory":38.363,"Driver.Packet.rendering_wait":0.218,"Driver.Present":52.672,"Driver.Present.acquire_image":10.651,"Driver.Present.device_setup":0.037,"Driver.Present.gpu_mutex_wait":6.420,"Driver.Present.inflight_wait":0.110,"Driver.Present.present_display_buffer":20.967,"Driver.Present.queue_present":0.835,"Driver.Present.release_and_callback":0.054,"Driver.Present.render_fence_wait":13.468,"Driver.Present.resize":0.084,"Driver.Present.validate":0.014,"Driver.Suspend":0.039,"GpuMutex.wait.dispatch":11.813,"GpuMutex.wait.draw":47.531,"GpuMutex.wait.end":4.931,"GpuMutex.wait.fill":6.343,"GpuMutex.wait.flush":0.018,"GpuMutex.wait.hook":20.302,"GpuMutex.wait.indirect":0.527,"GpuMutex.wait.label":25.279,"GpuMutex.wait.other":4.797,"GpuMutex.wait.present":6.317,"Graphics.Draw":2399.142,"Graphics.Draw.draw_and_resource_release":1920.352,"Graphics.Draw.index_upload":112.626,"Graphics.Draw.validate":189.514,"Graphics.Draw.vertex_upload":153.410,"Recorder.Reap":114.115,"Recorder.Submit":1381.107,"Recorder.Sync":8.310,"Resources.Complete":101.893,"Resources.Prepare":101.890,"Shader.DrawStage":1395.519,"Shader.DrawStage.capture_resources":944.798,"Shader.DrawStage.materialize":310.799,"Shader.DrawStage.prepared_invocation":133.623,"VideoOut.Flip":54.512,"VideoOut.Flip.completion_mutex_wait":0.045,"VideoOut.Flip.config_mutex_wait":0.004,"VideoOut.Flip.frame_limit":0.037,"VideoOut.Flip.notify_game":0.374,"VideoOut.Flip.present":51.773,"VideoOut.Flip.validate":0.051,"VideoOut.Flip.vblank_wait":0.043,"VideoOut.Flip.window_prepare":0.098,"VideoOut.Flip.window_title":2.083,"VideoOut.Readiness":0.104,"VideoOut.Readiness.locks_validate":0.055,"Vulkan.Acquire":10.478,"Vulkan.Acquire.acquire_fence_wait":0.112,"Vulkan.Acquire.acquire_image":10.035,"Vulkan.Acquire.fence_reset":0.297,"Vulkan.Acquire.retired_swapchains":0.022,"Vulkan.Dispatch":82.973,"Vulkan.Dispatch.command_record":19.939,"Vulkan.Dispatch.shader_resources":61.827,"Vulkan.DispatchRecipe":2.062,"Vulkan.DispatchRecipe.command_record":2.032,"Vulkan.Present":19.728,"Vulkan.Present.command_record_scale":1.455,"Vulkan.Present.pixel_upload":0.127,"Vulkan.Present.queue_submit":18.069,"Vulkan.QueuePresent":0.741,"Vulkan.QueuePresent.queue_present":0.709,"Vulkan.Retire":13.377,"Vulkan.Retire.wait":12.869},"top_phases_ms_per_frame":{"Driver.Packet":198.846,"Driver.Packet.memory_wait":94.534,"Driver.Packet.draw":63.608,"Driver.Draw":63.227,"Graphics.Draw":49.982,"Graphics.Draw.draw_and_resource_release":40.007,"Driver.Draw.shader_compile_and_link":35.339,"Shader.DrawStage":29.073},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":3024,"Graphics.Barrier.dcc-clear":1344,"Graphics.Barrier.dcc-keys":616,"Graphics.Barrier.dispatch-lead":1020,"Graphics.Barrier.dispatch-trail":2385,"Graphics.Barrier.draw":32030,"Graphics.Barrier.fill":967,"Graphics.Barrier.fill-clear":96,"Graphics.Barrier.indirect-args":192,"Graphics.Barrier.label-run":9810,"Graphics.Barrier.present-blit":96,"Graphics.Barrier.shadow-publish":205,"Graphics.Barrier.staging-in":8440,"Graphics.Barrier.staging-out":4067,"Graphics.Barrier.storage-upload":410,"Graphics.Barrier.storage-writeback":2591,"Graphics.BarrierMerged.dispatch-lead":1749,"Graphics.BarrierMerged.fill":665,"Graphics.BarrierMerged.label-run":640,"Graphics.BarrierMerged.shadow-publish":189,"Graphics.BarrierMerged.staging-in":3761,"Graphics.BarrierMerged.staging-out":4067,"Graphics.BarrierMerged.storage-writeback":661,"Graphics.Copy":9098,"Graphics.Copy.bytes":1902708864,"Graphics.RenderPass":19706,"Graphics.RenderPass.Close.command":5612,"Graphics.RenderPass.Close.image":7909,"Graphics.RenderPass.Close.key":2819,"Graphics.RenderPass.Close.label":640,"Graphics.RenderPass.Close.new-batch":2726,"Graphics.RenderPass.Continued":55188},"trace_dropped":false,"trace":"aps5-trace-c8ee0ae1c826-185987.json.gz"}
Main trace_digest.py --top 8
**frames 0:48** from present 4826: 48 presents, frame p50 101.8 / p90 112.9 / p99 120.4 / max 120.4 ms, GPU busy 58.7 ms per present
AMD Radeon RX 6650 XT (RADV NAVI23), radv Mesa 26.2.6-arch1.1, Linux 7.2.14-arch1-1, 1920x1080, commit c4bff3e0c135, dropped: no

```json
{"commit":"c4bff3e0c135","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_SCREENSHOT_TRIGGER":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"0:48","APS5_TRACE_TRIGGER_FILE":"<path>"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08194","title":"Asterigos: Curse of the Stars","content_version":"01.004.001","resolution":"1920x1080","window":{"spec":"frames 0:48","first_present":4826,"ms":4918.068},"presents":48,"frame_ms":{"p50":101.811,"p90":112.91,"p99":120.432,"max":120.432},"gpu_busy_ms_per_present":58.655,"worker_busy_pct":{"queue worker 0x0":97.14,"queue worker 0x20":98.172},"phase_totals_ms":{"Driver.Completion":0.388,"Driver.Dispatch":500.784,"Driver.Dispatch.capture_resources":87.25,"Driver.Dispatch.decode_key_device_setup":32.945,"Driver.Dispatch.lookup_cache":1.914,"Driver.Dispatch.materialize":7.811,"Driver.Dispatch.prepared_invocation":5.756,"Driver.Draw":2830.139,"Driver.Draw.device_setup":86.188,"Driver.Draw.draw_enqueued":1090.67,"Driver.Draw.post_compile_prepare":14.723,"Driver.Draw.prepare":209.214,"Driver.Draw.shader_compile_and_link":1395.214,"Driver.EndSubmission":56.717,"Driver.Packet":9548.418,"Driver.Packet.device_lock":18.242,"Driver.Packet.dispatch":829.071,"Driver.Packet.draw":2847.576,"Driver.Packet.execute":424.46,"Driver.Packet.flip_flush":19.299,"Driver.Packet.flush_between_packets":80.678,"Driver.Packet.memory_wait":4557.923,"Driver.Packet.pipeline_drain":166.714,"Driver.Packet.pipeline_prepare":31.365,"Driver.Packet.prepare_memory":36.052,"Driver.Packet.rendering_wait":0.212,"Driver.Present":52.356,"Driver.Present.acquire_image":6.999,"Driver.Present.device_setup":0.047,"Driver.Present.gpu_mutex_wait":11.379,"Driver.Present.inflight_wait":0.137,"Driver.Present.present_display_buffer":21.279,"Driver.Present.queue_present":0.804,"Driver.Present.release_and_callback":0.039,"Driver.Present.render_fence_wait":11.445,"Driver.Present.resize":0.11,"Driver.Present.validate":0.015,"Driver.Suspend":0.029,"GpuMutex.wait.dispatch":10.563,"GpuMutex.wait.draw":36.697,"GpuMutex.wait.end":8.07,"GpuMutex.wait.fill":7.856,"GpuMutex.wait.flush":0.011,"GpuMutex.wait.hook":13.53,"GpuMutex.wait.label":24.655,"GpuMutex.wait.other":3.771,"GpuMutex.wait.present":11.275,"Graphics.Draw":2301.652,"Graphics.Draw.draw_and_resource_release":1826.587,"Graphics.Draw.index_upload":109.012,"Graphics.Draw.validate":185.651,"Graphics.Draw.vertex_upload":155.184,"Recorder.Reap":116.037,"Recorder.Submit":1392.733,"Recorder.Sync":41.309,"Recorder.WaitSerial":151.274,"Resources.Complete":104.908,"Resources.Prepare":91.022,"Shader.DrawStage":1109.595,"Shader.DrawStage.capture_resources":661.802,"Shader.DrawStage.materialize":324.629,"Shader.DrawStage.prepared_invocation":117.139,"VideoOut.Flip":54.096,"VideoOut.Flip.completion_mutex_wait":0.047,"VideoOut.Flip.config_mutex_wait":0.008,"VideoOut.Flip.frame_limit":0.033,"VideoOut.Flip.notify_game":0.392,"VideoOut.Flip.present":51.413,"VideoOut.Flip.validate":0.053,"VideoOut.Flip.vblank_wait":0.047,"VideoOut.Flip.window_prepare":0.088,"VideoOut.Flip.window_title":2.002,"VideoOut.Readiness":0.105,"VideoOut.Readiness.locks_validate":0.063,"Vulkan.Acquire":6.782,"Vulkan.Acquire.acquire_fence_wait":0.115,"Vulkan.Acquire.acquire_image":6.346,"Vulkan.Acquire.fence_reset":0.29,"Vulkan.Acquire.retired_swapchains":0.019,"Vulkan.Dispatch":133.449,"Vulkan.Dispatch.command_record":21.281,"Vulkan.Dispatch.shader_resources":110.769,"Vulkan.DispatchRecipe":1.954,"Vulkan.DispatchRecipe.command_record":1.927,"Vulkan.Present":20.093,"Vulkan.Present.command_record_scale":1.328,"Vulkan.Present.pixel_upload":0.12,"Vulkan.Present.queue_submit":18.582,"Vulkan.QueuePresent":0.729,"Vulkan.QueuePresent.queue_present":0.692,"Vulkan.Retire":11.343,"Vulkan.Retire.wait":10.866},"top_phases_ms_per_frame":{"Driver.Packet":198.925,"Driver.Packet.memory_wait":94.957,"Driver.Packet.draw":59.325,"Driver.Draw":58.961,"Graphics.Draw":47.951,"Graphics.Draw.draw_and_resource_release":38.054,"Driver.Draw.shader_compile_and_link":29.067,"Recorder.Submit":29.015},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":2997,"Graphics.Barrier.dcc-clear":1344,"Graphics.Barrier.dcc-keys":592,"Graphics.Barrier.dispatch-lead":1199,"Graphics.Barrier.dispatch-trail":2635,"Graphics.Barrier.draw":29832,"Graphics.Barrier.fill":975,"Graphics.Barrier.fill-clear":96,"Graphics.Barrier.indirect-args":192,"Graphics.Barrier.label-run":10253,"Graphics.Barrier.present-blit":96,"Graphics.Barrier.shadow-publish":419,"Graphics.Barrier.staging-in":9137,"Graphics.Barrier.staging-out":4423,"Graphics.Barrier.storage-upload":718,"Graphics.Barrier.storage-writeback":2622,"Graphics.BarrierMerged.dispatch-lead":1820,"Graphics.BarrierMerged.fill":657,"Graphics.BarrierMerged.label-run":651,"Graphics.BarrierMerged.shadow-publish":409,"Graphics.BarrierMerged.staging-in":4132,"Graphics.BarrierMerged.staging-out":4423,"Graphics.BarrierMerged.storage-writeback":674,"Graphics.Copy":9984,"Graphics.Copy.bytes":2109752736,"Graphics.RenderPass":18241,"Graphics.RenderPass.Close.command":5893,"Graphics.RenderPass.Close.image":7113,"Graphics.RenderPass.Close.key":1877,"Graphics.RenderPass.Close.label":651,"Graphics.RenderPass.Close.new-batch":2707,"Graphics.RenderPass.Continued":53561},"trace_dropped":false,"trace":"aps5-trace-c4bff3e0c135-4118920.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 4836: 120.4 ms at 1118 ms: Driver.Packet (queue worker 0x20) 119.9, Driver.Packet.memory_wait (queue worker 0x20) 115.8, Driver.Packet (queue worker 0x0) 97.1, batch (gpu) 63.5
  • present 4829: 120.4 ms at 331 ms: Driver.Packet (queue worker 0x20) 119.6, Driver.Packet.memory_wait (queue worker 0x20) 115.5, Driver.Packet (queue worker 0x0) 96.5, Driver.Packet.draw (queue worker 0x0) 64.0
  • present 4835: 115.5 ms at 1003 ms: Driver.Packet (queue worker 0x20) 115.2, Driver.Packet.memory_wait (queue worker 0x20) 107.6, Driver.Packet (queue worker 0x0) 90.9, Driver.Packet.draw (queue worker 0x0) 60.9
  • present 4834: 113.2 ms at 889 ms: Driver.Packet (queue worker 0x20) 112.8, Driver.Packet.memory_wait (queue worker 0x20) 108.7, Driver.Packet (queue worker 0x0) 90.8, batch (gpu) 62.2
  • present 4830: 112.9 ms at 451 ms: Driver.Packet (queue worker 0x20) 112.5, Driver.Packet.memory_wait (queue worker 0x20) 107.4, Driver.Packet (queue worker 0x0) 89.5, Driver.Packet.draw (queue worker 0x0) 61.5

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 4836: 120.4 ms at 1118 ms, persistence 31.5 ms
  • present 4860: 107.0 ms at 3564 ms, persistence 15.7 ms
  • present 4829: 120.4 ms at 331 ms, persistence 15.2 ms
  • present 4868: 102.7 ms at 4336 ms, persistence 13.9 ms
  • present 4852: 104.9 ms at 2779 ms, persistence 10.5 ms
  • present 4846: 105.7 ms at 2175 ms, persistence 9.6 ms
  • present 4870: 102.7 ms at 4533 ms, persistence 8.9 ms
  • present 4841: 112.0 ms at 1664 ms, persistence 8.0 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 78.8 (77 %) 3.2 (3 %) 20.4 95.2 Driver.Packet 81.4, Driver.EndSubmission 0.6
draw committer 66.6 (65 %) 1.4 (1 %) 34.5 29.5 Graphics.Draw 39.8, Recorder.Submit 26.4
presenter 0.7 (1 %) 0.5 (0 %) 101.3 0.1 VideoOut.Flip 1.1, Driver.Present 0.0
queue worker 0x20 4.9 (5 %) 95.6 (93 %) 1.9 0.1 Driver.Packet 100.0, Driver.EndSubmission 0.5
gpu 58.4 (57 %) 0.0 (0 %) 44.0 0.0 batch 58.4

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 181.4, Driver.Packet.memory_wait 94.9, batch 58.4, Driver.Packet.draw 51.5, Driver.Draw 51.1, Graphics.Draw 39.8, Graphics.Draw.draw_and_resource_release 29.4, Recorder.Submit 29.0

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x20) 114.6 ms at 1066 ms, present 4835
  • Driver.Packet.memory_wait (queue worker 0x20) 112.6 ms at 275 ms, present 4828
  • Driver.Packet.memory_wait (queue worker 0x20) 112.1 ms at 393 ms, present 4829
  • Driver.Packet.memory_wait (queue worker 0x20) 110.7 ms at 833 ms, present 4833
  • Driver.Packet.memory_wait (queue worker 0x20) 110.0 ms at 1611 ms, present 4840
  • Driver.Packet.memory_wait (queue worker 0x20) 109.7 ms at 948 ms, present 4834
  • Driver.Packet.memory_wait (queue worker 0x20) 106.8 ms at 59 ms, present 4826
  • Driver.Packet.memory_wait (queue worker 0x20) 105.0 ms at 1295 ms, present 4837

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 781: 8.1 ms at 1091 ms, present 4835: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.6, Graphics.Draw.draw_and_resource_release (draw committer) 0.6, Recorder.Submit (draw committer) 0.3
  • batch 3240: 7.5 ms at 4412 ms, present 4868: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.2, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.7, Resources.Complete (draw committer) 0.2
  • batch 1866: 7.4 ms at 2563 ms, present 4849: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.2, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.6, Resources.Complete (draw committer) 0.1
  • batch 2233: 7.4 ms at 3055 ms, present 4854: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.0, Graphics.Draw.draw_and_resource_release (draw committer) 0.8, Recorder.Submit (draw committer) 0.3
  • batch 2523: 7.4 ms at 3442 ms, present 4858: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.3, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.4, Resources.Complete (draw committer) 0.1

</details>

<details>
<summary>Port trace_digest.py --top 8</summary>

```text
**frames 0:48** from present 4629: 48 presents, frame p50 102.1 / p90 110.9 / p99 128.5 / max 128.5 ms, GPU busy 55.4 ms per present
AMD Radeon RX 6650 XT (RADV NAVI23), radv Mesa 26.2.6-arch1.1, Linux 7.2.14-arch1-1, 1920x1080, commit c8ee0ae1c826, dropped: no

```json
{"commit":"c8ee0ae1c826","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_SCREENSHOT_TRIGGER":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"0:48","APS5_TRACE_TRIGGER_FILE":"<path>"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08194","title":"Asterigos: Curse of the Stars","content_version":"01.004.001","resolution":"1920x1080","window":{"spec":"frames 0:48","first_present":4629,"ms":4909.156},"presents":48,"frame_ms":{"p50":102.083,"p90":110.928,"p99":128.456,"max":128.456},"gpu_busy_ms_per_present":55.369,"worker_busy_pct":{"queue worker 0x0":97.524,"queue worker 0x20":98.023},"phase_totals_ms":{"Driver.Completion":0.378,"Driver.Dispatch":307.936,"Driver.Dispatch.capture_resources":105.726,"Driver.Dispatch.decode_key_device_setup":28.606,"Driver.Dispatch.lookup_cache":1.792,"Driver.Dispatch.materialize":6.89,"Driver.Dispatch.prepared_invocation":5.361,"Driver.Draw":3034.915,"Driver.Draw.device_setup":90.058,"Driver.Draw.draw_enqueued":992.908,"Driver.Draw.post_compile_prepare":14.338,"Driver.Draw.prepare":204.274,"Driver.Draw.shader_compile_and_link":1696.295,"Driver.EndSubmission":54.704,"Driver.Packet":9544.594,"Driver.Packet.device_lock":18.939,"Driver.Packet.dispatch":626.268,"Driver.Packet.draw":3053.2,"Driver.Packet.execute":398.816,"Driver.Packet.flip_flush":19.899,"Driver.Packet.flush_between_packets":82.419,"Driver.Packet.memory_wait":4537.62,"Driver.Packet.pipeline_drain":197.001,"Driver.Packet.pipeline_prepare":34.158,"Driver.Packet.prepare_memory":38.363,"Driver.Packet.rendering_wait":0.218,"Driver.Present":52.672,"Driver.Present.acquire_image":10.651,"Driver.Present.device_setup":0.037,"Driver.Present.gpu_mutex_wait":6.42,"Driver.Present.inflight_wait":0.11,"Driver.Present.present_display_buffer":20.967,"Driver.Present.queue_present":0.835,"Driver.Present.release_and_callback":0.054,"Driver.Present.render_fence_wait":13.468,"Driver.Present.resize":0.084,"Driver.Present.validate":0.014,"Driver.Suspend":0.039,"GpuMutex.wait.dispatch":11.813,"GpuMutex.wait.draw":47.531,"GpuMutex.wait.end":4.931,"GpuMutex.wait.fill":6.343,"GpuMutex.wait.flush":0.018,"GpuMutex.wait.hook":20.302,"GpuMutex.wait.indirect":0.527,"GpuMutex.wait.label":25.279,"GpuMutex.wait.other":4.797,"GpuMutex.wait.present":6.317,"Graphics.Draw":2399.142,"Graphics.Draw.draw_and_resource_release":1920.352,"Graphics.Draw.index_upload":112.626,"Graphics.Draw.validate":189.514,"Graphics.Draw.vertex_upload":153.41,"Recorder.Reap":114.115,"Recorder.Submit":1381.107,"Recorder.Sync":8.31,"Resources.Complete":101.893,"Resources.Prepare":101.89,"Shader.DrawStage":1395.519,"Shader.DrawStage.capture_resources":944.798,"Shader.DrawStage.materialize":310.799,"Shader.DrawStage.prepared_invocation":133.623,"VideoOut.Flip":54.512,"VideoOut.Flip.completion_mutex_wait":0.045,"VideoOut.Flip.config_mutex_wait":0.004,"VideoOut.Flip.frame_limit":0.037,"VideoOut.Flip.notify_game":0.374,"VideoOut.Flip.present":51.773,"VideoOut.Flip.validate":0.051,"VideoOut.Flip.vblank_wait":0.043,"VideoOut.Flip.window_prepare":0.098,"VideoOut.Flip.window_title":2.083,"VideoOut.Readiness":0.104,"VideoOut.Readiness.locks_validate":0.055,"Vulkan.Acquire":10.478,"Vulkan.Acquire.acquire_fence_wait":0.112,"Vulkan.Acquire.acquire_image":10.035,"Vulkan.Acquire.fence_reset":0.297,"Vulkan.Acquire.retired_swapchains":0.022,"Vulkan.Dispatch":82.973,"Vulkan.Dispatch.command_record":19.939,"Vulkan.Dispatch.shader_resources":61.827,"Vulkan.DispatchRecipe":2.062,"Vulkan.DispatchRecipe.command_record":2.032,"Vulkan.Present":19.728,"Vulkan.Present.command_record_scale":1.455,"Vulkan.Present.pixel_upload":0.127,"Vulkan.Present.queue_submit":18.069,"Vulkan.QueuePresent":0.741,"Vulkan.QueuePresent.queue_present":0.709,"Vulkan.Retire":13.377,"Vulkan.Retire.wait":12.869},"top_phases_ms_per_frame":{"Driver.Packet":198.846,"Driver.Packet.memory_wait":94.534,"Driver.Packet.draw":63.608,"Driver.Draw":63.227,"Graphics.Draw":49.982,"Graphics.Draw.draw_and_resource_release":40.007,"Driver.Draw.shader_compile_and_link":35.339,"Shader.DrawStage":29.073},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":3024,"Graphics.Barrier.dcc-clear":1344,"Graphics.Barrier.dcc-keys":616,"Graphics.Barrier.dispatch-lead":1020,"Graphics.Barrier.dispatch-trail":2385,"Graphics.Barrier.draw":32030,"Graphics.Barrier.fill":967,"Graphics.Barrier.fill-clear":96,"Graphics.Barrier.indirect-args":192,"Graphics.Barrier.label-run":9810,"Graphics.Barrier.present-blit":96,"Graphics.Barrier.shadow-publish":205,"Graphics.Barrier.staging-in":8440,"Graphics.Barrier.staging-out":4067,"Graphics.Barrier.storage-upload":410,"Graphics.Barrier.storage-writeback":2591,"Graphics.BarrierMerged.dispatch-lead":1749,"Graphics.BarrierMerged.fill":665,"Graphics.BarrierMerged.label-run":640,"Graphics.BarrierMerged.shadow-publish":189,"Graphics.BarrierMerged.staging-in":3761,"Graphics.BarrierMerged.staging-out":4067,"Graphics.BarrierMerged.storage-writeback":661,"Graphics.Copy":9098,"Graphics.Copy.bytes":1902708864,"Graphics.RenderPass":19706,"Graphics.RenderPass.Close.command":5612,"Graphics.RenderPass.Close.image":7909,"Graphics.RenderPass.Close.key":2819,"Graphics.RenderPass.Close.label":640,"Graphics.RenderPass.Close.new-batch":2726,"Graphics.RenderPass.Continued":55188},"trace_dropped":false,"trace":"aps5-trace-c8ee0ae1c826-185987.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 4641: 128.5 ms at 1249 ms: Driver.Packet (queue worker 0x20) 128.0, Driver.Packet.memory_wait (queue worker 0x20) 119.4, Driver.Packet (queue worker 0x0) 107.2, Driver.Packet.draw (queue worker 0x0) 70.7
  • present 4634: 117.0 ms at 540 ms: Driver.Packet (queue worker 0x20) 115.5, Driver.Packet.memory_wait (queue worker 0x20) 109.9, Driver.Packet (queue worker 0x0) 97.1, Driver.Packet.draw (queue worker 0x0) 68.4
  • present 4633: 113.7 ms at 427 ms: Driver.Packet (queue worker 0x20) 113.2, Driver.Packet.memory_wait (queue worker 0x20) 109.2, Driver.Packet (queue worker 0x0) 93.5, Driver.Packet.draw (queue worker 0x0) 64.6
  • present 4669: 112.2 ms at 4095 ms: Driver.Packet (queue worker 0x20) 111.7, Driver.Packet.memory_wait (queue worker 0x20) 108.6, Driver.Packet (queue worker 0x0) 91.7, Driver.Packet.draw (queue worker 0x0) 62.6
  • present 4630: 110.9 ms at 101 ms: Driver.Packet (queue worker 0x20) 110.5, Driver.Packet.memory_wait (queue worker 0x20) 104.9, Driver.Packet (queue worker 0x0) 90.8, Driver.Packet.draw (queue worker 0x0) 59.9

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 4641: 128.5 ms at 1249 ms, persistence 36.6 ms
  • present 4634: 117.0 ms at 540 ms, persistence 24.6 ms
  • present 4669: 112.2 ms at 4095 ms, persistence 19.8 ms
  • present 4655: 109.3 ms at 2675 ms, persistence 16.1 ms
  • present 4663: 105.8 ms at 3483 ms, persistence 11.0 ms
  • present 4676: 102.7 ms at 4806 ms, persistence 10.8 ms
  • present 4665: 103.7 ms at 3683 ms, persistence 8.7 ms
  • present 4658: 105.5 ms at 2985 ms, persistence 8.3 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 82.7 (81 %) 0.1 (0 %) 19.5 96.9 Driver.Packet 82.2, Driver.EndSubmission 0.6
draw committer 68.4 (67 %) 1.5 (1 %) 32.4 31.3 Graphics.Draw 41.4, Recorder.Submit 26.7
presenter 0.7 (1 %) 0.4 (0 %) 101.1 0.1 VideoOut.Flip 1.1, Driver.Present 0.0
queue worker 0x20 4.8 (5 %) 95.4 (93 %) 2.0 0.1 Driver.Packet 99.7, Driver.EndSubmission 0.5
gpu 55.3 (54 %) 0.0 (0 %) 47.0 0.0 batch 55.3

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 181.9, Driver.Packet.memory_wait 94.5, Driver.Packet.draw 56.1, Driver.Draw 55.7, batch 55.3, Graphics.Draw 41.4, Graphics.Draw.draw_and_resource_release 30.6, Recorder.Submit 28.8

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x20) 118.5 ms at 1192 ms, present 4640
  • Driver.Packet.memory_wait (queue worker 0x20) 112.5 ms at 479 ms, present 4633
  • Driver.Packet.memory_wait (queue worker 0x20) 111.1 ms at 4036 ms, present 4668
  • Driver.Packet.memory_wait (queue worker 0x20) 104.7 ms at 153 ms, present 4630
  • Driver.Packet.memory_wait (queue worker 0x20) 104.2 ms at 2625 ms, present 4654
  • Driver.Packet.memory_wait (queue worker 0x20) 104.1 ms at 262 ms, present 4631
  • Driver.Packet.memory_wait (queue worker 0x20) 104.1 ms at 4150 ms, present 4669
  • Driver.Packet.memory_wait (queue worker 0x20) 103.0 ms at 371 ms, present 4632

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 792: 7.4 ms at 1121 ms, present 4639: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.9, Graphics.Draw.draw_and_resource_release (draw committer) 0.6, Recorder.Submit (draw committer) 0.4
  • batch 3351: 7.3 ms at 4692 ms, present 4674: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.4, Graphics.Draw.draw_and_resource_release (draw committer) 1.1, Recorder.Submit (draw committer) 0.4
  • batch 3419: 7.1 ms at 4783 ms, present 4675: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.8, Graphics.Draw.draw_and_resource_release (draw committer) 0.7, Recorder.Submit (draw committer) 0.3
  • batch 1017: 7.0 ms at 1450 ms, present 4642: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.7, Graphics.Draw.draw_and_resource_release (draw committer) 0.6, Recorder.Submit (draw committer) 0.5, Resources.Complete (draw committer) 0.1
  • batch 1737: 6.7 ms at 2441 ms, present 4652: GPU no ranges; recorded by Graphics.Draw (draw committer) 1.0, Graphics.Draw.draw_and_resource_release (draw committer) 0.8, Recorder.Submit (draw committer) 0.3

</details>

AI-assisted: yes

@relativespace2K

Copy link
Copy Markdown
Contributor

@TheAggie this branch is superseded by #20130. I ported its buffer-base stage reuse to current main (JJenkx's support port 4a91615413f7, original authors kept) and added the data-only relocation path from #9755; the new PR is a draft and lists #19398 as a dependency. I did not push to your branch. If you agree, #20130 can replace this one; the overlap warning is expected until then.

relativespace2K added a commit to relativespace2K/AnyPS5 that referenced this pull request Nov 15, 2026
finishDraw set matched[i] after stageReused on the data-only candidate path, so a forwarded user word patched into push constants kept its old value. Select the patched constants for candidates too, and keep the data-only branch on the vertex path as boykopovar#5609 did until a non-vertex path is tested.
@adriadam10 adriadam10 removed their assignment Nov 17, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

Changes are required before merge: prevent creation of a partial relocated draw entry when any stage lacks an eligible donor.

What I ran

Reviewed head 09238da8206e0aa70d8966c69f822c297da36308. Read the prepared description, commits, diff and manifest, plus targeted source for draw relocation, cache lookup/capture, descriptor metadata, pipeline dynamic state, pending image overlap, the moved-buffer test and shader disk cache. No build or tests were run. The author reports Windows 11 testing and performance captures; these were not independently run here.

Results

Check Result Note
Prepared diff review passed Reviewed all 1,468 diff lines
Targeted source review passed Main relocation and related paths inspected
Build and tests not run No local execution performed

Findings

Blocking

  • DrawRelocate.cpp:271 publishes a relocated entry even when complete is false. In that case, rejected or unavailable stages remain empty, but the entry is still returned with the donor decode. Draw.cpp:105-108 then treats any non-null entry as a cache hit candidate, and lookup marks a stage-size mismatch as a miss; later stage reuse can consume only the matching subset. This can turn partial donor availability into a draw built from an inconsistent set of relocated and newly compiled stages. Return without publishing the relocated entry unless all required stages are available and valid, or make the caller fall back to a full decode/build when relocation is incomplete.

Non-blocking

None.

Not verified

No build, test suite, Vulkan device run, Linux build, or performance capture was performed. The description’s test and performance results are author-reported. All changed files listed as reviewed in the manifest were present and read via the prepared diff; targeted repository source reads are listed above. Excluded files were not inspected individually.

To get this to a good state

Require complete, valid donor coverage before returning a relocated draw entry, then rerun the moved-buffer and draw-cache tests on the updated head.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs needs rebase Conflicts with main, rebase needed perf numbers missing perf pull request without a before and after summary line perf Performance change shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.