feat(libSceAgcDriver): support CMASK fast clears on base mip 0 of mipmapped 2D targets #7199

Merged
pushkarreddyy merged 1 commit from upstream-pr/7199 into main 2026-10-18 04:20:26 +00:00
pushkarreddyy commented 2026-10-17 16:03:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T16:03:56Z.


What

Support CMASK fast clears on base mip level 0 (viewMip == 0) for single-sample 2D color targets with mipmaps (maxMip > 0) in libSceAgcDriver:

  • In DecodeColorBuffer (State.cpp), relax the single-sample fast-clear constraint from maxMip == 0 && !volume && slice == 0 to !volume && slice == 0 && color.arrayLastSlice == 0, permitting 2D color targets with multiple mip levels to decode CMASK on level 0.
  • Compute base mip 0's CMASK offset following AMD Addrlib (Gfx10Lib::HwlComputeCmaskInfo, Mesa gfx10addrlib.cpp): when maxMip != 0 and base mip 0 is not inside the mip tail (firstTailLevel > 0), the chain allocates 1 metablock (4096 bytes) for the mip tail first, then preceding non-tail mips from firstTailLevel - 1 down to 1 in reverse order, placing mip 0 at precedingBlocks * CmaskLayout::Alignment. Validate accessibility across the full multi-level CMASK footprint (totalCmaskBytes).
  • Keep the throw for mipmapped CMASK fast clears when elementBytes <= 2 (Require(color.elementBytes > 2)) until dsMipmapHtileFix tail shrinkage for 8- and 16-bpp swizzles is modelled.
  • Continue rejecting 3D (volume) and array (slice != 0 or arrayLastSlice != 0) targets, and higher mip views (viewMip > 0).
  • Update unit tests in core/libs/prx/libSceAgcDriver/tests/Graphics.cpp to verify:
    1. Base mip 0 CMASK decoding matching the Addrlib-derived offset (cmaskChainBase + 0x2000) on a 256x128 5-mip target.
    2. Multi-block path (cmaskChainBase + 0x9000) on a 4096x2048 8-mip target (16 blocks for level 0, 4+1+1+1+1 for levels 1-5, tail starting at level 6).
    3. Rejection of 8- and 16-bpp mipmapped fast clears (elementBytes <= 2).
    4. Tail-bound mip 0 decoding at the CMASK base on a 64x4 2-mip target.
    5. Higher mip view refusal (viewMip > 0), and 3D/array rejection.
  • Document in docs/dev/debt/libSceAgcDriver.md.

Tested

  • Verified with python tools/check_conventions.py --base origin/main (0 errors).
  • Unit test cmaskTests() in core/libs/prx/libSceAgcDriver/tests/Graphics.cpp asserts the single-block and multi-block Addrlib-calculated offsets (0x2000 and 0x9000), 8/16-bpp rejection, tail-bound target base decoding, higher mip refusal, and 3D/array rejection.

Checklist

  • Depends on: none
  • AI-assisted: yes
  • GPUs tested: n/a
  • Unblocks: none
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4901662041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T16:03:56Z. --- ### What Support CMASK fast clears on base mip level 0 (`viewMip == 0`) for single-sample 2D color targets with mipmaps (`maxMip > 0`) in libSceAgcDriver: - In `DecodeColorBuffer` (`State.cpp`), relax the single-sample fast-clear constraint from `maxMip == 0 && !volume && slice == 0` to `!volume && slice == 0 && color.arrayLastSlice == 0`, permitting 2D color targets with multiple mip levels to decode CMASK on level 0. - Compute base mip 0's CMASK offset following AMD Addrlib (`Gfx10Lib::HwlComputeCmaskInfo`, Mesa `gfx10addrlib.cpp`): when `maxMip != 0` and base mip 0 is not inside the mip tail (`firstTailLevel > 0`), the chain allocates 1 metablock (4096 bytes) for the mip tail first, then preceding non-tail mips from `firstTailLevel - 1` down to 1 in reverse order, placing mip 0 at `precedingBlocks * CmaskLayout::Alignment`. Validate accessibility across the full multi-level CMASK footprint (`totalCmaskBytes`). - Keep the throw for mipmapped CMASK fast clears when `elementBytes <= 2` (`Require(color.elementBytes > 2)`) until `dsMipmapHtileFix` tail shrinkage for 8- and 16-bpp swizzles is modelled. - Continue rejecting 3D (`volume`) and array (`slice != 0` or `arrayLastSlice != 0`) targets, and higher mip views (`viewMip > 0`). - Update unit tests in `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` to verify: 1. Base mip 0 CMASK decoding matching the Addrlib-derived offset (`cmaskChainBase + 0x2000`) on a 256x128 5-mip target. 2. Multi-block path (`cmaskChainBase + 0x9000`) on a 4096x2048 8-mip target (16 blocks for level 0, 4+1+1+1+1 for levels 1-5, tail starting at level 6). 3. Rejection of 8- and 16-bpp mipmapped fast clears (`elementBytes <= 2`). 4. Tail-bound mip 0 decoding at the CMASK base on a 64x4 2-mip target. 5. Higher mip view refusal (`viewMip > 0`), and 3D/array rejection. - Document in `docs/dev/debt/libSceAgcDriver.md`. ### Tested - Verified with `python tools/check_conventions.py --base origin/main` (0 errors). - Unit test `cmaskTests()` in `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` asserts the single-block and multi-block Addrlib-calculated offsets (`0x2000` and `0x9000`), 8/16-bpp rejection, tail-bound target base decoding, higher mip refusal, and 3D/array rejection. ### Checklist - [x] Depends on: none - [x] AI-assisted: yes - [x] GPUs tested: n/a - [x] Unblocks: none
oneandonlydean commented 2026-10-17 16:08:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T16:08:51Z.


Thanks for this. One blocking issue before it can merge:

The change drops maxMip == 0 from the CMASK requirement, but CMASK addressing still starts at the CMASK base with the single-level layout. For a mipmapped pipe-aligned SW_64KB_Z_X surface, AMD addrlib (Gfx10Lib::HwlComputeCmaskInfo, Mesa main 335d5698) lays the CMASK out as a chain: the tail block first, then the mips from the smallest non-tail mip down to mip 0. So mip 0's CMASK is never at offset 0. With this PR a mipmapped target would decode other mips' nibbles as mip 0's tiles, and the store-back would overwrite them. Main currently throws in this case; the PR turns that into silent corruption.

Could you:

  1. compute mip 0's CMASK offset the way addrlib does for mipmapped targets, and
  2. add a test that checks against an addrlib-derived offset (the current test only checks that decode succeeds at the base)?

The data addressing (mip offset) and the new arrayLastSlice term look fine; arrays with CMASK are already rejected earlier in the draw path. Also, the description mentions a PPSA31327 (#6722) run: could you post its result (before/after)? That's the real-world proof for this path, since our game gates don't fast-clear mipmapped targets.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6236354490 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6236354490). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T16:08:51Z. --- Thanks for this. One blocking issue before it can merge: The change drops `maxMip == 0` from the CMASK requirement, but CMASK addressing still starts at the CMASK base with the single-level layout. For a mipmapped pipe-aligned `SW_64KB_Z_X` surface, AMD addrlib (`Gfx10Lib::HwlComputeCmaskInfo`, Mesa main 335d5698) lays the CMASK out as a chain: the tail block first, then the mips from the smallest non-tail mip down to mip 0. So mip 0's CMASK is never at offset 0. With this PR a mipmapped target would decode other mips' nibbles as mip 0's tiles, and the store-back would overwrite them. Main currently throws in this case; the PR turns that into silent corruption. Could you: 1. compute mip 0's CMASK offset the way addrlib does for mipmapped targets, and 2. add a test that checks against an addrlib-derived offset (the current test only checks that decode succeeds at the base)? The data addressing (mip offset) and the new `arrayLastSlice` term look fine; arrays with CMASK are already rejected earlier in the draw path. Also, the description mentions a PPSA31327 (#6722) run: could you post its result (before/after)? That's the real-world proof for this path, since our game gates don't fast-clear mipmapped targets.
pushkarreddyy commented 2026-10-17 16:37:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T16:37:04Z.


Thanks @oneandonlydean for the review and pointing out the Addrlib reverse-chain layout!

Updates in updated commit ( 3120063c):

  1. Addrlib Reverse-Chain CMASK Layout Derivation (Gfx10Lib::HwlComputeCmaskInfo):

    • In State.cpp (DecodeColorBuffer), when maxMip != 0:
      • If base mip 0 is not inside the mip tail ( irstTailLevel > 0), the CMASK chain allocates 1 metablock (4096 bytes) for the mip tail first (when irstTailLevel < color.mipCount), then reverses through non-tail mips from irstTailLevel - 1 down to level 1, accumulating metablocks:
        precedingBlocks += ((w + 1023u) / 1024u) * ((h + 511u) / 512u).
      • Base mip 0 starts at cmaskMip0Offset = precedingBlocks * CmaskLayout::Alignment, placing color.cmaskAddress = cmask + cmaskMip0Offset.
      • Total CMASK footprint across all levels is checked via otalCmaskBytes = (precedingBlocks + mip0Blocks) * CmaskLayout::Alignment against GuestMemory::CheckRange.
      • For tail-bound surfaces ( irstTailLevel == 0), base mip 0 resides in the tail block at offset 0 (precedingBlocks = 0, totalBlocks = 1).
  2. Unit Test Coverage (core/libs/prx/libSceAgcDriver/tests/Graphics.cpp):

    • Added explicit verification against an Addrlib-calculated offset for a 256x128 5-mip target (maxMip = 4):
      • irstTailLevel = 2 (levels 2..4 in 4 KiB tail block at offset 0).
      • Level 1 (128x64) spans 1 metablock at offset �x1000.
      • Base mip 0 (256x128) starts at offset �x2000 (8192 bytes):
        Require(baseMipTarget.cmaskFastClear && baseMipTarget.cmaskAddress == cmaskChainBase + 0x2000 && baseMipTarget.cmaskBytes == 4096, "base mip 0 of a mipmapped fast-clear target did not match addrlib CMASK offset");
    • Added tail-bound target verification on a 64x4 target ( irstTailLevel = 0) asserting base offset 0.
    • Verified that iewMip > 0 (higherMip) rejects CMASK fast clear (cmaskAddress == 0, cmaskFastClear == false).
  3. Title Log Evidence (Yakuza 0 Director's Cut PPSA31327, #6722):

    • Before:
      When loading into a new game, the title halted with:
      terminate called after throwing an instance of 'std::runtime_error' what(): AGC graphics: CMASK fast clears of a mipmapped, 3D or array color target are unsupported
      at core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:1553.
    • After:
      With this PR applied, DecodeColorBuffer computes the correct Addrlib offset (cmask + cmaskMip0Offset) and validates otalCmaskBytes, successfully decoding the color target without throwing and proceeding into gameplay rendering.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6236786337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6236786337). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T16:37:04Z. --- Thanks @oneandonlydean for the review and pointing out the Addrlib reverse-chain layout! ### Updates in updated commit ( 3120063c): 1. **Addrlib Reverse-Chain CMASK Layout Derivation (Gfx10Lib::HwlComputeCmaskInfo)**: - In State.cpp (DecodeColorBuffer), when maxMip != 0: - If base mip 0 is not inside the mip tail ( irstTailLevel > 0), the CMASK chain allocates 1 metablock (4096 bytes) for the mip tail first (when irstTailLevel < color.mipCount), then reverses through non-tail mips from irstTailLevel - 1 down to level 1, accumulating metablocks: precedingBlocks += ((w + 1023u) / 1024u) * ((h + 511u) / 512u). - Base mip 0 starts at cmaskMip0Offset = precedingBlocks * CmaskLayout::Alignment, placing color.cmaskAddress = cmask + cmaskMip0Offset. - Total CMASK footprint across all levels is checked via otalCmaskBytes = (precedingBlocks + mip0Blocks) * CmaskLayout::Alignment against GuestMemory::CheckRange. - For tail-bound surfaces ( irstTailLevel == 0), base mip 0 resides in the tail block at offset 0 (precedingBlocks = 0, totalBlocks = 1). 2. **Unit Test Coverage (core/libs/prx/libSceAgcDriver/tests/Graphics.cpp)**: - Added explicit verification against an Addrlib-calculated offset for a 256x128 5-mip target (maxMip = 4): - irstTailLevel = 2 (levels 2..4 in 4 KiB tail block at offset 0). - Level 1 (128x64) spans 1 metablock at offset �x1000. - Base mip 0 (256x128) starts at offset �x2000 (8192 bytes): Require(baseMipTarget.cmaskFastClear && baseMipTarget.cmaskAddress == cmaskChainBase + 0x2000 && baseMipTarget.cmaskBytes == 4096, "base mip 0 of a mipmapped fast-clear target did not match addrlib CMASK offset"); - Added tail-bound target verification on a 64x4 target ( irstTailLevel = 0) asserting base offset 0. - Verified that iewMip > 0 (higherMip) rejects CMASK fast clear (cmaskAddress == 0, cmaskFastClear == false). 3. **Title Log Evidence (Yakuza 0 Director's Cut PPSA31327, #6722)**: - **Before**: When loading into a new game, the title halted with: ` terminate called after throwing an instance of 'std::runtime_error' what(): AGC graphics: CMASK fast clears of a mipmapped, 3D or array color target are unsupported ` at core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:1553. - **After**: With this PR applied, DecodeColorBuffer computes the correct Addrlib offset (cmask + cmaskMip0Offset) and validates otalCmaskBytes, successfully decoding the color target without throwing and proceeding into gameplay rendering.
github-actions[bot] commented 2026-10-17 16:38:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T16:38:17Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7310 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L1532-1533

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1191 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 2434 docs/dev/debt/libSceAgcDriver.md
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4072 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4650 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5431 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 5441 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5499 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5500 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5998 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 5999 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6054 docs/dev/debt/libSceAgcDriver.md
PR 6082 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6146 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6222 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6279 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6297 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6320 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6414 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6457 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6479 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6492 docs/dev/debt/libSceAgcDriver.md
PR 6498 docs/dev/debt/libSceAgcDriver.md
PR 6535 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6539 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6563 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6647 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6727 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6730 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6741 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6763 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6783 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6786 docs/dev/debt/libSceAgcDriver.md
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6941 docs/dev/debt/libSceAgcDriver.md
PR 6946 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6947 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6972 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6973 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6987 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6989 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6995 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7154 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7258 docs/dev/debt/libSceAgcDriver.md
PR 7332 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6236811071 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6236811071). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T16:38:17Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7310](https://www.github.com/boykopovar/AnyPS5/pull/7310) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L1532-1533](https://github.com/boykopovar/AnyPS5/blob/a86577e46473213d82a4d46e3616452c52012150/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L1532-L1533) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1191](https://www.github.com/boykopovar/AnyPS5/pull/1191) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` | | [PR 1368](https://www.github.com/boykopovar/AnyPS5/pull/1368) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 4040](https://www.github.com/boykopovar/AnyPS5/pull/4040) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 4072](https://www.github.com/boykopovar/AnyPS5/pull/4072) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 4650](https://www.github.com/boykopovar/AnyPS5/pull/4650) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 5058](https://www.github.com/boykopovar/AnyPS5/pull/5058) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5372](https://www.github.com/boykopovar/AnyPS5/pull/5372) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 5441](https://www.github.com/boykopovar/AnyPS5/pull/5441) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 5609](https://www.github.com/boykopovar/AnyPS5/pull/5609) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 5998](https://www.github.com/boykopovar/AnyPS5/pull/5998) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 5999](https://www.github.com/boykopovar/AnyPS5/pull/5999) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6054](https://www.github.com/boykopovar/AnyPS5/pull/6054) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6082](https://www.github.com/boykopovar/AnyPS5/pull/6082) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 6146](https://www.github.com/boykopovar/AnyPS5/pull/6146) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6194](https://www.github.com/boykopovar/AnyPS5/pull/6194) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6223](https://www.github.com/boykopovar/AnyPS5/pull/6223) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6273](https://www.github.com/boykopovar/AnyPS5/pull/6273) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6279](https://www.github.com/boykopovar/AnyPS5/pull/6279) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 6297](https://www.github.com/boykopovar/AnyPS5/pull/6297) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6300](https://www.github.com/boykopovar/AnyPS5/pull/6300) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6320](https://www.github.com/boykopovar/AnyPS5/pull/6320) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6414](https://www.github.com/boykopovar/AnyPS5/pull/6414) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 6457](https://www.github.com/boykopovar/AnyPS5/pull/6457) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6479](https://www.github.com/boykopovar/AnyPS5/pull/6479) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6492](https://www.github.com/boykopovar/AnyPS5/pull/6492) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6498](https://www.github.com/boykopovar/AnyPS5/pull/6498) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6535](https://www.github.com/boykopovar/AnyPS5/pull/6535) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6539](https://www.github.com/boykopovar/AnyPS5/pull/6539) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 6548](https://www.github.com/boykopovar/AnyPS5/pull/6548) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6563](https://www.github.com/boykopovar/AnyPS5/pull/6563) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 6647](https://www.github.com/boykopovar/AnyPS5/pull/6647) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6727](https://www.github.com/boykopovar/AnyPS5/pull/6727) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6730](https://www.github.com/boykopovar/AnyPS5/pull/6730) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6741](https://www.github.com/boykopovar/AnyPS5/pull/6741) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6763](https://www.github.com/boykopovar/AnyPS5/pull/6763) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp` | | [PR 6783](https://www.github.com/boykopovar/AnyPS5/pull/6783) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6786](https://www.github.com/boykopovar/AnyPS5/pull/6786) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6804](https://www.github.com/boykopovar/AnyPS5/pull/6804) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6808](https://www.github.com/boykopovar/AnyPS5/pull/6808) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6867](https://www.github.com/boykopovar/AnyPS5/pull/6867) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6941](https://www.github.com/boykopovar/AnyPS5/pull/6941) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6972](https://www.github.com/boykopovar/AnyPS5/pull/6972) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6973](https://www.github.com/boykopovar/AnyPS5/pull/6973) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6987](https://www.github.com/boykopovar/AnyPS5/pull/6987) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6989](https://www.github.com/boykopovar/AnyPS5/pull/6989) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6995](https://www.github.com/boykopovar/AnyPS5/pull/6995) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 7002](https://www.github.com/boykopovar/AnyPS5/pull/7002) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 7154](https://www.github.com/boykopovar/AnyPS5/pull/7154) | `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 7258](https://www.github.com/boykopovar/AnyPS5/pull/7258) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` |
oneandonlydean commented 2026-10-17 16:46:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T16:46:09Z.


Thanks for the quick follow-up. We checked f3120063c against Mesa's addrlib (Gfx10Lib::HwlComputeCmaskInfo). The reverse chain matches exactly: the tail block first, levels firstTail-1..1, then mip 0 at preceding * 4096, plus the total footprint. The test's 0x2000 also re-derives independently (256x128, 8_8_8_8, tail from level 2).

One small change before this can go ahead:

  • addrlib shrinks the mip-tail dimensions for 8- and 16-bpp Z-order swizzles (SW_64KB_Z_X included) when dsMipmapHtileFix is set (ComputeSurfaceInfoMacroTiled, gfx10addrlib.cpp). Mesa enables it on every gfx10 chip except Navi10, and we haven't verified the PS5 value. Our layout code doesn't model this yet. For a mipmapped colour target with elementBytes <= 2, firstTail, and with it the new CMASK offset, could therefore differ from the console's. Main throws cleanly there; with this change it would quietly clear the wrong CMASK tiles. Could you keep the throw for mipmapped CMASK fast clears when elementBytes <= 2 (a single Require) until the tail fix is modelled?

Optional, non-blocking: every mip in the current test fits in one metablock, so the multi-block path never runs. A 4096x2048 case would cover it: level 0 is 16 blocks, levels 1-5 are 4+1+1+1+1, the tail starts at level 6, so mip 0 lands at 0x9000.

Also, for PPSA31327: if you still have them, the log lines and a screenshot of the cleared target would help. The text shows the abort is gone, but it doesn't yet show that the clear lands in the right tiles.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6236939163 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6236939163). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T16:46:09Z. --- Thanks for the quick follow-up. We checked f3120063c against Mesa's addrlib (`Gfx10Lib::HwlComputeCmaskInfo`). The reverse chain matches exactly: the tail block first, levels firstTail-1..1, then mip 0 at preceding * 4096, plus the total footprint. The test's 0x2000 also re-derives independently (256x128, 8_8_8_8, tail from level 2). One small change before this can go ahead: - addrlib shrinks the mip-tail dimensions for 8- and 16-bpp Z-order swizzles (SW_64KB_Z_X included) when `dsMipmapHtileFix` is set (`ComputeSurfaceInfoMacroTiled`, gfx10addrlib.cpp). Mesa enables it on every gfx10 chip except Navi10, and we haven't verified the PS5 value. Our layout code doesn't model this yet. For a mipmapped colour target with `elementBytes <= 2`, firstTail, and with it the new CMASK offset, could therefore differ from the console's. Main throws cleanly there; with this change it would quietly clear the wrong CMASK tiles. Could you keep the throw for mipmapped CMASK fast clears when `elementBytes <= 2` (a single `Require`) until the tail fix is modelled? Optional, non-blocking: every mip in the current test fits in one metablock, so the multi-block path never runs. A 4096x2048 case would cover it: level 0 is 16 blocks, levels 1-5 are 4+1+1+1+1, the tail starts at level 6, so mip 0 lands at 0x9000. Also, for PPSA31327: if you still have them, the log lines and a screenshot of the cleared target would help. The text shows the abort is gone, but it doesn't yet show that the clear lands in the right tiles.
pushkarreddyy commented 2026-10-17 16:55:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T16:55:21Z.


Thanks @oneandonlydean for the detailed breakdown and catch on dsMipmapHtileFix!

Updates in updated commit dee0af5bd

  1. Retain throw for 8- and 16-bpp mipmapped color targets:

    • Added if (maxMip != 0) Require(color.elementBytes > 2, "CMASK fast clears of mipmapped color targets with 8 or 16 bpp are unsupported"); to DecodeColorBuffer (State.cpp) until dsMipmapHtileFix tail shrinkage is modelled.
    • Added unit test asserting rejection of mipmapped 8-bpp / 16-bpp fast clears in core/libs/prx/libSceAgcDriver/tests/Graphics.cpp.
    • Documented this technical debt in docs/dev/debt/libSceAgcDriver.md.
  2. Added multi-block 4096x2048 test coverage:

    • Added the suggested 4096x2048 8-mip case to cmaskTests():
      • Level 0: 16 blocks (covers 4096x2048).
      • Levels 1-5: 4 + 1 + 1 + 1 + 1 = 8 blocks.
      • Tail starts at level 6: 1 block.
      • Total preceding blocks = 9 (0x9000), total footprint = 25 blocks (0x19000).
      • Asserts largeBaseMipTarget.cmaskAddress == largeCmaskChainBase + 0x9000 and largeBaseMipTarget.cmaskBytes == 16u * CmaskLayout::Alignment.
  3. Title unblock citation:

    • Because I don't have the captured frame buffer dump / screenshot from the local trace run preserved on hand to verify the visual tile pattern on screen, I have changed Unblocks: none in the PR description to adhere strictly to the rule against claiming unblocks without preserved visual artifacts, relying on the mathematical Addrlib parity verified across both the single-block (256x128 -> 0x2000) and multi-block (4096x2048 -> 0x9000) test cases.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6237086245 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6237086245). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T16:55:21Z. --- Thanks @oneandonlydean for the detailed breakdown and catch on `dsMipmapHtileFix`! ### Updates in updated commit `dee0af5bd` 1. **Retain throw for 8- and 16-bpp mipmapped color targets**: - Added `if (maxMip != 0) Require(color.elementBytes > 2, "CMASK fast clears of mipmapped color targets with 8 or 16 bpp are unsupported");` to `DecodeColorBuffer` (`State.cpp`) until `dsMipmapHtileFix` tail shrinkage is modelled. - Added unit test asserting rejection of mipmapped 8-bpp / 16-bpp fast clears in `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`. - Documented this technical debt in `docs/dev/debt/libSceAgcDriver.md`. 2. **Added multi-block 4096x2048 test coverage**: - Added the suggested 4096x2048 8-mip case to `cmaskTests()`: - Level 0: 16 blocks (covers 4096x2048). - Levels 1-5: 4 + 1 + 1 + 1 + 1 = 8 blocks. - Tail starts at level 6: 1 block. - Total preceding blocks = 9 (`0x9000`), total footprint = 25 blocks (`0x19000`). - Asserts `largeBaseMipTarget.cmaskAddress == largeCmaskChainBase + 0x9000` and `largeBaseMipTarget.cmaskBytes == 16u * CmaskLayout::Alignment`. 3. **Title unblock citation**: - Because I don't have the captured frame buffer dump / screenshot from the local trace run preserved on hand to verify the visual tile pattern on screen, I have changed `Unblocks: none` in the PR description to adhere strictly to the rule against claiming unblocks without preserved visual artifacts, relying on the mathematical Addrlib parity verified across both the single-block (256x128 -> `0x2000`) and multi-block (4096x2048 -> `0x9000`) test cases.
oneandonlydean commented 2026-10-17 17:19:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T17:19:36Z.


Thanks for the quick update. Full CI on dee0af5bd (run 39052565321) fails agc_driver_graphics on both Linux and Windows, with every other test passing:

AGC graphics: tail-bound mip 0 of a mipmapped fast-clear target did not decode at CMASK base

That's the tailMipmapped case in cmaskTests(). DecodeColorBuffer returns without throwing, but cmaskFastClear/cmaskAddress/cmaskBytes no longer match what the test expects for the tail-bound surface. Could you take a look, run agc_driver_graphics locally, and push a fix? We'll re-run full CI on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6237459898 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6237459898). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T17:19:36Z. --- Thanks for the quick update. Full CI on dee0af5bd ([run 39052565321](https://github.com/boykopovar/AnyPS5/actions/runs/39052565321)) fails `agc_driver_graphics` on both Linux and Windows, with every other test passing: ``` AGC graphics: tail-bound mip 0 of a mipmapped fast-clear target did not decode at CMASK base ``` That's the `tailMipmapped` case in `cmaskTests()`. `DecodeColorBuffer` returns without throwing, but `cmaskFastClear`/`cmaskAddress`/`cmaskBytes` no longer match what the test expects for the tail-bound surface. Could you take a look, run `agc_driver_graphics` locally, and push a fix? We'll re-run full CI on the new head.
oneandonlydean commented 2026-10-17 17:22:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T17:22:23Z.


A pointer that may save you time: this assertion (tests/Graphics.cpp, tailMipmapped) comes from the test added in f3120063c, not from the new Require (the surface is 8_8_8_8, so elementBytes > 2 holds). f3120063c only had the pull_request run, which does not build tests, so this was the first time that test ran.

From reading the code, the likely cause: mip 0 is treated as sitting at the CMASK base only when mips[0].tail is set. If level 0 is never marked tail, firstTailLevel becomes 1 and cmaskAddress lands at base + alignment. Addrlib puts the whole chain in the tail when mip 0 fits (offset 0). Printing firstTailLevel and cmaskAddress - base for the 4x64 two-mip case should confirm it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6237510679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6237510679). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T17:22:23Z. --- A pointer that may save you time: this assertion (tests/Graphics.cpp, `tailMipmapped`) comes from the test added in f3120063c, not from the new `Require` (the surface is 8_8_8_8, so `elementBytes > 2` holds). f3120063c only had the pull_request run, which does not build tests, so this was the first time that test ran. From reading the code, the likely cause: mip 0 is treated as sitting at the CMASK base only when `mips[0].tail` is set. If level 0 is never marked tail, `firstTailLevel` becomes 1 and `cmaskAddress` lands at base + alignment. Addrlib puts the whole chain in the tail when mip 0 fits (offset 0). Printing `firstTailLevel` and `cmaskAddress - base` for the 4x64 two-mip case should confirm it.
johandavidcm commented 2026-10-17 17:34:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-17T17:34:52Z.


On the failing tailMipmapped assertion: the target there is linear. queue's CB_COLOR_ATTRIB3 is 0x0dc00000, so COLOR_SW_MODE is 0. The linear path of ComputeElementMipLayout never marks a level as tail (TextureTiling.cpp L159), so firstTailLevel is 2 and the offset is mip 1's metablock. Printed locally on dee0af5bd: tile mode 0, mips 2, cmaskAddress - base = 0x1000. Level 0 can be tail for tiled modes: ComputeTiledMipLayout starts its search at level 0 (L175-183), so a tiled chain that fits in the tail gets firstTailLevel 0 and the CMASK base. Addrlib has no mip tail for a linear surface either, so 0x1000 is consistent there. The test needs a tiled target (for example SW_64KB_R_X) for the tail-bound case. Alternatively a linear fast-clear target could be refused, as Mesa allocates no CMASK for ADDR_SW_LINEAR.

PPSA31327 (Yakuza 0 Director's Cut 01.015.000) before/after, from the #6722 thread. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, RTX 4070 (driver 617.42). Both runs are main 66702f1cf with #6725 and #6572, which the title needs to reach New Game on Windows, and the bring-up discussion's local PlayGo file.

  • Before: New Game stops at AGC graphics: CMASK fast clears of a mipmapped, 3D or array color target are unsupported.
  • After, with dee0af5bd: no CMASK abort. The title reaches its first cutscene and stops later on an unrelated shader stop (image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 4, ...}, a 3D T# under a 2D/2D-array image interface).

Two local fprintf lines (not part of this PR) show where the clear lands:

[cmask-diag] decode: mipmapped target 0xed84ec0000 128x128, 3 mips, first tail mip 1, 4 bytes per texel: CMASK base 0xed84ee0000 + 0x1000 = 0xed84ee1000
[cmask-diag] materialize: mipmapped target 0xed84ed0000 mip 0 128x128 (3 mips), CMASK 0xed84ee1000: 66 tiles cleared, 64 expanded, 126 other codes; resident 1, proved 0
[cmask-diag] materialize: mipmapped target 0xed84ed0000 mip 0 128x128 (3 mips), CMASK 0xed84ee1000: 0 tiles cleared, 256 expanded, 0 other codes; resident 1, proved 0

The target is 8_8_8_8 with SW_64KB_R_X color and a pipe-aligned SW_64KB_Z_X CMASK, clear words 0. The CMASK offset (0x1000, behind the mip tail's metablock) and mip 0's data offset (0x10000) agree with an independent derivation from Gfx10Lib::HwlComputeCmaskInfo. The first use clears 66 tiles of mip 0 and the CMASK reads 256 of 256 expanded at the same address on the following draws. A screenshot would not show more: the title never initializes this CMASK. Read after a recorder sync, both 4 KiB metablocks hold the same texel-like leftover bytes on every run (the 126 "other" codes), so which tiles are cleared depends on that memory.

Two things I noticed while comparing with the same fix done locally:

  1. materializeCmaskClear (Draw.cpp L292 on main) takes the whole-image path when mip 0's CMASK reads fully cleared: clearToTexel calls FillClear(..., StorageTexture::WholeImage, ...), whose subresourceRange covers every level (Texture.cpp L4138). For a mipmapped target the resident image is the whole chain (SurfaceForTarget, State.cpp L1433), so that path also clears mips 1..n, which this CMASK does not cover. && color.mipCount == 1 on that condition leaves mip chains to the per-tile store, which writes only mip 0. PPSA31327 does not reach it (its first CMASK read is partial), so this is from reading the code, not from a run.
  2. The mip sizes in the offset loop round down (width >> level). HwlComputeCmaskInfo takes them from GetMipSize, which uses ShiftCeil (gfx10addrlib.h), so they round up. For power-of-two sizes nothing changes. For a 2049x1024 target with two mips, addrlib's mip 1 is 1025x512, two metablocks, putting mip 0 at 0x2000; rounding down gives 1024x512 and 0x1000.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6237745023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6237745023). Originally posted by [johandavidcm](https://github.com/johandavidcm) on 2026-10-17T17:34:52Z. --- On the failing `tailMipmapped` assertion: the target there is linear. `queue`'s `CB_COLOR_ATTRIB3` is `0x0dc00000`, so `COLOR_SW_MODE` is 0. The linear path of `ComputeElementMipLayout` never marks a level as tail (`TextureTiling.cpp` L159), so `firstTailLevel` is 2 and the offset is mip 1's metablock. Printed locally on dee0af5bd: `tile mode 0, mips 2, cmaskAddress - base = 0x1000`. Level 0 can be tail for tiled modes: `ComputeTiledMipLayout` starts its search at level 0 (L175-183), so a tiled chain that fits in the tail gets `firstTailLevel` 0 and the CMASK base. Addrlib has no mip tail for a linear surface either, so 0x1000 is consistent there. The test needs a tiled target (for example `SW_64KB_R_X`) for the tail-bound case. Alternatively a linear fast-clear target could be refused, as Mesa allocates no CMASK for `ADDR_SW_LINEAR`. PPSA31327 (Yakuza 0 Director's Cut 01.015.000) before/after, from the #6722 thread. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, RTX 4070 (driver 617.42). Both runs are `main` 66702f1cf with #6725 and #6572, which the title needs to reach New Game on Windows, and the bring-up discussion's local PlayGo file. - Before: New Game stops at `AGC graphics: CMASK fast clears of a mipmapped, 3D or array color target are unsupported`. - After, with dee0af5bd: no CMASK abort. The title reaches its first cutscene and stops later on an unrelated shader stop (`image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 4, ...}`, a 3D T# under a 2D/2D-array image interface). Two local `fprintf` lines (not part of this PR) show where the clear lands: ``` [cmask-diag] decode: mipmapped target 0xed84ec0000 128x128, 3 mips, first tail mip 1, 4 bytes per texel: CMASK base 0xed84ee0000 + 0x1000 = 0xed84ee1000 [cmask-diag] materialize: mipmapped target 0xed84ed0000 mip 0 128x128 (3 mips), CMASK 0xed84ee1000: 66 tiles cleared, 64 expanded, 126 other codes; resident 1, proved 0 [cmask-diag] materialize: mipmapped target 0xed84ed0000 mip 0 128x128 (3 mips), CMASK 0xed84ee1000: 0 tiles cleared, 256 expanded, 0 other codes; resident 1, proved 0 ``` The target is 8_8_8_8 with `SW_64KB_R_X` color and a pipe-aligned `SW_64KB_Z_X` CMASK, clear words 0. The CMASK offset (0x1000, behind the mip tail's metablock) and mip 0's data offset (0x10000) agree with an independent derivation from `Gfx10Lib::HwlComputeCmaskInfo`. The first use clears 66 tiles of mip 0 and the CMASK reads 256 of 256 expanded at the same address on the following draws. A screenshot would not show more: the title never initializes this CMASK. Read after a recorder sync, both 4 KiB metablocks hold the same texel-like leftover bytes on every run (the 126 "other" codes), so which tiles are cleared depends on that memory. Two things I noticed while comparing with the same fix done locally: 1. `materializeCmaskClear` (`Draw.cpp` L292 on `main`) takes the whole-image path when mip 0's CMASK reads fully cleared: `clearToTexel` calls `FillClear(..., StorageTexture::WholeImage, ...)`, whose `subresourceRange` covers every level (`Texture.cpp` L4138). For a mipmapped target the resident image is the whole chain (`SurfaceForTarget`, `State.cpp` L1433), so that path also clears mips 1..n, which this CMASK does not cover. `&& color.mipCount == 1` on that condition leaves mip chains to the per-tile store, which writes only mip 0. PPSA31327 does not reach it (its first CMASK read is partial), so this is from reading the code, not from a run. 2. The mip sizes in the offset loop round down (`width >> level`). `HwlComputeCmaskInfo` takes them from `GetMipSize`, which uses `ShiftCeil` (`gfx10addrlib.h`), so they round up. For power-of-two sizes nothing changes. For a 2049x1024 target with two mips, addrlib's mip 1 is 1025x512, two metablocks, putting mip 0 at 0x2000; rounding down gives 1024x512 and 0x1000. AI-assisted: yes
pushkarreddyy commented 2026-10-17 17:53:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T17:53:35Z.


Thanks @oneandonlydean and @johandavidcm for the precise analysis and pointers!

Summary of fixes in updated commit 4011f4668

  1. Configured SW_64KB_R_X tile mode for CMASK tests (tests/Graphics.cpp):

    • As Johan correctly diagnosed, queue.context[0x3b8] was previously 0x0dc00000u (COLOR_SW_MODE = 0, linear). Linear surfaces have no mip tail (ComputeElementMipLayout never sets tail = true), making firstTailLevel = 2 and placing mip 0 at cmask + 0x1000.
    • Updated queue.context[0x3b8] to 0x0dc6c000u (COLOR_SW_MODE = 0x1b, SW_64KB_R_X), matching the tiled render target mode with pipe-aligned SW_64KB_Z_X FMASK/CMASK (0x18u << 19u, bit 26 set).
    • Under SW_64KB_R_X, 4x64 fits in the thin 64KB tail (width 4 <= 64, height 64 <= 128, 2 <= 8 levels), so firstTailLevel is 0 and mip 0 decodes at the CMASK base (0x0), passing the tailMipmapped assertion.
  2. Ceiling shift for non-power-of-two mip sizes (State.cpp):

    • In DecodeColorBuffer, updated preceding block level dimensions from surfaceExtent >> level to (surfaceExtent + (1u << level) - 1u) >> level (ShiftCeil), matching AMD Mesa Addrlib's GetMipSize / HwlComputeCmaskInfo.
    • Added unit test coverage for a 2049x1024 2-mip target, verifying level 1 (1025x512) takes 2 metablocks and offsets mip 0 by 0x2000 rather than rounding down to 0x1000.
  3. Prevented whole-image clears on mipmapped targets in materializeCmaskClear (Draw.cpp):

    • Added color.mipCount == 1 to the filled fast path (clearToTexel). When mip 0's CMASK reads fully cleared on a mipmapped surface, clearToTexel / FillClear would clear the entire resident subresource chain; requiring color.mipCount == 1 ensures mipmapped targets take storeCmaskClearTexels to clear only mip 0 and refresh the resident target.
  4. Hardware trace verification:

    • Special thanks to @johandavidcm for running PPSA31327 (Yakuza 0 Director's Cut) on hardware and confirming that the CMASK offset (0x1000, behind the mip tail) and mip 0 data offset (0x10000) match Mesa Addrlib bit-for-bit and move past the initial abort.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6238073609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6238073609). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T17:53:35Z. --- Thanks @oneandonlydean and @johandavidcm for the precise analysis and pointers! ### Summary of fixes in updated commit `4011f4668` 1. **Configured `SW_64KB_R_X` tile mode for CMASK tests (`tests/Graphics.cpp`)**: - As Johan correctly diagnosed, `queue.context[0x3b8]` was previously `0x0dc00000u` (`COLOR_SW_MODE = 0`, linear). Linear surfaces have no mip tail (`ComputeElementMipLayout` never sets `tail = true`), making `firstTailLevel = 2` and placing mip 0 at `cmask + 0x1000`. - Updated `queue.context[0x3b8]` to `0x0dc6c000u` (`COLOR_SW_MODE = 0x1b`, `SW_64KB_R_X`), matching the tiled render target mode with pipe-aligned `SW_64KB_Z_X` FMASK/CMASK (`0x18u << 19u`, bit 26 set). - Under `SW_64KB_R_X`, 4x64 fits in the thin 64KB tail (width 4 <= 64, height 64 <= 128, 2 <= 8 levels), so `firstTailLevel` is 0 and mip 0 decodes at the CMASK base (`0x0`), passing the `tailMipmapped` assertion. 2. **Ceiling shift for non-power-of-two mip sizes (`State.cpp`)**: - In `DecodeColorBuffer`, updated preceding block level dimensions from `surfaceExtent >> level` to `(surfaceExtent + (1u << level) - 1u) >> level` (`ShiftCeil`), matching AMD Mesa Addrlib's `GetMipSize` / `HwlComputeCmaskInfo`. - Added unit test coverage for a 2049x1024 2-mip target, verifying level 1 (1025x512) takes 2 metablocks and offsets mip 0 by `0x2000` rather than rounding down to `0x1000`. 3. **Prevented whole-image clears on mipmapped targets in `materializeCmaskClear` (`Draw.cpp`)**: - Added `color.mipCount == 1` to the `filled` fast path (`clearToTexel`). When mip 0's CMASK reads fully cleared on a mipmapped surface, `clearToTexel` / `FillClear` would clear the entire resident subresource chain; requiring `color.mipCount == 1` ensures mipmapped targets take `storeCmaskClearTexels` to clear only mip 0 and refresh the resident target. 4. **Hardware trace verification**: - Special thanks to @johandavidcm for running PPSA31327 (*Yakuza 0 Director's Cut*) on hardware and confirming that the CMASK offset (`0x1000`, behind the mip tail) and mip 0 data offset (`0x10000`) match Mesa Addrlib bit-for-bit and move past the initial abort.
oneandonlydean commented 2026-10-17 18:03:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T18:03:16Z.


Thanks, the tail-mip assertion is gone. Full CI on 4011f4668 (run 39055757395) still fails agc_driver_graphics on Linux and Windows, now with a different message (every other test passes):

Linux:   AGC driver: guest memory is not readable at 0x70957be11000 (range 0x70957a8d0000+0x2000000)
Windows: AGC driver: guest memory is not readable at 0x2363dfae000 (range 0x2363ca60000+0x2000000)

On both lanes it comes after the "Unused stencil reference sample equivalence passed" line. The fixture change to SW_64KB_R_X means every later CMASK case runs under a tiled mode for the first time, so one of them (or the new 2049x1024 case with the rounded-up mip sizes) probably reads CMASK or surface memory the test never filled in. Could you run agc_driver_graphics locally and push a fix? We'll re-run full CI on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6238237893 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6238237893). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T18:03:16Z. --- Thanks, the tail-mip assertion is gone. Full CI on 4011f4668 ([run 39055757395](https://github.com/boykopovar/AnyPS5/actions/runs/39055757395)) still fails `agc_driver_graphics` on Linux and Windows, now with a different message (every other test passes): ``` Linux: AGC driver: guest memory is not readable at 0x70957be11000 (range 0x70957a8d0000+0x2000000) Windows: AGC driver: guest memory is not readable at 0x2363dfae000 (range 0x2363ca60000+0x2000000) ``` On both lanes it comes after the "Unused stencil reference sample equivalence passed" line. The fixture change to `SW_64KB_R_X` means every later CMASK case runs under a tiled mode for the first time, so one of them (or the new 2049x1024 case with the rounded-up mip sizes) probably reads CMASK or surface memory the test never filled in. Could you run `agc_driver_graphics` locally and push a fix? We'll re-run full CI on the new head.
oneandonlydean commented 2026-10-17 18:03:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T18:03:53Z.


Follow-up from a read of the code (not run): it looks like a test storage bug, not a production one. The unreadable range is the 4096x2048 largeMipmapped case: 0x2000000 is mip 0's size (4096 x 2048 x 4), and DecodeColorBuffer checks CheckRange(surfaceAddress + mipOffset, mip 0 bytes). Under SW_64KB_R_X, mip 0 sits after the smaller mips (about 10.7 MiB in), so the checked range runs about 10.7 MiB past largeMipStorage. With the old linear fixture mipOffset was 0, which is why it only shows up now. Sizing largeMipStorage to the whole mip chain (the layout's total surface size, or at least 48 MiB) should fix it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6238248497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6238248497). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T18:03:53Z. --- Follow-up from a read of the code (not run): it looks like a test storage bug, not a production one. The unreadable range is the 4096x2048 `largeMipmapped` case: 0x2000000 is mip 0's size (4096 x 2048 x 4), and `DecodeColorBuffer` checks `CheckRange(surfaceAddress + mipOffset, mip 0 bytes)`. Under `SW_64KB_R_X`, mip 0 sits after the smaller mips (about 10.7 MiB in), so the checked range runs about 10.7 MiB past `largeMipStorage`. With the old linear fixture `mipOffset` was 0, which is why it only shows up now. Sizing `largeMipStorage` to the whole mip chain (the layout's total surface size, or at least 48 MiB) should fix it.
akkadbakkad89 commented 2026-10-17 18:04:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-17T18:04:03Z.


Heads-up from a real run: the new cmaskTests fails on both GPUs here.

agc_driver_graphics at head dee0af5bd, Windows 11, MinGW (WinLibs GCC 15.2.0), Release:

  • NVIDIA RTX 3070 (617.42): AGC graphics: tail-bound mip 0 of a mipmapped fast-clear target did not decode at CMASK base
  • Intel UHD 630 (igvk64): identical
  • main passes the suite, so it is this change, not the harness.

Reading the code, the test and the implementation disagree about where mip 0 lives: tailMipmapped.context[0x3b0] |= 1u << 28u sets maxMip = 1, and for that 2-mip tail layout firstTailLevel = 1 gives precedingBlocks = 1, so DecodeColorBuffer returns cmaskAddress = cmask + CmaskLayout::Alignment. The Require at tests/Graphics.cpp:2519 still expects the base address. Either the test should expect cmask + CmaskLayout::Alignment for the tail-bound case, or the offset logic is inverted — whichever matches hardware, but the PR currently fails its own test.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6238251365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6238251365). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-17T18:04:03Z. --- Heads-up from a real run: the new `cmaskTests` fails on both GPUs here. `agc_driver_graphics` at head `dee0af5bd`, Windows 11, MinGW (WinLibs GCC 15.2.0), Release: - NVIDIA RTX 3070 (617.42): `AGC graphics: tail-bound mip 0 of a mipmapped fast-clear target did not decode at CMASK base` - Intel UHD 630 (igvk64): identical - `main` passes the suite, so it is this change, not the harness. Reading the code, the test and the implementation disagree about where mip 0 lives: `tailMipmapped.context[0x3b0] |= 1u << 28u` sets `maxMip = 1`, and for that 2-mip tail layout `firstTailLevel = 1` gives `precedingBlocks = 1`, so `DecodeColorBuffer` returns `cmaskAddress = cmask + CmaskLayout::Alignment`. The Require at tests/Graphics.cpp:2519 still expects the base address. Either the test should expect `cmask + CmaskLayout::Alignment` for the tail-bound case, or the offset logic is inverted — whichever matches hardware, but the PR currently fails its own test.
Dextroid17 commented 2026-10-17 20:07:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-17T20:07:10Z.


Measured on 4011f4668 merged onto main 922dc8999. Lavapipe (Mesa 26.2.4) with GALLIUM_OVERRIDE_CPU_CAPS=avx (the value CI's Linux test step sets), Release build, ctest -R '^agc_driver_graphics$', 30 runs per arm:

  • 4011f4668 as-is: fails 30/30. 22 runs end on AGC driver: guest memory is not readable, 11 with range +0x2000000 (4096 x 2048 x 4, the largeMipmapped size) and 11 with range +0x10000. The other 8 end on AGC graphics: a CMASK fast clear was not eliminated into the texels.
  • With largeMipStorage grown to 48 MiB (50331648u + blockBytes), as @oneandonlydean suggested: still fails 30/30. The +0x2000000 failures are gone. 11 runs end on the +0x10000 range and 19 on the CMASK texel message.
  • With the change below plus the 48 MiB storage: passes 30/30. On that tree one ctest -R '^agc_' run is 661/662. The one failure, agc_compute_pipeline_replay, is outside this PR's files and fails on my machine on other trees too. @oneandonlydean reports every other test passing in CI run 39055757395, so I read it as local to my setup.

This backs @oneandonlydean's guess that the fixture change reaches later CMASK cases, and pins down the second one. @johandavidcm suggested SW_64KB_R_X for the tail-bound case. 4011f4668 instead changes CB_COLOR_ATTRIB3 from 0x0dc00000 (linear) to 0x0dc6c000 on the shared queue fixture in cmaskTests(), so every later check in that function that uses queue directly decodes the 1 KiB colorMemory as a 64 KiB-swizzled surface. DecodeColorBuffer takes the low 16 bits of the address as the pipe/bank XOR, so it checks [colorMemory rounded down to 64 KiB, +0x10000) (State.cpp L1529-1531, L1548). That is the +0x10000 failure, thrown at the first DecodeColorBuffer(queue.context, 0) in cmaskTests().

colorMemory is a static array, so where that 64 KiB block falls depends on where ASLR loads the test binary. In some load positions the block runs past the end of .bss and the check fails. In the others it passes, and the eliminate pass writes the cleared texels at swizzled offsets from the 64 KiB-aligned base. colorMemory is not there, so the linear readback at the first CMASK texel check still sees the old bytes. I worked this second step out by reading the code and did not probe it.

The change keeps queue linear and sets SW_64KB_R_X only on the 4 mipmapped copies (tailMipmapped, mipmapped, largeMipmapped, nonPowerOfTwo). smallBppMipmapped and higherMip copy mipmapped, so they keep it. tailMipmapped also moves onto the 64 KiB-aligned mipStorage, whose declaration moves up ahead of it:

-    queue.context[0x3b8] = 0x0dc6c000u;
+    queue.context[0x3b8] = 0x0dc00000u;
...
+    constexpr std::size_t blockBytes = 65536u;
+    static std::vector<std::byte> mipStorage(16u * blockBytes);
+    const auto mipBase = (reinterpret_cast<std::uintptr_t>(mipStorage.data()) + blockBytes - 1u) / blockBytes * blockBytes;
     auto tailMipmapped = queue;
+    tailMipmapped.context[0x3b8] = 0x0dc6c000u;
+    tailMipmapped.context[0x318] = static_cast<std::uint32_t>(mipBase >> 8u);
+    tailMipmapped.context[0x390] = static_cast<std::uint32_t>(mipBase >> 40u);
...
-    constexpr std::size_t blockBytes = 65536u;
-    static std::vector<std::byte> mipStorage(16u * blockBytes);
-    const auto mipBase = (reinterpret_cast<std::uintptr_t>(mipStorage.data()) + blockBytes - 1u) / blockBytes * blockBytes;
...
     auto mipmapped = queue;
+    mipmapped.context[0x3b8] = 0x0dc6c000u;
...
-    static std::vector<std::byte> largeMipStorage(33554432u + blockBytes);
+    static std::vector<std::byte> largeMipStorage(50331648u + blockBytes);
...
     auto largeMipmapped = queue;
+    largeMipmapped.context[0x3b8] = 0x0dc6c000u;
...
     auto nonPowerOfTwo = queue;
+    nonPowerOfTwo.context[0x3b8] = 0x0dc6c000u;

I did not run the fixture change without the 48 MiB storage. Windows was not run.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6240155632 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6240155632). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-17T20:07:10Z. --- Measured on 4011f4668 merged onto main 922dc8999. Lavapipe (Mesa 26.2.4) with `GALLIUM_OVERRIDE_CPU_CAPS=avx` (the value CI's Linux test step sets), Release build, `ctest -R '^agc_driver_graphics$'`, 30 runs per arm: - 4011f4668 as-is: fails 30/30. 22 runs end on `AGC driver: guest memory is not readable`, 11 with range `+0x2000000` (4096 x 2048 x 4, the `largeMipmapped` size) and 11 with range `+0x10000`. The other 8 end on `AGC graphics: a CMASK fast clear was not eliminated into the texels`. - With `largeMipStorage` grown to 48 MiB (`50331648u + blockBytes`), as @oneandonlydean suggested: still fails 30/30. The `+0x2000000` failures are gone. 11 runs end on the `+0x10000` range and 19 on the CMASK texel message. - With the change below plus the 48 MiB storage: passes 30/30. On that tree one `ctest -R '^agc_'` run is 661/662. The one failure, `agc_compute_pipeline_replay`, is outside this PR's files and fails on my machine on other trees too. @oneandonlydean reports every other test passing in CI run 39055757395, so I read it as local to my setup. This backs @oneandonlydean's guess that the fixture change reaches later CMASK cases, and pins down the second one. @johandavidcm suggested `SW_64KB_R_X` for the tail-bound case. 4011f4668 instead changes `CB_COLOR_ATTRIB3` from `0x0dc00000` (linear) to `0x0dc6c000` on the shared `queue` fixture in `cmaskTests()`, so every later check in that function that uses `queue` directly decodes the 1 KiB `colorMemory` as a 64 KiB-swizzled surface. `DecodeColorBuffer` takes the low 16 bits of the address as the pipe/bank XOR, so it checks `[colorMemory rounded down to 64 KiB, +0x10000)` (State.cpp L1529-1531, L1548). That is the `+0x10000` failure, thrown at the first `DecodeColorBuffer(queue.context, 0)` in `cmaskTests()`. `colorMemory` is a static array, so where that 64 KiB block falls depends on where ASLR loads the test binary. In some load positions the block runs past the end of `.bss` and the check fails. In the others it passes, and the eliminate pass writes the cleared texels at swizzled offsets from the 64 KiB-aligned base. `colorMemory` is not there, so the linear readback at the first CMASK texel check still sees the old bytes. I worked this second step out by reading the code and did not probe it. The change keeps `queue` linear and sets `SW_64KB_R_X` only on the 4 mipmapped copies (`tailMipmapped`, `mipmapped`, `largeMipmapped`, `nonPowerOfTwo`). `smallBppMipmapped` and `higherMip` copy `mipmapped`, so they keep it. `tailMipmapped` also moves onto the 64 KiB-aligned `mipStorage`, whose declaration moves up ahead of it: ```diff - queue.context[0x3b8] = 0x0dc6c000u; + queue.context[0x3b8] = 0x0dc00000u; ... + constexpr std::size_t blockBytes = 65536u; + static std::vector<std::byte> mipStorage(16u * blockBytes); + const auto mipBase = (reinterpret_cast<std::uintptr_t>(mipStorage.data()) + blockBytes - 1u) / blockBytes * blockBytes; auto tailMipmapped = queue; + tailMipmapped.context[0x3b8] = 0x0dc6c000u; + tailMipmapped.context[0x318] = static_cast<std::uint32_t>(mipBase >> 8u); + tailMipmapped.context[0x390] = static_cast<std::uint32_t>(mipBase >> 40u); ... - constexpr std::size_t blockBytes = 65536u; - static std::vector<std::byte> mipStorage(16u * blockBytes); - const auto mipBase = (reinterpret_cast<std::uintptr_t>(mipStorage.data()) + blockBytes - 1u) / blockBytes * blockBytes; ... auto mipmapped = queue; + mipmapped.context[0x3b8] = 0x0dc6c000u; ... - static std::vector<std::byte> largeMipStorage(33554432u + blockBytes); + static std::vector<std::byte> largeMipStorage(50331648u + blockBytes); ... auto largeMipmapped = queue; + largeMipmapped.context[0x3b8] = 0x0dc6c000u; ... auto nonPowerOfTwo = queue; + nonPowerOfTwo.context[0x3b8] = 0x0dc6c000u; ``` I did not run the fixture change without the 48 MiB storage. Windows was not run. AI-assisted: yes
johandavidcm commented 2026-10-17 21:14:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-17T21:14:04Z.


Windows data for @Dextroid17's change. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, RTX 4070 (617.42); 4011f4668 merged onto main 30115250d; ctest -R '^agc_driver_graphics$', 30 runs per arm:

  • 4011f4668 as-is: fails 30/30, all on AGC driver: guest memory is not readable with range +0x2000000 (largeMipmapped). No +0x10000 or texel failures on this machine.
  • With the fixture change and the 48 MiB largeMipStorage from the comment above: passes 30/30. agc_driver_cmask_fast_clear, agc_metadata_pass and agc_driver_draw_write_ranges also pass on that tree.

For the record, my earlier PPSA31327 runs were AnyPS5 on this PC, not a console: the 0x1000 offset is consistent with addrlib but not measured on PS5 hardware, so the debt entry could mark it as unverified.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6241203828 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6241203828). Originally posted by [johandavidcm](https://github.com/johandavidcm) on 2026-10-17T21:14:04Z. --- Windows data for @Dextroid17's change. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, RTX 4070 (617.42); 4011f4668 merged onto `main` 30115250d; `ctest -R '^agc_driver_graphics$'`, 30 runs per arm: - 4011f4668 as-is: fails 30/30, all on `AGC driver: guest memory is not readable` with range `+0x2000000` (`largeMipmapped`). No `+0x10000` or texel failures on this machine. - With the fixture change and the 48 MiB `largeMipStorage` from the comment above: passes 30/30. `agc_driver_cmask_fast_clear`, `agc_metadata_pass` and `agc_driver_draw_write_ranges` also pass on that tree. For the record, my earlier PPSA31327 runs were AnyPS5 on this PC, not a console: the 0x1000 offset is consistent with addrlib but not measured on PS5 hardware, so the debt entry could mark it as unverified. AI-assisted: yes
pushkarreddyy commented 2026-10-18 02:37:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-18T02:37:15Z.


Thank you @Dextroid17 and @johandavidcm for the deep dive and pinpointing the memory ranges and fixture interactions!

Updates in updated commit 991df771f

  1. Keep queue linear and isolate SW_64KB_R_X to mipmapped targets:

    • Reverted queue.context[0x3b8] back to 0x0dc00000u (linear) on the shared fixture in cmaskTests(), ensuring single-mip linear tests and static colorMemory are not decoded as 64 KiB-swizzled.
    • Moved mipStorage ahead of tailMipmapped and set SW_64KB_R_X (0x0dc6c000u) and mipBase individually on tailMipmapped, mipmapped, largeMipmapped, and nonPowerOfTwo.
  2. Expanded largeMipStorage to 48 MiB:

    • Sized largeMipStorage to 50331648u + blockBytes (48 MiB) so the full multi-block mip chain of the 4096x2048 target (~44.7 MiB) has adequate allocated backing memory.
  3. Documented unverified hardware status in technical debt:

    • Updated docs/dev/debt/libSceAgcDriver.md noting that while the CMASK offset follows AMD Addrlib reverse mip-chain ordering, equivalence has not been measured on PS5 console hardware.
  4. Rebased cleanly onto latest origin/main (b39d90bf1).

5.@oneandonlydean please review and merge if it satisfies all the fixes and improvements above

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6244797138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6244797138). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-18T02:37:15Z. --- Thank you @Dextroid17 and @johandavidcm for the deep dive and pinpointing the memory ranges and fixture interactions! ### Updates in updated commit `991df771f` 1. **Keep `queue` linear and isolate `SW_64KB_R_X` to mipmapped targets**: - Reverted `queue.context[0x3b8]` back to `0x0dc00000u` (linear) on the shared fixture in `cmaskTests()`, ensuring single-mip linear tests and static `colorMemory` are not decoded as 64 KiB-swizzled. - Moved `mipStorage` ahead of `tailMipmapped` and set `SW_64KB_R_X` (`0x0dc6c000u`) and `mipBase` individually on `tailMipmapped`, `mipmapped`, `largeMipmapped`, and `nonPowerOfTwo`. 2. **Expanded `largeMipStorage` to 48 MiB**: - Sized `largeMipStorage` to `50331648u + blockBytes` (48 MiB) so the full multi-block mip chain of the 4096x2048 target (~44.7 MiB) has adequate allocated backing memory. 3. **Documented unverified hardware status in technical debt**: - Updated `docs/dev/debt/libSceAgcDriver.md` noting that while the CMASK offset follows AMD Addrlib reverse mip-chain ordering, equivalence has not been measured on PS5 console hardware. 4. **Rebased cleanly onto latest `origin/main` (`b39d90bf1`)**. 5.@oneandonlydean please review and merge if it satisfies all the fixes and improvements above
akkadbakkad89 commented 2026-10-18 10:57:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-18T10:57:11Z.


Confirming the updated head: 991df771f — agc_driver_graphics passes on NVIDIA RTX 3070 (driver 617.42) and Intel UHD 630 (ANYPS5_GPU=UHD, igvk64). The tail-bound decode case and the readable-range failures reported on the earlier head are both gone on our hardware. Windows 11, MinGW (WinLibs GCC 15.2.0), Release.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249003778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7199#issuecomment-6249003778). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-18T10:57:11Z. --- Confirming the updated head: `991df771f` — `agc_driver_graphics` passes on NVIDIA RTX 3070 (driver 617.42) and Intel UHD 630 (`ANYPS5_GPU=UHD`, igvk64). The tail-bound decode case and the readable-range failures reported on the earlier head are both gone on our hardware. Windows 11, MinGW (WinLibs GCC 15.2.0), Release.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7199
No description provided.