perf(agc): trim push constant assembly and fragment output lookups #18174
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18174"
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 meh7an on 2026-11-10T17:59:15Z.
What
Two trims in the per-draw work
planDrawdoes on the draw committer.AssemblePushConstantsbuilt the 256-byte push-constant block one byte at a time and checked overlap with a 256-entryboolarray. It now keeps one bit per DWORD in astd::uint64_tand copies each stage's range with onememcpy. TheRequirechecks are the same, in the same order, with the same messages.static_assert), and the slot check limits a range to 32 DWORDs, so the mask and the shift stay inside 64 bits.CachedFragmentOutputsalready let a thread serve a repeat of its last validation key without the shared memo, but only underAPS5_DRAW_PIPELINE(CommitTrims). It now does so by default.ThreadScratchslot: one TEB read, where it was an FLS value plus two emulatedthread_locals on MinGW.validationMutex, so the lock is not held while the key is copied.APS5_NO_LAST_FRAGMENT_OUTPUTS=1asks the memo for every draw (newENVIRONMENT.mdrow).ARCHITECTURE.mdno longer lists this skip underCommitTrims.ThreadFragmentOutputLookupsreturns per-thread counters (last-key hits, memo hits, validations) for the tests. They are plain increments on the thread's own slot.AssemblePushConstantsor the last-key lookup inCachedFragmentOutputs. This comes from a diff scan of the 2,012 open PRs for these symbols. Five PRs too large forgh pr diffwere checked file by file; #9508 and #7642 add a push-data mask of their own in a new function (PushDataPlacements).CommitTrims, so main's opt-in last key would also run by default once it lands. This PR moves the last key out ofCommitTrims, behind its own switch, in a TEB slot, remembering validated keys too. It does not depend on #15456, and the two compose. Both edit the sameARCHITECTURE.mdparagraph.CachedFragmentOutputs, and #5925 calls it from the pipeline journal; neither changes the lookup.tools/pr_overlap.pyfailed closed.ARCHITECTURE.mdparagraph, and with #16413 and #16753 at the top of the graphics test runner'smain, where each adds a mode.Draw.cpp,tests/Graphics.cpp,ENVIRONMENT.md,Shaders.hpp,Draw.hpp) were covered by the symbol scan above.Tested
Windows 11 (10.0.26300), NVIDIA GeForce RTX 2080 Ti (driver 617.14), Sonic Origins (PPSA05324) menu on the S3K page, 3840x2160, default environment.
164ac9b078and this change on top of it (e312386c58).eb3839d4f3without conflicts.git range-diffshows the same patch, nowb2ca8d4f36. The validation runs below used the rebased commit and maineb3839d4f3.New tests:
agc_driver_push_constant_assembly(agc_driver_graphics_tests --push-constant-assembly, also in the default run): compares the result, or the error, with a copy of the old byte loop.agc_driver_last_fragment_outputs, andagc_driver_last_fragment_outputs_off(the same withAPS5_NO_LAST_FRAGMENT_OUTPUTS=1): six real draws on the device, A, A, B, A, A, B, where B culls both faces (another key).Broken copies of the change, each run against these tests, are all caught (10 of 10):
Vulkan validation protocol (
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -V, same machine and GPU):agc_graphics_profile_draw,agc_driver_pass_break_reasons,agc_driver_draw_offset_indices,agc_driver_multisampled_pass_order,agc_driver_unclamped_normalized_blend,agc_driver_sample_order*(4),agc_driver_draw_cache_relocation*(6),agc_driver_depth_fast_clear_submit.eb3839d4f3. On the change, 18 pass, the three new tests included.agc_driver_sample_order_grid_referenceskips by its own check in both.was not found but was requested by env var VK_INSTANCE_LAYERSor aVUID-line. Both contain the same 53 host-import fallback lines fromagc_graphics_profile_draw; this machine's host heap reports an 8 MiB budget.tools/check_conventions.pyandtools/env_reference.py --checkpass. Full ctest was not run.Sampler (
APS5_SAMPLE_COMMITTERandAPS5_SAMPLE_WORKER, 60 s window, 3843 samples per thread). The first PR window ran on3781aedc48, an earlier revision of this commit. It has the same code, with the memo insert's lock in an inner block.164ac9b078(3 windows)planDrawselfplanDrawinclusiveAssemblePushConstantsinclusiveplanDrawself (0.7% of the committer, about 0.5 ms per frame), and about 10 in push constants (about 0.2 ms per frame, noisier).DrawPipeline::Enqueue.Two traced runs per arm (
APS5_TRACE_SECONDS=200:15), in main, PR, PR, main order, both commit IDs in the summaries:164ac9b078e312386c58Graphics.Drawper frame (retained events)seconds 200:15 from present 4465: 205 presents, frame p50 73.1 / p90 77.4 / p99 82.0 / max 83.4 ms, GPU busy 35.6 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit
164ac9b078, dropped: yesseconds 200:15 from present 4433: 205 presents, frame p50 72.8 / p90 77.1 / p99 81.1 / max 84.4 ms, GPU busy 36.2 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit e312386c5883, dropped: yes
seconds 200:15 from present 4416: 203 presents, frame p50 73.7 / p90 78.0 / p99 83.7 / max 84.5 ms, GPU busy 35.8 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit e312386c5883, dropped: yes
seconds 200:15 from present 4497: 207 presents, frame p50 72.3 / p90 76.6 / p99 81.1 / max 84.6 ms, GPU busy 35.8 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit
164ac9b078, dropped: yesTraces (two runs per zip, each with its
aps5-summary.jsonl): m330-main-traces.zip (main164ac9b078), m330-change-traces.zip (this PRe312386c58).trace_digest.py, main run 1
seconds 200:15 from present 4465: 205 presents, frame p50 73.1 / p90 77.4 / p99 82.0 / max 83.4 ms, GPU busy 35.6 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit
164ac9b078, dropped: yesIncomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
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): batch 35.5, Graphics.Draw 30.0, Graphics.Draw.draw_and_resource_release 22.2, Driver.Packet 17.1, Driver.Packet.draw 13.4, Driver.Draw 13.1, VideoOut.Flip 9.4, Driver.Present 9.3, VideoOut.Flip.present 9.2, Recorder.WaitSerial 9.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py, PR run 1
seconds 200:15 from present 4433: 205 presents, frame p50 72.8 / p90 77.1 / p99 81.1 / max 84.4 ms, GPU busy 36.2 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit e312386c5883, dropped: yes
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
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): batch 36.3, Graphics.Draw 29.6, Graphics.Draw.draw_and_resource_release 21.8, Driver.Packet 16.9, Driver.Packet.draw 13.3, Driver.Draw 12.9, VideoOut.Flip 10.3, Driver.Present 10.3, VideoOut.Flip.present 10.2, Recorder.WaitSerial 10.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py, PR run 2
seconds 200:15 from present 4416: 203 presents, frame p50 73.7 / p90 78.0 / p99 83.7 / max 84.5 ms, GPU busy 35.8 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit e312386c5883, dropped: yes
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
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): batch 35.6, Graphics.Draw 30.7, Graphics.Draw.draw_and_resource_release 22.5, Driver.Packet 17.7, Driver.Packet.draw 13.8, Driver.Draw 13.5, VideoOut.Flip 9.1, Driver.Present 9.0, VideoOut.Flip.present 8.9, Recorder.WaitSerial 8.9
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py, main run 2
seconds 200:15 from present 4497: 207 presents, frame p50 72.3 / p90 76.6 / p99 81.1 / max 84.6 ms, GPU busy 35.8 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit
164ac9b078, dropped: yesIncomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
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): batch 35.8, Graphics.Draw 29.9, Graphics.Draw.draw_and_resource_release 22.5, Driver.Packet 17.0, Driver.Packet.draw 13.3, Driver.Draw 12.9, VideoOut.Flip 9.8, Driver.Present 9.7, VideoOut.Flip.present 9.7, Recorder.WaitSerial 9.6
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-13T02:51:32Z.
Review: COMMENTED
Reviewed push constant assembly and fragment output trims — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
b2ca8d4f367756c03541beba37daf2217752d24c(basemain, titleperf(agc): trim push constant assembly and fragment output lookups).repo_read.py. No build and no test run.Results
tests/execution/*.cppLastFragmentOutputs.cppmaps toagc_driver_last_fragment_outputs_tests<optional>,<random>,<map>,<algorithm>are presentagc_driver_push_constant_assemblyagc_driver_last_fragment_outputsand_offNegative control
Not run. The description reports 10 of 10 broken copies caught. I did not repeat this.
Findings
Blocking
None.
Non-blocking
None.
Sources
AssemblePushConstants: one bit per DWORD, onememcpyper stage, overlap check before the copy.CachedFragmentOutputs: last-key lookup on by default unlessAPS5_NO_LAST_FRAGMENT_OUTPUTSis set. The key is remembered only after a successful validation. The memo lock covers the find and the insert.Not verified
thread_locals on MinGW:HostThreadSlot.hppwas not read.agc_driver_last_fragment_outputsrun (switch on) is registered by the execution glob loop; I did not read the rest of that loop.LastFragmentOutputs.cpp(PixelPushOffset,DepthFastClearHarnessmembers) were not checked.tests/Graphics.cppis too large for the review folder. Only its changed hunks (indiff.patch) and its include lines were read.ARCHITECTURE.mdandENVIRONMENT.md: only the changed lines were read.files.jsonreviewedwere read through their changed hunks indiff.patch.Draw.cppwas also read at head, lines 1140–1245. No file was read in full.To get this to a good state
Nothing is required.