fix(agc): keep a registered shader's register state as a sorted list #10727
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10727"
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 milescoviello on 2026-10-24T19:51:25Z.
What
A registered shader's
RegisteredShaderStateholds its shader, context and user config registers, each aRegisters.Registersis dense: it keeps a value for every offset up to the highest one set, rounded up to 64, plus a presence bit per offset. A registration's user config state has two registers at 0x24a and 0x24b, and that comes to 2.5 KiB. Its context state starts from the ~300 initial context registers spread up to 0x3b8, about 4.1 KiB. In Ghost of Tsushima (PPSA02225), 172 s into the opening, the registry held 14,322 live states. Their register files came to at least 110.1 MiB in the dense layout, and they hold 33.1 MiB of offset and value pairs. A heap profile 900 s in had 52.7 MiB atInitialContextRegisters, 34.1 MiB at the user config initializer and 23.0 MiB atRegisters::markunderRegisterShader.RegisteredShaderStatenow stores each file as aRegisterList, the present registers as (offset, value) pairs in offset order.Stacked on #10685
This branch holds #10685's commit (
4f15f29b42) and then its own, which is the only one to review here. Both PRs add a type in front ofRegisteredShaderStateinShaderRegistry.hpp, so they would conflict on their own.How
ShaderRegistry.hpp:RegisterListis built from aRegistersand expands back withExpand(), which sets the highest offset first so the dense array is sized once. It hasfind/end/at(binary search),ForEach,size,empty,emplace(keeps offset order, doesn't replace) and==. Decoding still builds denseRegisters, now inDecodedShaderState, andRegisteredShaderStateis constructed from one, so the null and depth-copy programs and the ABI path that adjust or read the decoded registers are unchanged.ShaderRegistry.cpp:DecodeRegisteredStatereturns aDecodedShaderState. The four places that copy a registered state into aQueueStateexpand it.DecodeFloatModetakes either form and reads RSRC1 withfind, so a dispatch's float mode never expands a state.Tested
Head
03449442ec(this commit on #10685's current head22d82e41c4), merged withmain08a10d2253(mergef0ab66231d, clean): a fullcmake --build buildsucceeds, and the 85 tests matching the pattern below pass 3 of 3. Under the Khronos validation layer, 85 of 85 pass onmainand on the merge, with noVUID-messages.Earlier:
Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, NVIDIA 615.71.09. The change was tested alone as
7e8e229bdfonmain30be9b428b, and as this branch's head7c940756fdon #10685. The 80 tests below pass 3 of 3 on both; the mutant, validation and Windows runs are on7e8e229bdf.testRegisterListinagc_driver: a list keeps its registers (expands back to the sameRegisters),findhits and misses correctly,emplacekeeps offset order without replacing a value, and a registered state keeps its decoded registers. Withemplaceappending out of order (a mutant),agc_driverfails 3 of 3:a register list is not kept in offset order, or a second emplace replaced a value.testRegisteredFloatModereads RSRC1 through the new form.agc_driverand its three modes plus the tests of every source that usesShaderSnapshot(80 in all): 80 of 80 pass 3 of 3 onmainand on this head.main30be9b428band on7e8e229bdf, each run asVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R "$R" -V -j4: 80 of 80 pass on each, with no skipped test, 136 device selections (RTX 4070 Ti) on each and no layer-missing line. Both report the same 14VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605, and none is new in the head.main30be9b428bvs7e8e229bdf: the same pattern matches 81 tests there. They pass 3 of 3 onmain, and on the head 2 of 3 with all 81. In the third runagc_driver_submit_progressfailed once, then passed 10 of 10 on the same build (ctest --repeat until-fail:10). This change doesn't touch submission progress.got/g14, my local stack that gets the title through its opening, 16 GB cap): at 46,000 registrations, 3,324 states, dense 23.3 MiB against 7.7 MiB of pairs; at 94,000, 14,322 states, dense 110.1 MiB against 33.1 MiB. The dense figure counts each file's values and presence bits up to its highest offset, so it's a lower bound on what the vectors allocate.mainaeff26bd9): RTX 5070 Ti (621.01) and an AMD RDNA2 iGPU (proprietary 2026.04.17). The 39agc_driver,prepared_*, registry and submit tests pass on both. The append-instead-of-insert mutant ofRegisterList::emplacefailsagc_driverwith the ordering message. 285agc_tests fail the same way with and without the change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)RegisteredShaderStateinShaderRegistry.hpp; this branch carries #10685's commit, and the last commit is this change)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:05:27Z.
Review: COMMENTED
The paired register-state checks and the memory measurements are useful. Since this changes the AGC shader path, CONTRIBUTING requires the same focused run on
mainand the change withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The report confirms validation and says no layer-missing warning appeared, but it does not record whether the first two controls were set for the 80-test comparison. Could you add the exact environment/command, or rerun with those controls if they were not set? This will establish that both arms exercised Vulkan and did not reuse shader-cache results.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:25:15Z.
Review: APPROVED
Re-reviewed exact head
7c940756fd0d0d5306dbbb539377d8179cb3803f. The author clarified the comparison command and confirmsANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_LAYER_KHRONOS_validationwere set on both baseline and change; all 80 focused tests passed 3/3 on each arm with 136 RTX 4070 Ti device selections and no layer-missing warning. The functional review remains clean:RegisterListpreserves offset order and values, expands only at queue-state boundaries, and float-mode reads avoid expansion. Windows data includes one transient unrelated submission-progress failure followed by 10/10 passes. Eligibility, conventions, intake, labels, and report are green; product jobs are skipped by policy. No blocking issue remains.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:53:18Z.
Review: DISMISSED
Reviewed current head
7c940756fd0d0d5306dbbb539377d8179cb3803fand refreshed the dependency state. The description says this branch contains #10685 commit4f15f29b42and is stacked on #10685, while that PR is still OPEN at the exact commit and this branch listsDepends on: none. CONTRIBUTING.md requires a PR that needs another one first to name it on the checklist and requires overlapping PR merge order to be declared. Please change the checklist toDepends on: #10685(and keep the branch based on that PR until it lands); otherwise reviewers and merge automation can treat this stacked change as independently mergeable. The code review and focused Vulkan baseline/candidate evidence remain as in my prior approval; this request is only for the contradictory dependency metadata.