fix(libSceAgc): return the console's register-defaults table and type pairs #6270
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6270"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-15T08:36:33Z.
What
PS5 FSR4 Showcase (PPSA99011, catalog 01.000.010) with #5648 stops at its first compose pass, 11 to 15 ms after chapter 0 starts:
No submission reaches the queue for it. The title's Vulkan driver (ps5-vulkan at
4bb0c8b) logs over the network, so I caught its lines on the guestvsnprintfwith gdb:Line 1030 of
native/graphics_queue_ps5.cisps5vk_color_runtime_defaults(defaults, sceAgcGetRegisterDefaults()).color_runtime_defaults.hlooks up the MRT0 colour-target block by its key0x38e92c91and refuses the table. There are two reasons:+0x30) held the compact 12-byte entries. Their second word also packs the block's register count and stride above bit 10 (0x00204138for MRT0 in the 137-entry table). The driver, like the other homebrew that share itsps5_agc_registers.h, reads 8-byte{key, index << 2 | bank}pairs. So it read MRT0 at index 529482.sceAgcGetRegisterDefaultsreturned the version 0 table. ps5-vulkan measured the console returning the running system software's table: 128 entries over 79 context blocks on 10.x, 137 over 84 on 12.02 and 13.x. The version 0 table has 150 entries, and its MRT0 block has0x319where the colour target has0x31b, so the driver refuses it even with the pairs fixed.Changes:
GetRegisterDefaultsbuilds the type table once per table as{key, entry & 0x3ff}pairs and checks that each index lies inside its bank.sceAgcGetRegisterDefaultsreturns the version 13 public table, which is the 137-entry one.sceAgcGetRegisterDefaults2(version)is unchanged.guest_shader_linknow expects that table (488 context registers instead of 523).agc_commandsandagc_initialization: reads the root at its byte offsets, walks the pairs and follows the MRT0 key to the sixteen colour-target registers. It expects block 78 forsceAgcGetRegisterDefaultsand block 73 for version 10, and a valid block in every version from 4.Title. PPSA99011 on
main+ #5648:stage=composein every run.stage=fsr4 after_ms=6149on its new pipelines. That is the build time described in #6118.Tested
Linux (Bazzite 44, GCC 16.2.1, Ninja, Release,
-DBUILD_TESTING=ON), RX 7700 XT (RADV), based onmaind92a8dad3:ctest: 1199 of 1222 pass and 20 are skipped (display tests).application_heap_lazyandagc_driver_tessellationsegfault, andagc_host_import_sparsefails, on unchangedmainhere too (#5759 fixes the last one).agc_commandsandagc_initializationfail on the new test with the compact entries put back ("MRT0 defaults key is missing, repeated or outside the context blocks"), and with the legacy call on version 0 ("legacy register defaults are not the newest public table").main4808d9c20+ #5632 + #5648, hidden display, no controller. Catalog sweep of 67 titles (25 s each) against the same tree without this PR: no title that ran before stops or drops in FPS, and PPSA99011 now runs. No other title in the set contains the MRT0 key except a Unity title that does not start here.tools/check_conventions.py --base upstream/mainpasses, andtools/pr_overlap.pyreports no overlap. #5845 also edits bothRegisterDefaults.cppfiles andtests/Commands.cpp, addingsceAgcGetDefaultCxStateFlat, a separate function. Windows and macOS were not built here.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-15T09:19:21Z.
Windows build and tests, for "Windows and macOS were not built here". Windows 11 (26200), RTX 3060 Laptop GPU (NVIDIA 617.42), WinLibs GCC 15.2.0 r7 (UCRT), Release,
BUILD_TESTING=ON. Head39575d66emerged ontomainc0be1f69b(clean).agc_commands,agc_initializationandguest_shader_linkpass.RegisterDefaults.cppfiles frommainand the PR's tests:agc_commandsandagc_initializationfail withlegacy register defaults are not the newest public table(2 of 2 runs).guest_shader_linkaborts (0xc0000409).Command/src/RegisterDefaults.cppfrommain:agc_commandsandagc_initializationfail withMRT0 defaults key is missing, repeated or outside the context blocks.guest_shader_linkpasses.ctest -R "agc|shader|guest_playgo" -j4: 579/579 pass with the PR (3 skipped, same asmain). Onmain,agc_driver_resource_cache_storage_admissionfailed once under-j4and passed 2 of 2 alone.Not run: PPSA99011, macOS.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:17:50Z.
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.
core/libs/tests/GuestShaderLink.cppcore/libs/prx/libSceAgc/tests/Commands.cppdocs/dev/debt/libSceAgc.mdImported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T13:12:32Z.
Cross-validation on Windows 11 Pro 26220, NVIDIA RTX 4070 (596.21), MinGW GCC 15.2, PR head
39575d66emerged on main8856f180cwith #5648943d362d2:#5648 has since been merged as
23dcb8249with the same head. Both merges are clean. Full Release build (BUILD_TESTING=ON) andlibspass, with no warnings in the changed files. Ryzen 7 5700X. Title relinked as in our catalog runs:--windows --trap-sdk-syscall-stubs --registry unused-filter=0,app0/eboot.binstaged,ANYPS5_REQUIRE_DISPLAY=1, real window, 120 s limit.PS5 FSR4 Showcase (PPSA99011, 01.000.010). The "before" side is the same tree with only the two
RegisterDefaults.cppreset tomain, thenlibsrebuilt. "Cold" means the title'sshader_cachefolder was deleted first; "warm" means it was reused.FSR4_SHOWCASE_ERROR fence=-4 stage=fsr4 after_ms=4555,FSR4_SHOWCASE_END result=FAILFSR4_SHOWCASE_ERROR fence=-4 stage=fsr4 after_ms=4583,FSR4_SHOWCASE_END result=FAILFSR4_SHOWCASE_ERROR fence=-4 stage=fsr4 after_ms=4540,FSR4_SHOWCASE_END result=FAILFSR4_SHOWCASE_ERROR fence=-4 stage=fsr4 after_ms=4553,FSR4_SHOWCASE_END result=FAILFSR4_SHOWCASE_ERROR fence=-4 stage=fsr4 after_ms=4580,FSR4_SHOWCASE_END result=FAILFSR4_SHOWCASE_READYandCHAPTER index=0.0x2754c0000..0x275580000cold, a few more warm) and then fail the FSR4 fence.presentation failed,MUBUF/MTBUFor a device loss, and no run presents a frame.So on NVIDIA I can't reproduce the
stage=compose after_ms=15stop. The title stops one stage earlier, at the samestage=fsr4fence that @LeandroLP23 (Radeon 860M, Windows) and you (RX 7700 XT, RADV,4808d9c20+ #5648) reported in #5648. The compose pass that reads the register defaults is never reached here, so the title can't show this PR's effect on this machine. What got your run paststage=fsr4? The body lists only #5632 and a hidden display on top of #5648.Tests
agc_commands,agc_initializationandguest_shader_link: 3/3 with--repeat until-fail:3.RegisterDefaults.cppfrommainand this PR's tests kept.agc_commandsandagc_initializationfail withlegacy register defaults are not the newest public table.guest_shader_linkaborts with 0xC0000409.-j8 -E '^agc_driver_|^video_out_flip'): 793/817 on the first pass, 2 skipped. The machine was also running two other builds at the time. The 24 failures were 22 ctest timeouts,conventions_wrapped_declarations(its internal 20 s subprocess timeout) andguest_kqueue(0xC0000409). Rerun serially, 21 of 24 pass. With a 600 s timeout,conventions_function_bodiesanddebt_splitpass too.hardware_oracle_comparestill hits its fixed 20 sTIMEOUTproperty. None of them touches libSceAgc.-j1 -R '^agc_driver_' --repeat until-fail:3): 439/439. 437 pass 3 of 3, 2 skip (agc_driver_sparse_dma_buf_import,agc_driver_stencil_ref_export).tools/check_conventions.py --base origin/main:All conventions checks passed.git diff --check: clean.Review notes
color_runtime_defaults.husestype_index_pairsandps5_agc_type_index_bank/value. Their definition,ps5_agc_registers.h, is not in ps5-vulkan's tree at4bb0c8b, so the 8-byte pair layout can't be checked from the linked source.core/readsRegisterDefaults::types, so dropping the count/stride bits and word 2 loses nothing internally.testDefaultsbuilds every public and internal table for versions 0–13, so the new bank-indexRequireis checked on all of them.Verdict: build, tests and conventions are confirmed on NVIDIA/Windows, and no regression found. Not confirmed: the PPSA99011 compose fix. On this GPU, with and without the PR, the title stops earlier at
stage=fsr4.Written with Claude Code assistance.
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-15T13:23:44Z.
AMD confirmation: with this PR, PS5 FSR4 Showcase gets past
composeand plays chapters 0, 1 and 2. On the same warm cache,mainstops atcompose.Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release.
main8856f180c(with #5648 merged), alone and with head39575d66emerged (clean). Catalog 01.000.010, relinked with--windows --trap-sdk-syscall-stubs. All runs use the same run folder, whoseshader_cachewas already warm (cache_in=28026892).mainCHAPTER index=0, thenFSR4_SHOWCASE_ERROR fence=-4 stage=compose after_ms=45CHAPTER index=0,1(Against a bilinear upscale),2(One pixel in nine), thenFSR4_SHOWCASE_ERROR vkQueueSubmit(queue, 1, &s, fence) = -4APS5_PROFILE_DRAW=1The run before the
maincontrol in this table had stopped earlier, atstage=fsr4(after_ms=4528). On the newmainone slow pipeline was missing from the cache, and that run built and saved it. The control then ran on a fully warm cache.The stop in chapter 2 is pipeline build time again, as in #6118. Chapter 2 dispatches programs the earlier chapters don't, and one of them wasn't cached yet:
@screamm, on getting past
stage=fsr4: here it took a pipeline cache built over 7 runs. Each run stops while the queue worker is still building one large FSR4 compute pipeline: 130k–800k SPIR-V words, up to 66 s each on this GPU. That build finishes after the title gives up, and[pipeline-cache] savedkeeps it at teardown, so the next run gets one pipeline further. The full table is in #6118. A run only adds to the cache if the process stays up until that build ends. I let each run go 60–90 s.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-16T06:53:07Z.
@screamm on your two points:
stage=fsr4: as @LeandroLP23 described, my run used ashader_cachebuilt over earlier runs. Each run that stays up until the slow FSR4 compute pipeline finishes building saves it at teardown, so later runs get past the fence. With a cold cache, my runs also stop atstage=fsr4, as in #6118.composeonly shows up once that stage is cached.ps5_agc_registers.h: it isn't in ps5-vulkan itself. Its Makefile takes it from a sibling repository,-I$(LAB_SIBLINGS)/ps5-agc-gears/include. The header isinclude/ps5_agc_registers.hin ps5-agc-gears. There,struct ps5_agc_type_indexis{uint32_t key; uint32_t encoded_index;}, which is 8 bytes. The bank isencoded_index & 3and the index isencoded_index >> 2. Static asserts pintype_index_pairsat root offset0x30and the root at0x40bytes ("FW 12.02 defaults root ABI"). That matches the pairs this PR produces. ps5-vulkan's owntests/test_color_runtime_defaults.calso builds its fake table asvalue << 2 | bank.Imported from boykopovar/AnyPS5. Originally posted by ArielWolle on 2026-10-18T22:05:26Z.
Regression report for PPSA34063 (NHL 27, update 01.003.001) on Windows. I'm not claiming a cause in this PR's code; I'm reporting what changes when it is reverted and asking one question.
Symptom. With this PR in, the title stops about 22 s after start, before it presents a frame, with:
The message is the
require(value != 0xffffffffu, ...)inregisterOffsetinExecution/src/Pm4.cpp, reached from an indirect register packet whose pair list holds the offset0xffffffff.What I compared (Windows 11, MinGW-w64 GCC 15.2, RTX 3070, driver 617.42; same relinked executable, game files and
libsin both runs):mainat0bc3003f8plus three unrelated open changes (#7254, #7256, and a CMASK slice fix, none of which touches PM4 or libSceAgc), with this PR: stops as above, one run.git revert -m 1 2da2284de(this PR) applied andlibSceAgc.prxrebuilt: no failure; the title was still running after 2 minutes when I looked, and it kept compiling shaders.mainat48d61f53b(before this PR), passed this point in every run, about ten.So reverting this PR is what removes the stop on this machine. I have not narrowed it to one of the two commits (the table type pairs, or
sceAgcGetRegisterDefaultsnow returning the version 13 table).Question. Does the console's version 13 register-defaults table contain entries a title turns into
0xffffffffoffsets in an indirect register list, and if so what does the command processor do with them (skip the pair, write nowhere)?registerOffsetthrows on them as unimplemented, so a title that reads this table through the legacy call now stops there. I can't tell from the title's side which of those it is, and I'm not proposing to make the driver accept the sentinel without that.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-18T22:59:13Z.
Since this PR, PPSA15304 aborts about 10 s after start:
The message comes from
registerOffsetinExecution/src/Pm4.cpp, which rejects a register offset of0xffffffff.main07377573fwith #7050 merged aborts like this; the same tree with only this PR reverted (git revert -m 1 2da2284de) loads the save and runs in game. The last build without this PR that I ran,mainbf2053816, also runs.Ubuntu 24.04, kernel 7.0.0, NVIDIA GeForce RTX 5080, driver 595.99.02, Release build.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-19T00:26:27Z.
@YossiYad since this merged, Uncharted: Legacy of Thieves Collection (PPSA05684, #4001) stops before its first frame:
The failing packet is a context register list: opcode 0x9f, pairs mode (
0x80000000), 232 entries. Several of its offsets are0xffffffff, and guest memory holds the same bytes when the packet runs, so the read is not stale:I narrowed it down on my integration build (
main773243436+ my open PRs + local patches, all unchanged between runs). The title does not run on plainmainwithout those PRs:f7750c776(the 8-byte{key, index << 2 | bank}type pairs) reverted, the title reaches the menu and renders it as before.dce1573ea(the version 13 table) reverted, it still stops.So this title appears to read the type table in the compact 12-byte form, while PPSA99011 reads pairs. Maybe the layout depends on the SDK the title was built with. I have not checked what the console's library hands out per SDK version. Happy to test a candidate fix on this title.
Linux, RTX 4070 Ti SUPER, NVIDIA 615.78.08.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-19T02:50:26Z.
@YossiYad another regression from this merge, a different symptom from the indirect-register sentinel above, on a free catalog title anyone can run: Middle Ages Ping Pong (PPSA28319, a Unity homebrew from the homebrew catalog). Windows 11, RTX 3080, WinLibs GCC 15.2, Release.
a62c724c3runs the title at 59.95 FPS for the full 60 s.a6dd29b3dcrashes at start-up, 2 of 2 runs:0xc0000005, a read of0x18atapp.exe+0x145782d, right after Unity's owntodo: GfxDevicePS5SharedData::CreateWorkload()line (rcx/rbx= 0). Before this PR the same point goes on to start its worker threads and load "unity default resources".bd7cd1be1(this merge's first parent) good,2da2284de(this merge) bad, with the same crash at every later bad step. (#6112's start-up abort, reverted by #7646, was told apart separately.)a6dd29b3dwith onlygit revert -m 1 2da2284dereaches "unity default resources" again, with no fault.Like the NHL 27 report, this isn't narrowed to one of the two changes yet: the
typesarray becoming{key, bankIndex}pairs, orsceAgcGetRegisterDefaults()now returning the version 13 table. I'll add which one once I've tried each on its own.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-19T02:54:34Z.
Narrowed the Middle Ages Ping Pong crash to the
typeslayout change inCommand/src/RegisterDefaults.cpp; the version 13 return inMisc/src/RegisterDefaults.cppisn't involved. Same machine,a6dd29b3d, 30 s per run, each variant one file restored from2da2284de^1(neither file has changed onmainsince this PR):Misc/src/RegisterDefaults.cppreverted (legacysceAgcGetRegisterDefaults()back to version 0,{key, bankIndex}pairs kept): crashes as onmain,0xc0000005reading0x18atapp.exe+0x145782d.Command/src/RegisterDefaults.cppreverted (typespassed through from the source table again, version 13 kept): runs pastGfxDevicePS5SharedData::CreateWorkload()tounity default resourceswith no fault.So with this title, Unity reads
RegisterDefaults.types(offset0x30) expecting the source's 3-word entries; given the 8-byte pairs, it ends up with a null bank pointer. I didn't run the newCommands.cppregister-defaults test with that file reverted, since it checks the pairs layout.Could the indirect register sentinel reports above have the same cause? A guest stepping through the pairs with a 12-byte stride would read keys from the wrong offsets. I haven't checked those titles, so I can't say.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-19T03:52:02Z.
Correction to my two comments above: they were tested on
a6dd29b3d, which predates #7681 (fea306dff, for #7678). Middle Ages Ping Pong importssceAgcGetRegisterDefaults2andsceAgcGetRegisterDefaults2Internal, not the legacysceAgcGetRegisterDefaults, so it is the #7678 case: the versioned tables handing out 8-byte pairs. Onmainfd423f9b2, which includes #7681, it runs again: 2 of 2 runs for the full 60 s at 59.92 and 59.93 FPS, with no fault, on the same machine. Nothing more is needed here for this title. #7681's Sword of the Sea run also answers my question about the sentinel reports.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-19T13:29:19Z.
Update on PPSA05684: #7681 fixes it as well. On my integration build (
main773243436+ my open PRs), with my local revert off7750c776dropped and #7681 (0c2260e30) applied, the title reaches its main menu and renders it as before, with no indirect register sentinel abort. So nothing more is needed here for this title either.AI-assisted: yes