perf: PPSA26344 buffer loads through V#s read from a user-data table fall back to read_bda_span #15780
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-11-04T14:36:13Z.
Title and scene
PPSA26344 01.008.000, 1920x1080. Fork: brightness screen. Stock
main: black screen before it.What is slow or what changed
This asks for a missing fast path. It is not a bug report about the existing path.
Builds
mainatb11c7bf84f: this is where the code references below come from. The cost figures come from a warm 1200 s run. The game stays on a black screen before the brightness-calibration screen for the whole run, and the window title shows 0.32 FPS at 1150 s.yotei/bestfork at4565a51dc4: built from local tree66b1722d5b, which adds a GCC build fix and an inert local preset. This build reaches the brightness screen and the opening cinematic. I used it for the two programs below, because stockmainhas not reached the scene that dispatches them in my runs.The code path
TakeGpuDescriptor(core/shader/recompiler/Optimization/src/ResourceTracker.cpp:2225atb11c7bf84f) makes a buffer resource only whenValidateSourcecan follow the V# back to a fixed source. Otherwise it setsmemory.gpuDescriptor = true(line 2244) andusesDma, and the backend emits each load as aread_bda_spancall. That is the intended general path for GPU-selected V#s.When a V# or T# is read from a table for an image, there are table lowerings already:
I found no merged or open change that plans a buffer load through such a table. In #7223 the
buffer=truetable column only serves as the heap for a nested T# lookup. The other open table PRs I checked (#7642, #9790, #9969, #15555) are image or T# side.Related: #7138 (cost of decoding a runtime V# with
ReadConstBuffer, on a related runtime-V# path), #8721 (table-driven formatted loads) and #14260 (draft; a BDA range cache in span reads; it makes eachread_bda_spancall cheaper rather than removing the calls, see the Windows datapoint below).What the V#s in this title look like
I replayed
0x801edd2700and0x801eef6c00offline withagc_shader_replay --dis, with a temporary stderr print added inTakeGpuDescriptorright aftermemory.gpuDescriptor = true. The diff (bda-vsharp-trace.patch) was not committed.The print stops after 40 loads. It recorded 40 distinct buffer loads per program, and it does not see loads that passed
ValidateSource.LoadBufferU325,x23,x32,x430.ReadConstBufferof aGetBufferResource(GetUserData…)table, from 5 distinct pcs per program.IMul32(ReadLane(Phi …))of a loop value, which looks like a per-lane waterfall. I have not checked this against the EXEC handling in the disassembly. The other 6 index with a loop-counterPhi.The print ran on the fork's recompiler.
TakeGpuDescriptorandValidateSourceare byte-identical in4565a51dc4andb11c7bf84f. However, the rest ofResourceTracker.cppchanged a lot between them (about 760 lines, including #7223), and I have not confirmed that these loads still reach the fallback onmain.Cost: per-program GPU time from
APS5_PROFILE_GPU=1[gputime]prints only the top 12 programs per line, so each share below is a range. The lower bound counts only listed time. The upper bound assumes all unlisted time belongs toread_bda_spanprograms.Fork (
yotei/best), brightness screen: 8[gputime]lines, 197 presents, 25984 ms of GPU program time (131.9 ms per present). Top 5 programs by total GPU time:read_bda_spancalls0x801edd27000x801eef6c000x801ee18b000x2145d000x80001fd400read_bda_span. Together they take between 26.2% and 63.2%.0x80001fd400has the same guest code length (6596 words) as0x801edd2700, and runs at 7.76 ms against 18.97 ms. The code differs, so this is only a rough comparison.Stock
main(b11c7bf84f), black-screen phase: 37[gputime]lines, 186 presents, 5629 ms of GPU program time. Top 8 programs by total GPU time:read_bda_spancalls0x8000253100|
0x80001e5f00| 8.47 | 95 | 181 ||
0x80002c4500| 0.23 | 3048 | 1 ||
0x80001fd400| 10.61 | 54 | 0 ||
0x800036e100| 1.89 | 186 | 16 ||
0x80003cee00| 1.60 | 186 | 0 ||
0x80001c0d00| 239.00 | 1 | 277 ||
0x80003d6000| 1.07 | 181 | 0 |read_bda_span. Together they take between 44.6% and 54.4% of GPU program time.mainprograms, so I don't know whether they use the same table pattern.I have not measured what a buffer-table lowering would save. These figures show what the current path costs, not what a fix would gain.
Independent datapoint: Windows, 02.002 (from @shahulmubeen-a's comment below, 2026-11-06; RTX 4070 Ti SUPER, a
yotei/best4565a51dc4-based build)0x801edd2700and0x801eef6c00at new addresses:0x801f64cc00(6608 code words, 447read_bda_spancalls) and0x801f808700(375 calls). The call counts match the two programs above; the code length differs slightly (6608 vs 6596 words).APS5_TRACE_BDA=1neither program shows an address access, so all of their span reads are GPU-selected V#s. That is an independent check of the pattern this issue describes; my own trace print above never looked at address-based reads.APS5_PROFILE_GPU=1) they take 7.9% and 5.9% of GPU program time. HOME is not GPU-bound on that build (about 42% busy), so he expects a lowering to matter most in the GPU-bound scenes measured here (brightness screen, opening cinematic).0x8000193900,0x80001aa100,0x80001c0300,0x800019ee00,0x80001df900; 0.8M-1.35M SPIR-V words each) whose span reads are address-based global loads. A buffer-table lowering would not reach those.read_bda_spancalls, a table lowering would remove the calls for the table-indexed subset.Scope note: his figures and mine come from different machines, OS, game versions and scenes, so they are not comparable to each other; each supports the same qualitative point.
Order of the summary lines below
The JSON below has two lines:
main: the last window of the warm run, withAPS5_PROFILE_GPUandAPS5_DUMP_SHADERSon.APS5_TRACE_SECONDS=240:10).Summary lines
Traces
Trace:
aps5-trace-66b1722d5b58-113844.json.gz(2.4 MB, a release asset on my fork).maintrace: stockmainnever left its black screen, so I have no comparable trace.APS5_PROFILE_GPU.Digest
python3 tools/trace_digest.py(frommain) on that trace:seconds 240:10 from present 1046: 16 presents, frame p50 658.9 / p90 734.5 / p99 755.2 / max 755.2 ms, GPU busy 626.7 ms per present
NVIDIA GeForce RTX 3080 Ti, NVIDIA 615.78.08, Linux 7.3.1-1-cachyos, 1920x1080, commit 66b1722d5b58, dropped: no
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.WorkerWait 4237.2, Driver.WorkerWait.idle_and_completion_poll 4049.5, Driver.Packet 1683.4, Driver.Packet.dispatch 902.4, Driver.Packet.memory_wait 692.6, Driver.Dispatch 669.8, batch 594.6, Driver.Dispatch.capture_resources 283.1, Driver.WorkerWait.dequeue_order 187.7, DrawPipeline.commit 185.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Capture
main: no. The cache carried over from a previous 1200 s run, but this run still had 12062 hits and 3486 misses, and it was still compiling 2 programs in the next-to-last 10 s window.APS5_TRACE_SUMMARY_EVERY=10plus the fork's README switches (in its summary line).APS5_PROFILE_GPU=1,APS5_DUMP_SHADERS=1,APS5_TRACE_SUMMARY_EVERY,APS5_TRACE_DIR,APS5_TRACE_PAD,APS5_PAD_INPUT_FILE,APS5_PAD_SCRIPT_REPEAT(scripted pad input) andAPS5_RESIDENT_LINEAR=1, plus the README switches.mainrun:APS5_PROFILE_GPU=1,APS5_DUMP_SHADERS=1,APS5_TRACE_SUMMARY_EVERY=10,APS5_TRACE_DIR, plus fouryotei/bestswitches thatmainrecognises (NO_RESULT_MEMO,NO_PIPELINE_JOURNAL,RESOURCE_CACHE_ENTRIES=1024,PIPELINE_DISPATCH).mainon the black screen; the fork on the brightness screen (profile) and the opening cinematic (trace).Machine: RTX 3080 Ti, NVIDIA 615.78.08, i9-11900K, 32 GB, Linux 7.3.1-1-cachyos.
AI-assisted: yes