fix(agc): retain cross-block R_X coordinate XORs #3482
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3482"
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 MarcZX10 on 2026-10-11T11:24:23Z.
What
Issue #3475 reports incorrect CPU offsets for SW_64KB_R_X color surfaces at 64 and 128 bits per element. On current
main,core/libs/prx/libSceAgcDriver/Graphics/src/ColorTargetLayout.cpp:152computes the in-block address from only the precomputed low coordinate bits:The R_X equations also XOR higher x/y coordinate bits into the in-block address. The current expression drops those terms when a surface crosses the nominal block width or height.
This change keeps the existing lookup tables for the low bits, then adds the high-coordinate equation contributions for R_X before applying the pipe/bank XOR. It adds fixed-address regressions for both reported cases:
0x10800(67584)0x10400(66560)The issue report attributes these expected values to an independent AMD addrlib comparison. I have not validated these layouts on PS5 hardware.
Tested
Linux, GCC 12.2 Release: built
agc_driver_graphics_tests;ctest --test-dir build-check -R '^agc_driver_graphics$' --output-on-failurepassed. Rebuilding and running the test with currentmain'sColorTargetLayout.cppfailed on the new 64 bpp assertion.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed. Windows and PS5 hardware not tested.Checklist
main(0f863c102207dae4b77b1a2bad16c3aedec34691); no other open PR implements this coordinate correctionNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:41:16Z.
Review: CHANGES_REQUESTED
Thanks for the fix. One bug remains:
ColorTargetLayout.cpp:159:inBlock |= (parity(coordinates) << bit)must be^=.inBlockalready holds the low-coordinate contribution to that bit (fromxOffsets/yOffsets), and the high-coordinate parity has to be XORed into it, not ORed. Evaluating the existingkTextureSwizzleEquationsentry on full x/y as a reference, the PR disagrees on 12288 of 73728 coordinates in a 3x3-block 8-byte surface and 11264 on a 16-byte one. For example, 8 bytes at (32, 64): the PR returns0x800, the full equation gives0x0(same at 16 bytes, (32, 64)).tests/ColorTargetLayout.cpp:56-57: both new cases pass with|=because the low part of the affected bit is 0 there. Please add cases where the low and high contributions are both 1 (e.g. (32, 64) at 8 bytes and 16 bytes) with expected values from addrlib, or at least from the full-coordinate evaluation of the equation.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T11:49:38Z.
Correction: my previous comment was mangled by shell interpolation. The code and tests are correct; the new
(32, 64)regression cases assert fullOffset()values, including their row-block bases:0x10000(8-byte elements) and0x30000(16-byte elements). The in-block equation result for both overlap cases is0.Commit
8a390b06dchanges the high-coordinate combination to XOR and adds these cases. Rebuilt and ranagc_driver_graphics_tests, the convention checker, andgit diff --check; all pass. The negative control with|=fails on the new assertion.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T12:01:59Z.
Review: APPROVED
Checked the XOR fix against the full-coordinate evaluation of the existing
{27,8}/{27,16}equations: the (0,64), (64,0) and overlapping (32,64) cases match the new assertions.agc_driver_graphicspasses on the PR merged onto main and fails without the change. Merging.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-11T12:06:14Z.
Independent source-reference verification of merged #3482 (2026-10-11)
Rebuilt the unchanged merged production ColorTargetLayout.cpp/.hpp and TextureSwizzleEquations.hpp from main2220effbe42c850d7f8df56dbac52e3cdea54009 (PR head8a390b06df02bf576a15d9c66d9b64949b7abdb1), using our existing independent AMD PAL AddrLib reference pinned atc5e800072a32f68b6ccc4422936d96167c6e0728. Rechecked all42 reference source files' SHA256/Git blobs before running. No substitute implementation or patch to the merged production code.
5/5 runs:140 configurations,536,940 byte-address checks per run, zero differences, including geometry. Five element sizes1/2/4/8/16bytes; seven extents1x1,5x3,33x65,129x67,257x129,1025x513,3840x2160; four legal16pipe XOR codes0/0x0f/0x40/0xcf. This covers both minimal8/16byte cross-block witnesses and overlapping coordinate contributions. The prior unchanged-main audit differed in95,156 of these536,940 checks; this merged version now matches the source reference throughout that same matrix.
Configuration is syntheticGFX10.1 non-RB+ family0x8f/revision0x82,GB_ADDR_CONFIG0x00100044,16pipes/256B; single mip/slice. This is CPU source-consistency validation, not PS5 hardware measurement, full repository-suite validation, native GPU interoperability or evidence that this particular title reaches the affected coordinates. Those broader claims are not made.
As a separation control, the independent1x1 arbitrary-XOR origin audit still has25/45differences, exactly as before: reserved column-bit handling remains a distinct unsettled input-contract question discussed on #1735. No XOR-mask change was needed to fix #3475. Pinned AMD source. Our game/integration remains pinned atforkd8fd7c7/main0f863 for the completed MSAA capture; it has not yet been rebased onto this merge. The upstream fix will be retained during that refresh rather than duplicated. AI-assisted verification/report: Codex.