AGC: CPU SW_64KB_R_X color layout drops cross-block XOR coordinate bits at 64/128 bpp #3475
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Amoenus on 2026-10-11T11:12:03Z.
Summary
ColorTargetLayout evaluates XOR equations using coordinates modulo the block dimensions. For SW_64KB_R_X at64/128bpp, the existing equations also use higher coordinate bits in their in-block pipe XOR. Dropping those bits makes CPU color offsets disagree with compiled AMD addrlib and with full-coordinate evaluation of AnyPS5's own existing equations, even when pipeBankXor=0. CPU color Tile/Detile and transfers share this offset routine, so a roundtrip with the same routine can pass without validating memory placement.
This is a source-model consistency defect; PS5 hardware/render equivalence and a title hitting these particular cases have not been measured. It was discovered while strengthening the independent validation for #2970 using our PPSA99902 dump as a broader compatibility target; that title's confirmed missing mode is D_X, not evidence that it executes these R_X cases. The separate arbitrary column-bit XOR discrepancy is reported on PR1735.
Revision / environment
74981fabe1production ColorTargetLayout.cpp/header, Git blobsb4deb5dda8/8c492a1a02. These files and TextureSwizzleEquations.hpp are unchanged through fetched main0f863c102207dae4b77b1a2bad16c3aedec34691.Minimal reproduction / expected offsets
Using AgcDriver::Graphics and the unchanged production source:
The independent API calls are Addr2ComputeSurfaceInfo followed by Addr2ComputeSurfaceAddrFromCoord, SW_64KB_R_X, the geometry above, bpp=64/128, pipeBankXor=0. Supply unalignedWidth/Height, numSlices/numMipLevels/numSamples/numFrags=1 and x/y as shown; compare output.addr and bitPosition=0.
Cause and controlled correction
ColorTargetLayout::offset on the pinned revision uses xOffsets[x%blockWidth] and yOffsets[y%blockHeight]. Existing R_X equations at8-byte elements include y-bit6 in address-bit11 while blockHeight=64; at16-byte elements they also include x-bit6 in address-bit10 while blockWidth=64. AMD HwlComputeSurfaceAddrFromCoordTiled evaluates its equation on full x/y, then adds the block index.
Controlled external correction: retained the exact main header, equations, geometry, allocation and XOR handling; changed only the R_X offset path to evaluate the existing equation with full x/y. This is a proposed correction, not a committed/runtime-tested implementation. The equivalent calculation is:
An implementation can preserve the cached fast path and add the higher-coordinate XOR contributions instead. It should keep legal-value semantics separate from the reserved raw-bit question on PR1735.
**Independent before/after:**5element sizes (1/2/4/8/16bytes),7extents (1x1,5x3,33x65,129x67,257x129,1025x513,3840x2160),4legal codes (0,0x0f,0x40,0xcf), boundary/dense-small/sampled-large coordinates: 140 configurations,536,940 address comparisons per run.
Follow-up / duplicate check
Add independently expected64/128bpp offsets across block boundaries (including zero XOR), implement the missing coordinate contribution generally, then exercise color transfers and GPU/CPU interoperability. Main's existing same-layout roundtrips alone are insufficient. All experiments are local/fork-only; no PR created.
Checked existing issues for ColorTargetLayout/SW_64KB_R_X/color block/color coordinate and open PRs mentioning ColorTargetLayout; reviewed related #1734/#1735/#2970. No matching tracked cross-block CPU coordinate defect found. This issue separates it from #2970's missing D64 mode and PR1735's reserved-XOR input question. AI-assisted investigation/validation/report: Codex.
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.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T12:02:05Z.
Fixed by #3482: R_X color offsets now include the high x/y coordinate contributions, covered by
agc_driver_graphics.