perf(agc): keep a queue's registers in flat arrays instead of a std::map #408
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/408"
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 oneandonlydean on 2026-10-02T21:28:39Z.
What
A queue's register banks (
RegistersinQueueState.hpp: context, shader and user config) were astd::map<std::uint32_t, std::uint32_t>. Every SET_*_REG packet inserted into it, and every draw read dozens of registers back through map lookups: the state decoders, the draw key's range walks, the prechecks. PPSA21564 sends about 350k register packets per 10 s at its title screen. In a profile of my integration branch these packets took about 0.7 s of every 10 s of the graphics queue worker (0.65 s of it CPU time), much of it in the map's node allocations and tree walks.Registersis now a class with a flat value array and a presence bitmap, grown to the highest offset written. It keeps the part of thestd::mapinterface the driver uses, with the same semantics, so no caller changes:contains,count,find,size,empty);lower_boundandupper_boundwalk the present registers in offset order (the bitmap is scanned withstd::countr_zero);emplacedoes not overwrite;insert_or_assignandoperator[]do;eraseclears the presence bit;at()throwsstd::out_of_rangefor an unset register;operator==compares the present (offset, value) pairs.Iterators yield the
std::pair<const std::uint32_t, std::uint32_t>by value, so the existing structured bindings over the banks work unchanged.Test:
testRegisterFileinagc_driver_pm4covers lookup,find,emplacewithout overwrite, assignment,lower_bound/upper_bound, iteration order, copies and==,erase, and the throw on an unset register.Tested
ctest125/125 pass, including the newtestRegisterFileinagc_driver_pm4. That test pins thestd::mapbehaviour the driver relies on, so it also passes when compiled against the old alias; it guards the replacement rather than failing before it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)