Skip to content

perf(agc): move per-draw thread-locals to TEB slots - #6615

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
Meh7an:perf/agc-draw-thread-locals-teb
Nov 5, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
Meh7an:perf/agc-draw-thread-locals-teb

Conversation

@Meh7an

@Meh7an Meh7an commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

With MinGW, every thread_local access goes through __emutls_get_address, a winpthreads key lookup. #6292 moved the draw path's locks and its hottest thread-locals to TEB slots (HostThreadSlot). This moves the ones left on the revalidation path, which every draw and dispatch that reuses cached resources takes:

  • ShaderResources::fastRevalidate's five scratch vectors and Revalidate's four (overlapping, refreshed, versions, regions) now go through ThreadScratch<T, Tag>(): the thread's object in a HostThreadSlot, created on first use and destroyed with the thread by ThreadOwned, as before;
  • Texture.cpp's refreshing exemption, read by StorageTexture::FlushPending and two other pending-store scans, is a HostThreadSlot<const StorageTexture*, RefreshingTag>;
  • Driver::sampledRead is a HostThreadSlot<bool, SampledReadTag>, through sampledRead() and setSampledRead().

On the S2 page of Sonic Origins Plus's main menu, the queue worker spent, per frame (APS5 sampler, 15 s):

  • __emutls_get_address: 1.24 to 1.51 in six runs without this change, 0.92 and 1.17 in two runs with it;
  • SampledReadScope: 0.15 to 0.24 without, 0.07 and 0.13 with;
  • fastRevalidate: 0.66 to 0.72 without, 0.56 and 0.63 with.

That is about 1% of the worker's frame (34 to 37 samples), so the frame times below move within run-to-run noise. Thread-locals elsewhere stay as they are.

Tested

Windows 11 (10.0.26300), WinLibs GCC 15.2.0 (UCRT), Release, NVIDIA GeForce RTX 2080 Ti, driver 617.14.

Metric Baseline This PR Change
frame_ms.p50 119.277 113.494 -4.8%
frame_ms.p90 133.323 128.928 -3.3%
mean_frame_ms 121.598 115.852 -4.7%
gpu_busy_ms_per_present 84.702 83.305 -1.6%
Driver.Packet (ms per frame) 119.228 113.745 -4.6%
Driver.Draw (ms per frame) 106.006 101.488 -4.3%

The four windows of the moving background I captured in that session read 112.3 to 119.3 ms at the median, so this pair's gap is mostly noise. The FPS shown in the title went from 9.58 to 9.74 (median of six readings), and a sampled pair taken an hour earlier went from 9.07 to 9.21.

Note: measuring base. These numbers come from my fork's dev, on main 0a56aaa. The code this change touches is the same on main 5d9dcc4.

Both carry these commits from my fork:

The branch sits on #6292's branch, rebased onto main c842491. In my fork ThreadScratch came with #6312's port. #6312 itself keeps its buffer in a thread_local slot so that it does not depend on #6292, so this PR adds ThreadScratch.

The comparison tool marks the window's first present as a configuration difference: the window opens 200 s into each run. Both summaries set trace_dropped, because the worker filled its event buffer at about 2,700 draws per frame. The phase totals above stay complete.

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 under Silent stubs in their library's technical debt file
  • 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): replace winpthreads locks and TLS on the draw path #6292
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 2080 Ti, driver 617.14, Windows 11
  • AI-assisted: yes

Traces and summary lines (baseline 4e46e7e, whose summary says a0dd42c; this change 99bf270, whose summary says 4e46e7e):
teb-traces.zip

The two summary lines, with tools/trace_digest.py for each trace:

Baseline (summary commit a0dd42c)

seconds 200:15 from present 2708: 124 presents, frame p50 119.3 / p90 133.3 / p99 151.6 / max 172.5 ms, GPU busy 84.7 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit a0dd42c (dirty), dropped: yes

{"commit":"a0dd42cf9b44","dirty":true,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"200:15"},"gpu":"NVIDIA GeForce RTX 2080 Ti","driver":"NVIDIA 617.14","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"seconds 200:15","first_present":2708,"ms":15078.201},"presents":124,"frame_ms":{"p50":119.277,"p90":133.323,"p99":151.553,"max":172.525},"gpu_busy_ms_per_present":84.702,"worker_busy_pct":{"queue worker 0x0":98.081},"top_phases_ms_per_frame":{"Driver.Packet":119.228,"Driver.Packet.draw":107.057,"Driver.Draw":106.006,"Driver.Draw.draw_and_resource_release":50.358,"Graphics.Draw":49.2,"Graphics.Draw.draw_and_resource_release":40.064,"Driver.Draw.shader_compile_and_link":37.71,"Driver.Present":32.538},"trace_dropped":true,"trace":"aps5-trace-a0dd42cf9b44-40532.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 2708: 172.5 ms at 0 ms: Driver.Packet (queue worker 0x0) 159.6, Driver.Packet.draw (queue worker 0x0) 154.8, Driver.Draw (queue worker 0x0) 153.3, batch (gpu) 117.0
  • present 2743: 151.6 ms at 4268 ms: batch (gpu) 88.1, Driver.Present (presenter) 30.9, Driver.Present.render_fence_wait (presenter) 30.2, Vulkan.Retire (presenter) 30.2
  • present 2730: 146.1 ms at 2685 ms: Driver.Packet (queue worker 0x0) 136.3, Driver.Packet.draw (queue worker 0x0) 130.9, Driver.Draw (queue worker 0x0) 129.8, batch (gpu) 89.4
  • present 2789: 142.1 ms at 9922 ms: batch (gpu) 85.1, Driver.Present (presenter) 29.5, Driver.Present.render_fence_wait (presenter) 29.0, Vulkan.Retire (presenter) 29.0
  • present 2802: 140.5 ms at 11540 ms: batch (gpu) 87.0, Driver.Present (presenter) 34.6, Driver.Present.render_fence_wait (presenter) 34.1, Vulkan.Retire (presenter) 34.0

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 21.2 (17 %) 0.1 (0 %) 100.3 38.1 Driver.Packet 21.3, Driver.Completion 0.0
presenter 0.5 (0 %) 32.1 (26 %) 89.1 0.1 Driver.Present 32.5
gpu 84.7 (70 %) 0.0 (0 %) 36.9 0.0 batch 84.7

Largest slices (ms per frame, inclusive, all threads): batch 84.7, Driver.Present 32.5, Driver.Present.render_fence_wait 32.0, Vulkan.Retire 32.0, Vulkan.Retire.wait 32.0, Driver.Packet 21.3, Driver.Packet.draw 20.4, Driver.Draw 20.2, Driver.Draw.draw_and_resource_release 5.0, Graphics.Draw 4.9

Longest waits

  • Driver.Present.render_fence_wait (presenter) 38.0 ms at 5652 ms, present 2754
  • Driver.Present.render_fence_wait (presenter) 37.7 ms at 10328 ms, present 2792
  • Driver.Present.render_fence_wait (presenter) 37.0 ms at 2329 ms, present 2727
  • Driver.Present.render_fence_wait (presenter) 36.9 ms at 5416 ms, present 2752
  • Driver.Present.render_fence_wait (presenter) 36.3 ms at 5775 ms, present 2755
  • Driver.Present.render_fence_wait (presenter) 36.1 ms at 6255 ms, present 2759
  • Driver.Present.render_fence_wait (presenter) 36.1 ms at 5295 ms, present 2751
  • Driver.Present.render_fence_wait (presenter) 35.8 ms at 10451 ms, present 2793
  • Driver.Present.render_fence_wait (presenter) 35.6 ms at 5893 ms, present 2756
  • Driver.Present.render_fence_wait (presenter) 35.6 ms at 12254 ms, present 2808
This change (summary commit 4e46e7e)

seconds 200:15 from present 3226: 130 presents, frame p50 113.5 / p90 128.9 / p99 143.9 / max 144.3 ms, GPU busy 83.3 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit 4e46e7e (dirty), dropped: yes

{"commit":"4e46e7ebac25","dirty":true,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"200:15"},"gpu":"NVIDIA GeForce RTX 2080 Ti","driver":"NVIDIA 617.14","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"seconds 200:15","first_present":3226,"ms":15060.793},"presents":130,"frame_ms":{"p50":113.494,"p90":128.928,"p99":143.934,"max":144.322},"gpu_busy_ms_per_present":83.305,"worker_busy_pct":{"queue worker 0x0":98.211},"top_phases_ms_per_frame":{"Driver.Packet":113.745,"Driver.Packet.draw":102.51,"Driver.Draw":101.488,"Driver.Draw.draw_and_resource_release":49.35,"Graphics.Draw":48.323,"Graphics.Draw.draw_and_resource_release":39.351,"Driver.Draw.shader_compile_and_link":35.574,"Driver.Present":32.978},"trace_dropped":true,"trace":"aps5-trace-4e46e7ebac25-37480.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 3257: 144.3 ms at 3533 ms: batch (gpu) 80.9, Driver.Present (presenter) 32.7, Driver.Present.render_fence_wait (presenter) 32.2, Vulkan.Retire (presenter) 32.2
  • present 3331: 143.9 ms at 12191 ms: batch (gpu) 84.7, Driver.Present (presenter) 35.6, Driver.Present.render_fence_wait (presenter) 35.1, Vulkan.Retire (presenter) 35.1
  • present 3341: 143.7 ms at 13365 ms: batch (gpu) 81.6, Driver.Present (presenter) 28.6, Driver.Present.render_fence_wait (presenter) 28.1, Vulkan.Retire (presenter) 28.1
  • present 3258: 134.2 ms at 3678 ms: batch (gpu) 84.2, Driver.Present (presenter) 34.4, Driver.Present.render_fence_wait (presenter) 33.9, Vulkan.Retire (presenter) 33.9
  • present 3264: 131.6 ms at 4387 ms: batch (gpu) 85.5, Driver.Present (presenter) 34.5, Driver.Present.render_fence_wait (presenter) 34.0, Vulkan.Retire (presenter) 34.0

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 19.3 (17 %) 0.1 (0 %) 96.5 37.8 Driver.Packet 19.4, Driver.Completion 0.0
presenter 0.5 (0 %) 32.5 (28 %) 82.9 0.1 Driver.Present 33.0
gpu 83.2 (72 %) 0.0 (0 %) 32.6 0.0 batch 83.2

Largest slices (ms per frame, inclusive, all threads): batch 83.2, Driver.Present 33.0, Driver.Present.render_fence_wait 32.5, Vulkan.Retire 32.5, Vulkan.Retire.wait 32.5, Driver.Packet 19.4, Driver.Packet.draw 18.6, Driver.Draw 18.5, Driver.Draw.draw_and_resource_release 4.1, Graphics.Draw 4.0

Longest waits

  • Driver.Present.render_fence_wait (presenter) 36.3 ms at 4855 ms, present 3268
  • Driver.Present.render_fence_wait (presenter) 35.7 ms at 948 ms, present 3234
  • Driver.Present.render_fence_wait (presenter) 35.6 ms at 10798 ms, present 3319
  • Driver.Present.render_fence_wait (presenter) 35.5 ms at 6303 ms, present 3280
  • Driver.Present.render_fence_wait (presenter) 35.4 ms at 5577 ms, present 3274
  • Driver.Present.render_fence_wait (presenter) 35.4 ms at 12569 ms, present 3334
  • Driver.Present.render_fence_wait (presenter) 35.3 ms at 11138 ms, present 3322
  • Driver.Present.render_fence_wait (presenter) 35.2 ms at 2506 ms, present 3248
  • Driver.Present.render_fence_wait (presenter) 35.2 ms at 5953 ms, present 3277
  • Driver.Present.render_fence_wait (presenter) 35.2 ms at 14174 ms, present 3348

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 13251 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L1861

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1896 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WriteEvidence.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6187 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6194 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6223 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6412 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6987 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6989 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6995 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7085 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7275 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7604 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7689 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8484 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8707 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9012 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9318 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9335 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 9592 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9884 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9897 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9898 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WriteEvidence.cpp
PR 10049 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10256 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10359 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10743 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10894 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 11435 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 11436 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11485 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11901 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12565 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 12567 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 12575 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12746 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 12921 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 12944 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 13646 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13796 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13963 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 14032 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 14261 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 14262 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 14302 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 14311 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 14621 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 14943 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 14944 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15059 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main (both commits, authorship unchanged). The conflicts were the lock/TLS replacements landing on structures main has since extended: in Driver.hpp and VulkanDevice.cpp the PR's AgcDriver::Mutex swap now applies to main's fuller field sets (draw relocations, journal replay, pipeline counters), and in Pipeline.cpp both includes are kept with the mutex swap plus the PR's scratchKey field.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/6615
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 5c61f9f1d.

@Meh7an
Meh7an force-pushed the perf/agc-draw-thread-locals-teb branch 2 times, most recently from ed20b75 to 2f4643e Compare October 16, 2026 19:55
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 16, 2026
@parl0v

parl0v commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Data point from a CPU-bound scene on Windows: RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, MinGW GCC Release. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input, 200 s rows, APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1; main bc3c0fc vs main + this PR, interleaved with five other PRs in one batch, two rounds. FPS is the mean of the last 10 [present] windows, GPU busy and idle gaps per frame over the last 8. This scene is CPU-bound on this machine (45-47 ms of idle gaps per frame).

libs FPS GPU busy idle gaps
main 6.70 / 6.60 105 / 106 ms 45 / 46 ms
+ this PR (2f4643e) 6.68 / 6.56 (-0.5 %) 105 / 106 ms 45 / 46 ms

Within the run-to-run spread (about ±1.5 % here), no regression, 0 fatal.

AI-assisted: yes (Claude Code)

@moong15

moong15 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Evidence from Stellar Blade on Windows (MinGW build): this stack gives about +7% presents in gameplay over two pairs.

What was measured. This PR's stack (#6615 including #6292; #6522 was already in our tree) ported onto a downstream perf branch: origin/main 4ffb0cd plus local AGC performance changes. The port keeps the PR's mechanism (atomic mutexes, explicit GPU-lock recursion, TEB slots) adapted to our tree. Base is the same tree without the port. It is not a clean main-vs-PR comparison.

  • Base ab1a4186593e, port 1b89c36184a1 (both clean builds, dirty: false)
  • Windows 11 10.0.26300, Ryzen 7 9800X3D, Radeon RX 9070 XT, AMD driver 26.8.1 (LLPC), 3840x2160
  • Same env in every run: APS5_FLAT_3D_COLOR_TARGET=1 APS5_CONTINUE_AFTER_FLIP_FAILURE=1 APS5_PREBUILD_THREADS=16 APS5_PIPELINE_DMA=1 APS5_HOST_IMPORT_MIB=16384 APS5_TRACE_SECONDS=0:150 APS5_TRACE_SUMMARY_EVERY=10 APS5_TRACE_EVENTS=4194304, warm shader cache, no APS5_PROFILE_*
  • The same scripted Cross presses in every run (APS5_PAD_INPUT_FILE, every 5 s from 8 s). Window: 49-150 s after launch, which is in-world gameplay after the first load.
  • Whole traces: trace_dropped is false in every window.

Before the port, a queue-0 sample profile of steady gameplay had about 4.9% of queue-0 time in winpthreads lock and TLS calls (__emutls_get_address 2.1% including its spin lock 1.5%, pthread_mutex_lock/timedlock 1.9%, unlock 0.5%, rwlock 0.4%).

Run Build Presents (49-150 s) fps p50 ms p90 ms p99 ms
1 base 1022 10.12 71.7 151.8 584.3
2 port 1068 10.57 64.9 150.8 491.0
3 base 1029 10.19 70.5 156.1 539.6
4 port 1127 11.16 61.6 148.2 422.0
  • Pair 1 (runs 1/2): +4.5%. Pair 2 (runs 3/4): +9.5%. p50 -9% and -13%, p99 -16% and -22%.
  • Peak commit was 0.75-1.2 GB higher with the port (30.9/31.2 GB vs 30.2/30.0 GB).
  • Queue 0 stays about 99% busy in both builds, so the gain is CPU time removed from the queue-0 path.

Traces and summary files are available on request.

trace_digest, run 1 (base)

1912 frames over 149995.1 ms (no summary line found)

Slowest frames (largest slices inside each, inclusive)

  • present 885: 10814.9 ms at 27970 ms: Driver.WorkerWait (queue worker 0x20) 7657.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 7657.6, Driver.WorkerWait (queue worker 0x0) 6350.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 6350.8
  • present 0: 3741.2 ms at 0 ms: Driver.Packet (queue worker 0x0) 40.5, Driver.Packet.device_lock (queue worker 0x0) 26.6, Driver.Commit.draw (draw committer) 24.4, GpuMutex.hold.draw (draw committer) 24.4
  • present 887: 3592.2 ms at 41902 ms: Driver.Packet (queue worker 0x0) 3438.3, Driver.Packet (queue worker 0x20) 2772.4, Driver.Packet.memory_wait (queue worker 0x20) 2709.9, Driver.Commit.draw (draw committer) 2409.5
  • present 886: 3116.5 ms at 38785 ms: Driver.Packet (queue worker 0x0) 3089.9, Driver.WorkerWait (queue worker 0x20) 2160.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 2160.1, Driver.Commit.draw (draw committer) 2093.8
  • present 888: 2582.3 ms at 45494 ms: Driver.Packet (queue worker 0x20) 2582.0, Driver.Packet.memory_wait (queue worker 0x20) 2542.2, Driver.Packet (queue worker 0x0) 2516.9, Driver.Commit.draw (draw committer) 2021.4

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.2 (0 %) 78.3 0.0
queue worker 0x0 66.5 (85 %) 6.1 (8 %) 5.9 23.8 Driver.Packet 67.1, Driver.EndSubmission 0.2
draw committer 29.0 (37 %) 0.9 (1 %) 48.5 7.0 Driver.Commit.draw 27.6, Driver.Commit.other 2.3
presenter 0.5 (1 %) 1.4 (2 %) 76.5 0.1 VideoOut.Flip 2.0, Driver.Present 0.0
title 0.1 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.Register 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.Register 0.0
queue worker 0x20 1.3 (2 %) 74.1 (94 %) 3.0 0.1 Driver.Packet 67.7, Driver.EndSubmission 0.2
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.4 0.0 Shader.Register 0.0
gpu 35.4 (45 %) 0.0 (0 %) 43.0 0.0 batch 35.4

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 134.8, Driver.Packet.memory_wait 65.6, batch 35.4, Driver.Packet.dispatch 30.0, Graphics.Draw 27.7, Driver.Commit.draw 27.6, GpuMutex.hold.draw 27.3, Graphics.Draw.draw_and_resource_release 23.4, Driver.Dispatch 20.9, Driver.Packet.draw 15.6

Longest waits

  • Driver.WorkerWait (queue worker 0x20) 6573.5 ms at 27954 ms, present 884
  • Driver.WorkerWait (queue worker 0x0) 5729.2 ms at 27970 ms, present 885
  • Driver.WorkerWait (queue worker 0x20) 2909.6 ms at 39741 ms, present 886
  • Driver.Packet.memory_wait (queue worker 0x20) 2816.9 ms at 44682 ms, present 887
  • Driver.Packet.memory_wait (queue worker 0x20) 1951.9 ms at 37725 ms, present 885
  • Driver.Packet.memory_wait (queue worker 0x20) 1897.9 ms at 42651 ms, present 887
  • Driver.Packet.memory_wait (queue worker 0x20) 1793.1 ms at 35878 ms, present 885
  • Driver.WorkerWait (queue worker 0x20) 1511.1 ms at 88900 ms, present 1163
  • Driver.Packet.memory_wait (queue worker 0x20) 1291.3 ms at 69726 ms, present 985
  • Driver.WorkerWait (queue worker 0x20) 1100.8 ms at 34777 ms, present 885

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

  • batch 27248: 146.6 ms at 89922 ms, present 1164: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 1036.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 1036.5, Driver.Packet (queue worker 0x0) 25.3, Driver.Packet.dispatch (queue worker 0x0) 15.6
  • batch 236: 88.5 ms at 5790 ms, present 93: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 9.3, Driver.Packet.dispatch (queue worker 0x0) 8.9, Driver.Dispatch (queue worker 0x0) 8.9, Vulkan.Dispatch (queue worker 0x0) 4.0
  • batch 237: 83.9 ms at 5879 ms, present 93: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 13.2, Driver.Packet.dispatch (queue worker 0x0) 13.2, Driver.Dispatch (queue worker 0x0) 10.3, Vulkan.Dispatch (queue worker 0x0) 9.1
  • batch 11845: 57.3 ms at 28148 ms, present 885: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 5729.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 5729.2, Recorder.Submit (queue worker 0x0) 0.0, Resources.Prepare (queue worker 0x0) 0.0
  • batch 27395: 50.3 ms at 91657 ms, present 1169: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 892.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 892.9, Driver.Packet (queue worker 0x0) 29.6, Driver.Packet.draw (queue worker 0x0) 5.7
trace_digest, run 2 (port)

2103 frames over 149914.4 ms (no summary line found)

Slowest frames (largest slices inside each, inclusive)

  • present 1030: 10892.9 ms at 28234 ms: Driver.WorkerWait (queue worker 0x20) 7382.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 7382.8, Driver.WorkerWait (queue worker 0x0) 6083.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 6083.4
  • present 1032: 4227.8 ms at 41747 ms: Driver.Packet (queue worker 0x0) 4068.3, Driver.Commit.draw (draw committer) 2694.8, GpuMutex.hold.draw (draw committer) 2688.7, Graphics.Draw (draw committer) 2685.4
  • present 0: 3485.1 ms at 0 ms: Driver.Packet (queue worker 0x0) 39.3, Driver.Packet.device_lock (queue worker 0x0) 25.5, Driver.Commit.draw (draw committer) 23.5, GpuMutex.hold.draw (draw committer) 23.5
  • present 1031: 2620.1 ms at 39127 ms: Driver.Packet (queue worker 0x0) 2581.6, Driver.Commit.draw (draw committer) 1759.1, GpuMutex.hold.draw (draw committer) 1757.7, Graphics.Draw (draw committer) 1755.5
  • present 1033: 1937.7 ms at 45975 ms: Driver.Packet (queue worker 0x20) 1937.6, Driver.Packet (queue worker 0x0) 1907.6, Driver.Packet.memory_wait (queue worker 0x20) 1871.2, Driver.Commit.draw (draw committer) 1467.6

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0
queue worker 0x0 59.6 (84 %) 6.5 (9 %) 5.2 21.8 Driver.Packet 61.3, Driver.EndSubmission 0.2
draw committer 25.5 (36 %) 0.8 (1 %) 45.1 6.7 Driver.Commit.draw 24.3, Driver.Commit.other 2.0
presenter 0.5 (1 %) 0.9 (1 %) 69.9 0.1 VideoOut.Flip 1.4, Driver.Present 0.0
title 0.2 (0 %) 0.0 (0 %) 71.1 0.0 Shader.ResolveAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0
title 0.1 (0 %) 0.0 (0 %) 71.2 0.0 Shader.ResolveAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 71.2 0.0 Shader.ResolveAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0
queue worker 0x20 2.2 (3 %) 66.5 (93 %) 2.5 0.1 Driver.Packet 61.9, Driver.EndSubmission 0.2
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 71.3 0.0 Shader.Register 0.0
gpu 33.3 (47 %) 0.0 (0 %) 38.0 0.0 batch 33.3

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 123.2, Driver.Packet.memory_wait 59.8, batch 33.3, Driver.Packet.dispatch 26.8, Graphics.Draw 24.4, Driver.Commit.draw 24.3, GpuMutex.hold.draw 24.1, Graphics.Draw.draw_and_resource_release 20.8, Driver.Dispatch 18.2, Driver.Packet.draw 14.6

Longest waits

  • Driver.WorkerWait (queue worker 0x20) 6324.5 ms at 28218 ms, present 1029
  • Driver.WorkerWait (queue worker 0x0) 5481.4 ms at 28235 ms, present 1030
  • Driver.WorkerWait (queue worker 0x20) 2915.4 ms at 40347 ms, present 1031
  • Driver.Packet.memory_wait (queue worker 0x20) 2619.4 ms at 37648 ms, present 1030
  • Driver.Packet.memory_wait (queue worker 0x20) 2251.8 ms at 45181 ms, present 1032
  • Driver.Packet.memory_wait (queue worker 0x20) 1732.6 ms at 35845 ms, present 1030
  • Driver.Packet.memory_wait (queue worker 0x20) 1712.8 ms at 43263 ms, present 1032
  • Driver.WorkerWait (queue worker 0x20) 1571.6 ms at 89025 ms, present 1383
  • Driver.WorkerWait (queue worker 0x20) 1075.0 ms at 34770 ms, present 1030
  • Driver.WorkerWait (queue worker 0x0) 1014.4 ms at 89581 ms, present 1384

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

  • batch 29483: 146.7 ms at 90172 ms, present 1384: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 1014.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 1014.4, Driver.Packet (queue worker 0x0) 20.1, Driver.Packet.dispatch (queue worker 0x0) 6.2
  • batch 186: 88.6 ms at 5276 ms, present 76: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 7.5, Driver.Packet.dispatch (queue worker 0x0) 7.5, Driver.Dispatch (queue worker 0x0) 5.4, Vulkan.Dispatch (queue worker 0x0) 4.5
  • batch 187: 85.6 ms at 5375 ms, present 76: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 94.8, Driver.Packet.dispatch (queue worker 0x0) 94.7, Driver.Dispatch (queue worker 0x0) 94.6, Vulkan.Dispatch (queue worker 0x0) 94.2
  • batch 12699: 54.2 ms at 28404 ms, present 1030: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 5481.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 5481.4, Recorder.Submit (queue worker 0x0) 0.1, Resources.Prepare (queue worker 0x0) 0.0
  • batch 29641: 50.3 ms at 91956 ms, present 1389: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 880.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 880.2, Driver.Packet (queue worker 0x0) 35.4, Driver.Packet.dispatch (queue worker 0x0) 14.6
trace_digest, run 3 (base)

1888 frames over 149975.6 ms (no summary line found)

Slowest frames (largest slices inside each, inclusive)

  • present 853: 10448.1 ms at 27936 ms: Driver.WorkerWait (queue worker 0x20) 7650.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 7650.9, Driver.WorkerWait (queue worker 0x0) 6302.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 6302.7
  • present 0: 3701.7 ms at 0 ms: Driver.Packet (queue worker 0x0) 42.1, Driver.Packet.device_lock (queue worker 0x0) 28.5, Driver.Commit.draw (draw committer) 26.6, GpuMutex.hold.draw (draw committer) 26.6
  • present 855: 2788.3 ms at 40917 ms: Driver.Packet (queue worker 0x0) 2661.8, Driver.Commit.draw (draw committer) 2027.3, GpuMutex.hold.draw (draw committer) 2025.1, Graphics.Draw (draw committer) 2022.6
  • present 854: 2532.7 ms at 38384 ms: Driver.Packet (queue worker 0x0) 2514.5, Driver.WorkerWait (queue worker 0x20) 1965.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1965.2, Driver.Commit.draw (draw committer) 1688.6
  • present 857: 2403.1 ms at 45872 ms: Driver.Packet (queue worker 0x20) 2399.5, Driver.Packet (queue worker 0x0) 2388.6, Driver.Packet.memory_wait (queue worker 0x20) 2368.5, Driver.Commit.draw (draw committer) 1534.1

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.2 (0 %) 79.2 0.0
queue worker 0x0 66.8 (84 %) 6.9 (9 %) 5.8 23.4 Driver.Packet 68.1, Driver.EndSubmission 0.2
draw committer 28.5 (36 %) 0.9 (1 %) 50.0 7.1 Driver.Commit.draw 27.2, Driver.Commit.other 2.2
presenter 0.5 (1 %) 1.0 (1 %) 77.9 0.1 VideoOut.Flip 1.5, Driver.Present 0.0
title 0.1 (0 %) 0.0 (0 %) 79.3 0.0 Shader.ResolveAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.Register 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.Register 0.0
queue worker 0x20 2.2 (3 %) 74.3 (93 %) 3.0 0.1 Driver.Packet 68.6, Driver.EndSubmission 0.2
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 79.4 0.0 Shader.ResolveGraphicsStagesAbi 0.0
gpu 35.6 (45 %) 0.0 (0 %) 43.8 0.0 batch 35.6

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 136.7, Driver.Packet.memory_wait 66.7, batch 35.6, Driver.Packet.dispatch 30.7, Graphics.Draw 27.2, Driver.Commit.draw 27.2, GpuMutex.hold.draw 26.9, Graphics.Draw.draw_and_resource_release 23.5, Driver.Dispatch 21.6, Driver.Packet.draw 15.2

Longest waits

  • Driver.WorkerWait (queue worker 0x20) 6539.4 ms at 27918 ms, present 852
  • Driver.WorkerWait (queue worker 0x0) 5658.0 ms at 27936 ms, present 853
  • Driver.WorkerWait (queue worker 0x20) 2651.8 ms at 38952 ms, present 854
  • Driver.Packet.memory_wait (queue worker 0x20) 1869.1 ms at 44860 ms, present 856
  • Driver.Packet.memory_wait (queue worker 0x20) 1851.8 ms at 46763 ms, present 857
  • Driver.Packet.memory_wait (queue worker 0x20) 1623.7 ms at 35844 ms, present 853
  • Driver.Packet.memory_wait (queue worker 0x20) 1609.1 ms at 43161 ms, present 855
  • Driver.WorkerWait (queue worker 0x20) 1581.6 ms at 88539 ms, present 1183
  • Driver.Packet.memory_wait (queue worker 0x20) 1432.1 ms at 37510 ms, present 853
  • Driver.Packet.memory_wait (queue worker 0x20) 1176.2 ms at 95968 ms, present 1219

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

  • batch 27916: 144.7 ms at 89614 ms, present 1184: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 1067.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 1067.4, Driver.Packet (queue worker 0x0) 49.4, Driver.Packet.dispatch (queue worker 0x0) 34.8
  • batch 210: 89.1 ms at 5693 ms, present 82: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.5, Driver.Packet.dispatch (queue worker 0x0) 11.5, Driver.Dispatch (queue worker 0x0) 6.5, Vulkan.Dispatch (queue worker 0x0) 5.1
  • batch 211: 84.4 ms at 5782 ms, present 82: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 7.7, Driver.Packet.dispatch (queue worker 0x0) 7.7, Driver.Dispatch (queue worker 0x0) 7.3, Vulkan.Dispatch (queue worker 0x0) 5.1
  • batch 11428: 55.9 ms at 28106 ms, present 853: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 5658.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 5658.0, Recorder.Submit (queue worker 0x0) 0.1, Resources.Prepare (queue worker 0x0) 0.0
  • batch 28048: 48.1 ms at 91438 ms, present 1188: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 827.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 827.9, Driver.Packet (queue worker 0x0) 23.7, Driver.Packet.dispatch (queue worker 0x0) 1.0
trace_digest, run 4 (port)

2059 frames over 149945.3 ms (no summary line found)

Slowest frames (largest slices inside each, inclusive)

  • present 927: 11148.0 ms at 27932 ms: Driver.WorkerWait (queue worker 0x20) 7572.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 7572.6, Driver.WorkerWait (queue worker 0x0) 6250.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 6250.5
  • present 929: 4298.7 ms at 41770 ms: Driver.Packet (queue worker 0x0) 4141.2, Driver.Commit.draw (draw committer) 3074.7, GpuMutex.hold.draw (draw committer) 3067.9, Graphics.Draw (draw committer) 3063.8
  • present 0: 3692.8 ms at 0 ms: Driver.Packet (queue worker 0x0) 42.4, Driver.Packet.device_lock (queue worker 0x0) 28.5, Driver.Commit.draw (draw committer) 26.4, GpuMutex.hold.draw (draw committer) 26.4
  • present 928: 2690.2 ms at 39080 ms: Driver.Packet (queue worker 0x0) 2635.9, Driver.Commit.draw (draw committer) 1718.0, GpuMutex.hold.draw (draw committer) 1710.6, Graphics.Draw (draw committer) 1707.6
  • present 930: 1848.5 ms at 46069 ms: Driver.Packet (queue worker 0x20) 1848.4, Driver.Packet (queue worker 0x0) 1819.3, Driver.Packet.memory_wait (queue worker 0x20) 1802.6, Driver.Commit.draw (draw committer) 1430.9

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0
queue worker 0x0 60.5 (83 %) 6.9 (9 %) 5.5 23.1 Driver.Packet 62.0, Driver.EndSubmission 0.2
draw committer 26.9 (37 %) 0.8 (1 %) 45.2 6.9 Driver.Commit.draw 25.8, Driver.Commit.other 1.8
presenter 0.5 (1 %) 1.2 (2 %) 71.2 0.1 VideoOut.Flip 1.6, Driver.Present 0.0
title 0.1 (0 %) 0.0 (0 %) 72.7 0.0 Shader.ResolveAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.Register 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.Register 0.0
queue worker 0x20 2.1 (3 %) 67.9 (93 %) 2.8 0.1 Driver.Packet 62.8, Driver.EndSubmission 0.2
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 72.8 0.0 Shader.ResolveGraphicsStagesAbi 0.0
gpu 35.0 (48 %) 0.0 (0 %) 37.8 0.0 batch 35.0

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 124.8, Driver.Packet.memory_wait 60.8, batch 35.0, Driver.Packet.dispatch 26.6, Graphics.Draw 25.9, Driver.Commit.draw 25.8, GpuMutex.hold.draw 25.6, Graphics.Draw.draw_and_resource_release 22.1, Driver.Dispatch 17.9, Driver.Packet.draw 14.8

Longest waits

  • Driver.WorkerWait (queue worker 0x20) 6480.1 ms at 27915 ms, present 926
  • Driver.WorkerWait (queue worker 0x0) 5630.7 ms at 27932 ms, present 927
  • Driver.WorkerWait (queue worker 0x20) 3046.3 ms at 40306 ms, present 928
  • Driver.Packet.memory_wait (queue worker 0x20) 2692.4 ms at 37583 ms, present 927
  • Driver.Packet.memory_wait (queue worker 0x20) 2330.1 ms at 45116 ms, present 929
  • Driver.Packet.memory_wait (queue worker 0x20) 1817.9 ms at 35763 ms, present 927
  • Driver.WorkerWait (queue worker 0x20) 1790.7 ms at 88279 ms, present 1253
  • Driver.Packet.memory_wait (queue worker 0x20) 1633.8 ms at 43353 ms, present 929
  • Driver.WorkerWait (queue worker 0x0) 1596.0 ms at 88464 ms, present 1254
  • Driver.WorkerWait (queue worker 0x20) 1109.8 ms at 34653 ms, present 927

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

  • batch 28086: 144.1 ms at 88943 ms, present 1254: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 1596.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 1596.0, Driver.Packet (queue worker 0x0) 30.4, Driver.Packet.dispatch (queue worker 0x0) 2.7
  • batch 212: 88.8 ms at 5656 ms, present 84: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.3, Driver.Packet.dispatch (queue worker 0x0) 11.3, Driver.Dispatch (queue worker 0x0) 11.3, Driver.Dispatch.materialize (queue worker 0x0) 7.5
  • batch 213: 84.3 ms at 5744 ms, present 84: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.8, Driver.Packet.dispatch (queue worker 0x0) 12.8, Driver.Dispatch (queue worker 0x0) 12.8, Driver.Dispatch.materialize (queue worker 0x0) 6.3
  • batch 11798: 52.9 ms at 28125 ms, present 927: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 5630.7, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 5630.7, Resources.Prepare (queue worker 0x0) 0.2, Recorder.Submit (queue worker 0x0) 0.0
  • batch 28241: 46.9 ms at 91350 ms, present 1259: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 1002.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 1002.8, Driver.Packet (queue worker 0x0) 39.6, Driver.Packet.dispatch (queue worker 0x0) 11.1

moong15 added a commit to moong15/AnyPS5 that referenced this pull request Oct 19, 2026
Ports boykopovar#6292 and boykopovar#6615 (boykopovar#6522 is already present). Draw-path mutexes and
the GPU-lock gate become atomic locks with explicit recursion, and
per-draw thread-locals move to native TLS slots (TEB slots on Windows)
instead of emutls. The same conversion also covers the newer sb5 paths:
guest allocation registry, trace thread binding, own-stack checks,
collect counters, recorder sync attribution, held-read scratch, packet
profile, draw keys, supplied shader-memory blocks and the changed-block
scratch. There is no runtime switch; compare builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneandonlydean oneandonlydean self-assigned this Oct 20, 2026
@Meh7an
Meh7an force-pushed the perf/agc-draw-thread-locals-teb branch from 2f4643e to 8310d3d Compare October 20, 2026 12:15
@github-actions

Copy link
Copy Markdown

This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

@tibzejoker

Copy link
Copy Markdown
Contributor

Two notes from GTA V (PPSA04264) on Windows (RTX 4090, i9-13900K, GCC 15.2). Numbers are from our older POC base (gtav-next11, Oct 16).

  • On current main (eb8dcfe), StorageTexture::FlushPending starts with DrawPipeline::HeldReads, and that calls std::getenv("APS5_NO_QUEUED_DRAW_READ_ORDER") on every call. UCRT's getenv takes the CRT lock and scans the environment. In our POC, getenv calls in the shader cache key, made for every draw stage, were 45 % of a draw preparation (most were our own POC switches). Reading them once gave +10 % FPS. We have not measured how often HeldReads runs on main. A static const bool would fix it, maybe as its own PR.
  • On the review point about future thread_locals: we replaced emutls for the whole module instead. libSceAgcDriver defines its own __emutls_get_address: one TLS slot, a per-thread array read from the TEB, and objects outside the module go to libgcc. Every thread_local gets the fast path, with no call-site change and no convention rule to enforce. Two things to get right: -Wl,--exclude-symbols,__emutls_get_address (when it was exported, our NID patcher dropped it and libSceVideoOut had bound to it), and per-thread storage that outlives the thread_local destructors. Details are on perf(agc): replace winpthreads locks and TLS on the draw path #6292. This PR adds 11 TLS slots (9 ThreadScratch tags + 2).

We measured with APS5_SAMPLE_WORKER and addr2line -i on a -O3 -g build. I can run GTA's open world on your head (#6292 alone vs #6292 + this PR, same session) to get the frame-rate pair the review asks for.

AI-assisted: yes (Claude Code)

@Meh7an
Meh7an force-pushed the perf/agc-draw-thread-locals-teb branch from 93ae204 to 21a8583 Compare October 23, 2026 08:12
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 23, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Meh7an #7919 was merged into main a short while after your rebase, and it conflicts with this stack in core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp. The conflict comes from the #6292 commit (7074425c6d), so #6292 and this PR both need the same fix.

#7919 moves the SnapshotCopies struct out of GuestBufferMemory.cpp into a new header, core/libs/prx/libSceAgcDriver/Graphics/include/SnapshotCopies.hpp (as Detail::SnapshotCopies), and leaves using SnapshotCopies = Detail::SnapshotCopies; in the .cpp. Your commit changes that struct's std::mutex mutex; to AgcDriver::Mutex mutex;, like the other caches in the file.

When you rebase, could you:

  • take main's side of the conflict in GuestBufferMemory.cpp (the using line, not the old struct), and
  • make your mutex change in the new header instead: in SnapshotCopies.hpp, replace std::mutex mutex; with AgcDriver::Mutex mutex; and add #include "prx/libSceAgcDriver/Execution/include/Mutex.hpp".

Git will not flag the header, so taking either side of the conflict alone builds fine, but it leaves the snapshot cache on std::mutex. I tried this resolution on top of current main: GuestBufferMemory.cpp and tests/SnapshotCopyFailure.cpp both compile. Your own commit here is otherwise unchanged by the rebase.

After the push CI runs again on the new head, and I will do a short delta review.

@Meh7an
Meh7an force-pushed the perf/agc-draw-thread-locals-teb branch from 21a8583 to 07bb9f6 Compare October 23, 2026 08:54
@Meh7an

Meh7an commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Thanks, done as you suggested. Both PRs are rebased onto main 72fe76f:

  • perf(agc): replace winpthreads locks and TLS on the draw path #6292 is now 2659ec3.
    • GuestBufferMemory.cpp keeps main's using SnapshotCopies = Detail::SnapshotCopies;.
    • SnapshotCopies.hpp has AgcDriver::Mutex mutex; and includes prx/libSceAgcDriver/Execution/include/Mutex.hpp.
    • Both lock sites use a deduced std::lock_guard, so nothing else changes.
  • This PR is now 07bb9f6, restacked on it. Its own commit is unchanged.
  • Local Windows build: the full suite (1982 tests) passes on both heads except agc_driver_sample_order, agc_driver_sample_order_grid_reference and agc_driver_sample_order_recipe_depth_locations. Those three fail the same way on plain main 6646483 on this machine (RTX 2080 Ti).
  • tools/check_conventions.py --base upstream/main passes on both.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@QDarkRex

Copy link
Copy Markdown
Contributor

Windows / AMD data from ASTRO BOT's Crash Site hub, with the APS5 samplers on the queue 0 worker and on the draw committer. On this title the change makes no measurable difference, because its thread-local accesses are spread over call sites this PR does not touch.

  • Host: Windows 11 (26300), Ryzen 7 5700X, 32 GB RAM, Radeon RX 9060 XT, AMD driver 26.10.1, WinLibs GCC 15.2.0 r7, Release.
  • Builds: this PR's head 07bb9f6 against its parent 2659ec3 (perf(agc): replace winpthreads locks and TLS on the draw path #6292's head). The A/B therefore isolates this PR's own commit.
  • Runs: ASTRO BOT PPSA21564 01.007.000, -lvl hub_crashsite, no input, 300 s each. One warm-up per arm, then two rounds in the order A B / B A. APS5_HOST_IMPORT_MIB=14336, APS5_TRACE_SUMMARY_EVERY=10, APS5_SAMPLE_WORKER and APS5_SAMPLE_COMMITTER were set in every run. Frame figures come from the 10 s windows from 120 s on. Sampler shares are inclusive, as a fraction of all samples (about 19,000 per thread per run).
Run Build FPS frame p50 GPU busy / present __emutls_get_address, worker __emutls_get_address, committer
1 #6292 7.76 128.6 ms 77.5 ms 1.58 % 2.57 %
2 this PR 7.80 128.1 ms 77.5 ms 1.58 % 2.50 %
3 this PR 7.79 129.1 ms 77.6 ms 1.73 % 2.62 %
4 #6292 7.81 128.7 ms 77.7 ms 1.99 % 2.71 %
  • SampledReadScope on the worker: 0.75 % and 0.81 % without, 0.70 % and 0.72 % with. That is the same direction as your Sonic numbers, but within run-to-run noise here.
  • On the committer, no remaining __emutls_get_address caller is above 0.3 % of the samples. The largest are GuestMemory::Accessible (from ShaderResources::MovedReadOnlyBuffers), Recorder::InCompletion (from CompletePendingCpuWrites in revalidateFull and StorageTexture::refresh), ShaderResources::PrepareDrawBindings, GuestMemory::CheckRange, FlushDepthPlanes and ColorTargetLayout. On the worker, they are Driver::execute, AgcDriverTraceThread, GuestMemory::CheckRange/Accessible under DecodeVertexStageInfo, and Driver::validateCaptured.
  • No errors in any run.

AI-assisted: yes (Claude Code). The runs were made on my machine.

@TechLevelZero

TechLevelZero commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

❌ NVIDIA GPU test: build failed

PR head 07bb9f6 merged onto main e6f5730 · tested 2026-11-01 15:07 UTC · 3 min

Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ❌ failed
Tests not run
build: first errors
[5248/6986] Building CXX object core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Execution/src/Driver/Packets/PacketExecution.cpp.o
[5249/6986] Building CXX object core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Graphics/src/Texture.cpp.o
FAILED: core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Graphics/src/Texture.cpp.o 
ccache /usr/bin/g++ -DANYPS5_ENABLE_SPIRV_TOOLS=1 -DAPS5_ENABLE_TIMING_LOG=0 -DlibSceAgcDriver_EXPORTS -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/libs -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/build/core/libs/prx/libSceAgcDriver/generated -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/shader/recompiler/RdnaDecoder/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/3rdparty/Vulkan-Headers/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/3rdparty/SPIRV-Headers/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/shader/recompiler -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/shader/recompiler/ControlFlow/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/shader/recompiler/IntermediateRepresentation/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/shader/recompiler/Translation/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/shader/recompiler/Optimization/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/shader/recompiler/SpirvBackend/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/3rdparty/glslang -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/Decoder/Png/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/build/3rdparty/SDL2/include -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/build/3rdparty/SDL2/include/SDL2 -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/build/3rdparty/SDL2/include-config-release/SDL2 -I/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/3rdparty/zstd/build/cmake/../../lib -isystem /home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/3rdparty/zstd/lib -isystem /home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/3rdparty/libjpeg-turbo/src -isystem /home/ben/anyps5-gpu-ci/data/trees/pr-6615/build/libjpeg-turbo/include -O3 -DNDEBUG -std=c++20 -fPIC -MD -MT core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Graphics/src/Texture.cpp.o -MF core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Graphics/src/Texture.cpp.o.d -o core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Graphics/src/Texture.cpp.o -c /home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp: In lambda function:
/home/ben/anyps5-gpu-ci/data/trees/pr-6615/src/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:4310:34: error: 'refreshing' was not declared in this scope; did you mean 'refresh'?
 4310 |             const auto* exempt = refreshing;
      |                                  ^~~~~~~~~~
      |                                  refresh
[5250/6986] Building CXX object core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Execution/src/FrameRecorder.cpp.o
[5251/6986] Building CXX object core/libs/prx/libSceAgcDriver/CMakeFiles/libSceAgcDriver.dir/Execution/src/Driver/Queues/Submission.cpp.o
Reproduce
git fetch origin 07bb9f628d1ddacf2483d16420d8d01f63649789 e6f57307fa7f47165d7fc1bee945abdb2f6816e7
git checkout e6f57307fa7f47165d7fc1bee945abdb2f6816e7 && git merge --no-ff 07bb9f628d1ddacf2483d16420d8d01f63649789
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@fogydes

fogydes commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

should-fix

Findings

  1. [verified] Freshness & Mergeability: git merge-tree --write-tree origin/main pull/6615 succeeds cleanly with exit code 0 and tree SHA ad185b4a47584b2101ca13ddbb9fb4349ef5089d, despite being 7,756 commits behind origin/main. Base commit 2659ec333e is already merged into main, leaving a clean single-commit delta on top of main.
  2. [read-only] Performance Evidence: Complies with AGENTS.md perf requirements by providing both aps5-summary.jsonl lines and full tools/trace_digest.py digests on Sonic Origins Plus (RTX 2080 Ti, driver 617.14), demonstrating ~1% worker frame time reduction on __emutls_get_address.
  3. [read-only] PR Template Checklist: The checklist in the PR body omits the required - [ ] Fixes: none (or issue reference) item from .github/pull_request_template.md.
  4. [read-only] Vulkan Validation Comparison: The diff modifies core AGC driver execution paths (ShaderResources.cpp, Texture.cpp). Per AGENTS.md, AGC changes require comparative test logs on main and the branch with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, confirming zero new VUID- validation errors.
  5. [verified] Conventions: tools/check_conventions.py --base 2659ec333e passes cleanly with zero violations in an isolated worktree.
  6. [verified] Cross-PR Ledger: Pairwise merge simulation against concurrent open PRs modifying shared AGC resource structures:

Freshness Envelope

  • Head SHA: 07bb9f628d1ddacf2483d16420d8d01f63649789
  • Merge-base SHA: 2659ec333e03dabdb486d48eccdc841654ae529c
  • Behind count: 7,756 commits
  • Merge-tree: clean (exit code 0, tree ad185b4a47584b2101ca13ddbb9fb4349ef5089d)

@jotitadev jotitadev 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.

On the NVIDIA CI build failure at 07bb9f628 ('refreshing' was not declared in this scope, Texture.cpp): this is a merge skew with #8911, not a toolchain issue.

#8911 (68f51b5a0b, merged 25/10, after this head) added a new reader of the old thread_local refreshing in the nothingToStore lambda at the top of StorageTexture::FlushPending. This PR replaces that variable with the Refreshing HostThreadSlot, and git merges the two cleanly, so the new line keeps naming a variable that no longer exists. It is the only error: a -k 0 build of libSceAgcDriver on the merge with main f91137142 reports just this line.

Fix, one line in the merged FlushPending:

             std::lock_guard lock(pending.mutex);
-            const auto* exempt = refreshing;
+            const auto* exempt = Refreshing::Get();

With it, libSceAgcDriver builds (Linux, GCC 15.2, Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON). On an RTX 3070 (NVIDIA 595.99.02), agc_driver_queued_index_read_order (#8911's test) and the 39 tests in agc_driver_graphics_tests pass, 40/40 in each of 3 runs. I did not run the full suite.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 4, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi meh7an,

Thanks for moving the per-draw thread-locals to TEB slots. One thing changed on your branch so it can land, on top of 07bb9f628d: we merged current main, and main had meanwhile added a new use of the old thread_local refreshing in StorageTexture::FlushPending (Texture.cpp, in the nothingToStore check). That variable no longer exists on your branch, so the merged tree did not compile; we changed that one use to Refreshing::Get(), like the others. Nothing else in your change was touched. A full build and the agc tests pass on the merged result. Feel free to adjust it if you would rather handle it differently.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 595a347 merged onto main c5bd55a · tested 2026-11-05 11:00 UTC · 27 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,870 passed · 3 failed (0 new, 3 also fail on main) · 55 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,928 of 3,972 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (990 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 105.6 s
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (9 IDs in 550 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (550 tests): agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, and 542 more
VUID-VkShaderModuleCreateInfo-pCode-08737 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08739 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08741 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
VUID-VkPipelineShaderStageCreateInfo-module-parameter (1 test): agc_driver_float16_unused_nan_payloads
VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849 (1 test): agc_driver_float16_unused_nan_payloads
Skipped (55)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_net_ctl_disconnected: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_four_k: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_height_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_limit: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_malformed: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_width_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no disp
Reproduce
git fetch origin 595a347a9367b0a821841d24b01f5496bb1bd6e1 c5bd55a89a07d39840867cc671f622f3d7c4869c
git checkout c5bd55a89a07d39840867cc671f622f3d7c4869c && git merge --no-ff 595a347a9367b0a821841d24b01f5496bb1bd6e1
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 595a347 merged onto main 4639eff · tested 2026-11-05 11:41 UTC · 39 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,850 passed · 12 failed (0 new, 8 also fail on main, 4 unstable on main) · 67 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,929 of 3,962 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (996 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 121.0 s, ⚠️ public_headers 85.5 s, ⚠️ agc_driver_image_sample_unnormalized 77.4 s, ⚠️ agc_driver_lazy_resolved_abi 66.8 s, ⚠️ agc_driver_sample_multisample_target 52.8 s
Unstable on main (4, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_depth_fast_clear_submit: failed in 2 of the last 10 main runs
agc_driver_pipeline_journal: failed in 9 of the last 10 main runs
guest_pthread_start: failed in 2 of the last 10 main runs
trace_digest_TraceDigestTests_test_cli_rejects_invalid_event_fields_without_partial_output: failed in 2 of the last 10 main runs
Failing on main too (8, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Passed on retry (3, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)
agc_driver_emulated_color_compare: Timeout in the parallel run; also passed only on retry in 47 other runs in the last 7 days
agc_driver_null_buffer_substitutes: Timeout in the parallel run
agc_driver_sgpr_pattern_fill_keys: Failed in the parallel run; also passed only on retry in 12 other runs in the last 7 days
Validated but not compared (1, not in the main baseline's validation pass)
guest_pthread_start
Validation IDs already present on main (4 IDs in 557 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (557 tests): agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, and 549 more
VUID-vkCmdCopyImage-srcImage-01548 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (67)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_idle_publish_wait: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a forced watch of the import reads its submissions as CPU stores
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_storage_pending_key_refresh: skipped, refreshes over a pending key store are not testable here
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_net_ctl_disconnected: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_four_k: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_height_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_limit: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_malformed: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayla
Reproduce
git fetch origin 595a347a9367b0a821841d24b01f5496bb1bd6e1 4639eff7f4c23325a916875a0e37f1e312fa18f4
git checkout 4639eff7f4c23325a916875a0e37f1e312fa18f4 && git merge --no-ff 595a347a9367b0a821841d24b01f5496bb1bd6e1
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

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

Labels

agc libSceAgc* build libc perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.