Repository navigation
Conversation
CnRJay
left a comment
There was a problem hiding this comment.
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.jsonllines plus traces captured with noAPS5_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.
…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
left a comment
There was a problem hiding this comment.
Reviewed against the diff; two correctness problems, and the PR still needs a rebase once #4943 lands.
DrawRelocate.cpprelocatedContentKey: each read is hashed asmin(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 inlearnPendingRelocationwhen a run is longer than the limit.Pipeline.cpprecordedDrawState(): a function-local static with no lock, read and written byapply/setLibraryState. With two queue workers recording, therecorded.commands == commandscheck does not stop one worker comparing against the other's viewport/stencil values and skipping avkCmdSet*its command buffer needs. Keep this state per command buffer (next tocommandsin the recorder's batch) or make itthread_localif 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.jsonllines 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.
8417747 to
00816c0
Compare
adriadam10
left a comment
There was a problem hiding this comment.
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:690recordedDrawState()is still a function-localstaticwith no lock. With two queue workers recording, therecorded.commands == commandscheck does not stop one worker comparing against the other's viewport/stencil values and skipping avkCmdSet*its own command buffer needs. Keep the state per command buffer (next tocommandsin the recorder's batch), or make itthread_localif 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.
00816c0 to
d6abd55
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the rebase. The 64-word hash and eviction fixes are in; one point from the last review is still open:
Pipeline.cpp:690recordedDrawState()is still a function-localstaticwith no lock. With two queue workers recording,recorded.commands == commandsdoes not stop one worker comparing against the other's viewport/stencil values and skipping avkCmdSet*its own command buffer needs (and the writes race). Keep the state per command buffer (next tocommandsin the recorder's batch), or make itthread_localif recording is single-threaded; please say which one holds.- Still stacked on #4943, which is open; please rebase once it lands.
|
@CnRJay thanks for the review. Rebased onto
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 AI-assisted (Claude Code). |
d6abd55 to
bf7ad56
Compare
|
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 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 AI-assisted (Claude Code). |
|
@TheAggie I’m preparing a diagnostic-only change that shares Your head 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. |
|
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 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 Additional integration findings:
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 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 5fb1747diff --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. |
|
@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
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 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
Asterigos PPSA08194 native work is preliminary: the first cold candidate warmup exited 139 before gameplay. A later partial-cache warmup with Native same-scene FPS/loading measurements remain pending. Main advanced to AI-assisted: yes |
|
Matched warm native Asterigos comparison for the core support port at
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.
This is qualification of the exact pinned pair, not newer main. Upstream has since reached 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 8Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
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
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
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
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
|
|
@TheAggie this branch is superseded by #20130. I ported its buffer-base stage reuse to current |
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.
MarcZX10
left a comment
There was a problem hiding this comment.
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:271publishes a relocated entry even whencompleteis false. In that case, rejected or unavailable stages remain empty, but the entry is still returned with the donor decode.Draw.cpp:105-108then 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.
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.
bufferBaseSlotsfield of a result, and its Linux-only size asserts expect the grown structs.AnyPendingOverlapsconsults 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).APS5_VERIFY_DRAW_DATA_HITS=1) is left to that verification instead of being reused.APS5_NO_DRAW_RELOCATION=1turns the relocation off,APS5_NO_DRAW_STATE_FILTER=1the 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_reportandagc_driver_store_over_untrackedfail, and fail the same way on plain main here.agc_driver_prepared_shaders_debugfailed once in a parallel run and passes alone. Three newer tests,agc_driver_prepared_graphics_prebuild_0/_1andundeliverable_host_exception, fail under my test runner because it skips their environment changes and pass pattern; run with those, all three pass.ShaderDiskCache.cpponly 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 comparesbufferBaseSlots.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 withAPS5_NO_DRAW_RELOCATION=1.main940eba9a2, 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.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%.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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code