Skip to content

fix(agc): prioritize demanded shader preparation - #4404

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
eljackjoestar-cmd:codex/demanded-shader-preparation
Oct 13, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
eljackjoestar-cmd:codex/demanded-shader-preparation

Conversation

@eljackjoestar-cmd

@eljackjoestar-cmd eljackjoestar-cmd commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Lost Soul Aside (PPSA26358) can stop during startup with LastObjectNotReadyForFinishDestroy is NULL while a game task waits in AwaitRegisteredPreparation. The registration pool processes jobs in FIFO order, so a shader needed immediately can sit behind hundreds of unrelated preparation jobs even with a warm disk cache.

Tag registration jobs with their prepared-state identity and move the requested job to the front when a caller waits for it. Record demand before consulting the queue, so a request arriving between snapshot publication and job submission also receives priority. Existing running jobs complete normally; queued work is retained, each job executes once, and preparation failures still propagate. Shader instruction semantics are unchanged.

Tested

Windows 11, GCC 15.2 Release, RTX 5070 (12 GB, driver 617.14), Ryzen 7 7800X3D, 32 GB RAM. Branch based on main fc1f063f5; head 68c2b0f74.

  • Full Windows Release build passes on this isolated rebased branch. agc_driver_prepared_publication passes without skips in 0.66 s. The regressions verify that demanded work runs first without duplication, both after enqueue and when demand arrives before enqueue.
  • Earlier negative control (not repeated for this rebase): making only the demand-prioritization function a no-op fails the regression with demanded preparation waited behind background work or ran twice. Restoring it passes.
  • Earlier local title integration passed all ten focused prepared-publication/prepared-shader tests, including synchronous and deferred modes (about 5.2 seconds total).
  • Earlier integration comparison: before this change, both cold-cache and warm-cache integration launches hit the startup fatal; the warm run reported zero cache misses. Crash stacks show a game task waiting for preparation while all eight preparation workers run other shaders.
  • In that earlier comparison, with this change, two separate fresh-cache launches reached the title screen on their first attempt, then entered loading after two X presses. Cache logs reported zero hits. The trace observed demanded work at positions 497 and 946 in queues of over a thousand jobs.

No game run was repeated for this rebase. Earlier title tests used the integration described in #4401, including unmerged rendering/ancillary/IR-memory/direct-memory fixes. This branch contains only the scheduling change and its regression tests. Level loading still exhausted available commit headroom and the memory guard stopped the game; gameplay and complete compatibility are not claimed. Rendering and startup audio are separate from this scheduling fix.

tools/check_conventions.py --base origin/main and git diff --check pass. Linux, console hardware and collaborator-triggered full CI were not run.

Checklist

  • Based on current main; no other open PR implements this demand-priority behavior. Related perf(agc): resolve static shader ABIs on the background pool #2589 moves static ABI preparation to the background pool; this change prioritizes existing registration jobs.
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA26358 Lost Soul Aside (PPSA26358): bring-up and remaining blockers #4401 (startup fatal)
  • AI-assisted: yes (OpenAI Codex)

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on main 88107b7de together with thirteen other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it:

  • tests/execution/PreparedPublication.cpp (agc_driver_prepared_publication): 3 of 3 runs passed.

Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed.

AI-assisted (Claude Code).

@fdfawef324

Copy link
Copy Markdown
Contributor

Tested on Windows with Black Myth: Wukong (PPSA23226). This PR fixes a hang there.

Without it: the title never presents a frame. With a warm shader cache, queue 0 stops executing after 173 submissions, at about 167 s. The queue worker is parked in AwaitRegisteredPreparation, behind the background preparation pool. The render thread waits for the last submission's completion label. At about 325 s Unreal aborts: GameThread timed out waiting for RenderThread after 120.00 secs. A cold-cache run stops the same way, at 270 s.

With this PR: APS5_TRACE_PREPARATION_WAIT=1 shows the shaders the worker waited on had been queued at these positions:

  • 2507 of 2509
  • 955 of 956
  • 905 of 906
  • 13 of 2525

The title now presents frames, the first at 45.6 s. Queue 0 executes 343 submissions, and Unreal reaches level and game-mode setup. There is no GameThread timeout. It runs until an unrelated crash at 262 s.

agc_driver_prepared_publication passes, and it fails when PrioritizeRegistrationPreparation is emptied. The PR merged cleanly onto main 6d7b873 and onto my integration branch. That branch also carries #4508 and #4960, which this title needs to start.

@github-actions

github-actions Bot commented Oct 13, 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
#5007 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp L110
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L796, L804, L830, L838-839, L852

@eljackjoestar-cmd
eljackjoestar-cmd force-pushed the codex/demanded-shader-preparation branch from c5eceec to 68c2b0f Compare October 13, 2026 08:22
@eljackjoestar-cmd

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto main fc1f063f5. Full Windows Release build passes, and agc_driver_prepared_publication passes without skips (0.66 s), including demanded work both before and after enqueue. Conventions and whitespace checks pass. The PR description separates this fresh rebase validation from the earlier integration/game and negative-control results; no new game run is claimed.

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.

4 participants