Skip to content

fix(agc): trace the title threads that register shaders - #7293

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/trace-title-shader-threads
Oct 17, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/trace-title-shader-threads

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Driver::RegisterShader, ResolveShaderAbi, ResolveGraphicsAbi and ResolveGraphicsStagesAbi run on the title's own threads (sceAgcCreateShader and the ABI calls of libSceAgc). Those threads never call PerformanceTrace::BindThread, so PerformanceTrace::Thread() is null there. Their Shader.Register and Shader.Resolve* scopes, and any Shader.PrepareArtifact work they do inline, were missing from every APS5_TRACE_* trace and summary. The summary still said trace_dropped: false.

Each of the four entry points now binds the calling thread first, when a trace is configured, as title. It uses the 32,768-event buffer the shader preparation threads use (TraceThread::DefaultCapacity / 8). BindThread returns at once for a thread that is already bound, such as a queue worker. Without a trace switch, nothing is allocated. docs/dev/BUILD.md names the new buffer next to the shader preparation ones.

#6341 does the same for the draw committer thread. This PR binds different threads and puts its test entries in another part of the CMake test block, so the two don't touch the same lines.

Tested

Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.02; main e815fb4.

  • New agc_driver_registration_trace (APS5_TRACE_FRAMES=0:1): a new thread registers a pixel shader inside the window. That thread must then hold a trace buffer named title, not dropped, whose slices and totals both have a Shader.Register scope longer than zero. agc_driver_registration_trace_disabled runs it with the trace switches unset; the registering thread must have no buffer.

    With main's ShaderRegistry.cpp the traced case fails 3 of 3 with a title thread that registered a shader has no trace buffer, and the disabled case passes. With this change both pass 3 of 3.

  • ctest ^agc_ (674 tests): all pass.

  • Forspoken (PPSA03984), warm caches, 130 s with scripted pad input, APS5_TRACE_SECONDS=45:20, one run of each build. On main 922dc89 the trace has no title thread, and the summary's eight largest phases are driver and Vulkan scopes. With this PR (f7cd8df) the trace has seven title threads holding 7,047 Shader.Register scopes (14.5 s summed over the threads), 323 Shader.ResolveGraphicsStagesAbi (780 ms), 163 Shader.ResolveAbi (536 ms) and one Shader.ResolveGraphicsAbi. Shader.Register is the summary's fourth largest phase, at 500.8 ms per frame:

main: seconds 45:20: 26 presents, frame p50 390.8 / p90 3131.9 ms, trace_dropped false; top: Driver.Packet 1951.1, Driver.Packet.memory_wait 1114.0, Driver.Packet.dispatch 462.6, Driver.Dispatch 437.0, ...
PR:   seconds 45:20: 29 presents, frame p50 401.1 / p90 1648.8 ms, trace_dropped false; top: Driver.Packet 1942.6, Driver.Packet.memory_wait 1046.6, Driver.Packet.dispatch 522.2, Shader.Register 500.8, Driver.Dispatch 497.8, ...

Not checked on Windows, macOS, AMD or Intel.

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: none
  • Unblocks: none (diagnostics)
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti (595.99.02, Linux)
  • AI-assisted: yes

🤖 Generated with Claude Code

Shader registration and the shader ABI resolves run on the title's own
threads, which never bound a trace buffer, so their Shader.Register and
Shader.Resolve* scopes were missing from every trace and summary. Those
entry points now bind the calling thread as `title` with the 32,768-event
buffer the shader preparation threads use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

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 674 docs/dev/BUILD.md
PR 1341 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1835 docs/dev/BUILD.md
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 3186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4339 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4650 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4891 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/BUILD.md
PR 5115 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5426 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5958 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 5998 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6134 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6176 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6259 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6320 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6373 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6454 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6486 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6535 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6601 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6741 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6788 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6867 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6887 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6965 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6973 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6987 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6989 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6995 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7002 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7201 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7223 core/libs/prx/libSceAgcDriver/CMakeLists.txt

@oneandonlydean oneandonlydean self-assigned this Oct 17, 2026
@oneandonlydean
oneandonlydean merged commit f1dc7b4 into boykopovar:main Oct 17, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants