feat(agc): implement PM4 CONTEXT_REG_RMW #16878
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16878"
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 AlexWhitehouse on 2026-11-07T19:42:32Z.
What
The PM4 packet
CONTEXT_REG_RMW(type-3 opcode0x51) wasn't in the AGC driver's reference catalogue, so a command buffer containing it failed validation withopcode is not known in the reference. This PR implements it from PAL at c5e80007, the revision my #16184 (COND_WRITE) and #16345 (DMA_DATA) cite:BuildContextRegRmw;The packet has four dwords: the header, the context-register offset (16 bits, upper 16 reserved), a mask and data. Its effect is
new = (old & ~mask) | (data & mask). PAL emits it for colour and depth state ingfx9UniversalCmdBuffer.cpp.SET_CONTEXT_REGis. It must be exactly four dwords, and set reserved offset bits are rejected.SET_CONTEXT_REGuses, so later reads,COPY_DATAfrom the register and the register fingerprint all see it;CONTEXT_REG_RMWentry indocs/dev/debt/libSceAgcDriver.mdrecords the throw for a register with no known value. Of the registers PAL modifies with this packet,CB_COLORn_DCC_CONTROL,DB_COUNT_CONTROLandDB_RESERVED_REG_2have no reset value in the model. Console behaviour is unmeasured, as for the other PM4 packets.Tested
New test:
agc_driver_pm4_context_reg_rmw(also run insideagc_driver_pm4) covers:COPY_DATAreadback of the register;Linux x86-64 (Ubuntu 26.04, GCC 15, Release, lavapipe with
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation):main,agc_driver_pm4_context_reg_rmwfails withopcode is not known in the reference;agc_driver_pm4andagc_driver_pm4_context_reg_rmwpass 2/2;VUID-errors and no missing-layer warning.Windows 11, RTX 3060: (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release, NVIDIA driver 610.88, Vulkan SDK 1.4.363, same validation environment):
agc_driver_pm4*tests pass at6cec611cd0;main'sPm4.cppandPm4Opcodes.hpp,agc_driver_pm4_context_reg_rmwfails withopcode is not known in the reference, andagc_driver_pm4withreference opcode catalog is incomplete;VUID-lines and no missing-layer warning in either run;The PM4 tests validate and execute packets on the CPU and create no Vulkan device. So the validation environment shows nothing breaks, but it doesn't exercise GPU validation.
Mutation check: dropping
& maskon the data fails withCONTEXT_REG_RMW used data outside the mask.python3 tools/check_conventions.py --base origin/main: all checks passed.Overlap: trial merges with my #16184 (COND_WRITE) and #16345 (DMA_DATA GDS controls), which also edit
Pm4.cppandtests/Pm4.cpp, are clean.pr_overlap.pycouldn't compare 12 PRs that conflict withmain, so I read their diffs by hand: #6186, #6188, #6549, #7642, #9893, #10193, #10249, #13928, #13929, #14944, #15136 and #16751. They change other packets, memory handling or test registration; none addsCONTEXT_REG_RMW.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)🤖 Generated with Claude Code