Skip to content

fix(agc): read GPU timing queries without waiting on unwritten ones - #6363

Open
hypermoist wants to merge 1 commit into
boykopovar:mainfrom
hypermoist:fix/agc-timing-queries-no-wait
Open

hypermoist wants to merge 1 commit into
boykopovar:mainfrom
hypermoist:fix/agc-timing-queries-no-wait

Conversation

@hypermoist

Copy link
Copy Markdown

What

Recorder::readGpuTiming reads a batch's timestamp queries after the batch's fence was waited on, so every stamp the batch wrote is already available. It still passed VK_QUERY_RESULT_WAIT_BIT. Begin and end stamps are separate calls (BeginGpuTiming / EndGpuTiming), so a timed range whose end never ran, for example a draw that failed between the two and was skipped, left its end query unwritten, and vkGetQueryPoolResults then waited forever on the reaping thread. This only happens with GPU timing on (APS5_PROFILE_GPU, draw profiling or a performance trace).

Without WAIT_BIT the call returns VK_NOT_READY for such a batch and its timings are dropped, as they already are for any other non-success result.

Tested

Linux (CachyOS, GCC Release, NVIDIA GeForce RTX 3060): builds; the AGC group of ctest passes except agc_driver_store_over_untracked, which fails on unmodified main too. tools/check_conventions.py passes; tools/pr_overlap.py --branch reports no line overlap. The stall was found profiling PPSA08427 with APS5_PROFILE_GPU=1 on my local branch; the game was not rerun on this exact rebase.

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
  • GPUs tested: NVIDIA GeForce RTX 3060 (proprietary driver)
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q8tinbP1MUpUaDsbNWnGnu

readGpuTiming runs after the batch's fence, so every timestamp the batch
wrote is already available. It still passed VK_QUERY_RESULT_WAIT_BIT, so a
timed range whose end stamp was never written (a BeginGpuTiming whose
EndGpuTiming did not run) made vkGetQueryPoolResults wait forever on the
reaping thread under APS5_PROFILE_GPU or a performance trace. Without WAIT_BIT the call returns
VK_NOT_READY and the batch's timings are dropped, as other failures are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q8tinbP1MUpUaDsbNWnGnu
This was referenced Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 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 5431 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6185 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6539 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6946 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6947 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp

@Neithennn

Copy link
Copy Markdown
Contributor

Windows NVIDIA run, since the description lists Linux only.

Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies, BUILD_TESTING=ON, ANYPS5_NO_SHADER_CACHE=1. Head 44d31ef9d merged onto main ff23657f3; full build succeeds.

These tests do not seem to reach Recorder::readGpuTiming. I tried APS5_PROFILE_GPU=1 on agc_driver_graphics: it stops at missing Vulkan function: vkCreateQueryPool both with this PR and on unchanged main, so the changed path is not exercised here. No title run.

AI-assisted: yes (runs done with Claude Code).

@JJenkx

JJenkx commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

I reproduced this on AMD Radeon RX 6650 XT / RADV Mesa 26.2.4-arch1.1, Arch Linux, current main b7cedd900. A real-queue test deliberately leaves one range end unwritten, completes another range in the same batch, then submits and syncs. With main, the all-complete control passes but the incomplete case times out at 15 seconds. With your exact 44d31ef9d change, both pass, and complete batches before/after the incomplete batch retain valid GPU timings. The test executable is byte-identical across the negative control and fixed runs.

Added the test-only follow-up as draft #6514, explicitly depending on this PR. Validation source with your fix; standalone test commit is based directly on main if useful to cherry-pick. Full libs build and four relevant tests pass on both RADV and lavapipe with the fix. Lavapipe also passes the unfixed case, so software-driver-only testing does not expose this hang. No title or FPS claim.

This branch has not been deployed

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

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants