feat(agc): fast clear the CMASK of array and layered color targets #11825

Open
oneandonlydean wants to merge 13 commits from upstream-pr/11825 into main
oneandonlydean commented 2026-10-27 08:55:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-27T08:55:34Z.


What

Carried from #8065 by @ArielWolle (closed by the open PR limit, not on its merits).

Fast clears the CMASK of array and layered color targets instead of throwing CMASK fast clears of a 3D or array color target are unsupported. Each layer is cleared through its own CMASK slice: the color address, the CMASK address and the pipe-bank XOR are offset per slice, the CMASK range check covers every layer, and the written-buffer ranges cover all layers. A 3D color target and a slice or array of a mipmapped target still throw, as recorded in the technical debt entry. The per-slice CMASK stride follows Addrlib's slice size and has not been measured on hardware.

The branch is the author's three commits on current main. The layered-draw commits it was stacked on (#7254) are already in main. It still contains the two commits of #7668 (CMASK offset of a color target slice), which is open: if #7668 merges first they apply as empty, and if this merges first #7668 has nothing left to add.

Two commits of ours: a merge of main, and one that moves the pipeline journal's sizeof(State) guard from 912 to 928 bytes, because ColorTarget gained cmaskSlice and cmaskSliceBytes. Both only address a draw's CMASK data; the recipe codec and CanonicalPipelineState copy just the pipeline-relevant color target fields, so no recipe format changes.

Tested

  • Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), on the head merged with main 12686b52de: agc_driver_graphics, agc_driver_cmask_fast_clear, agc_driver_layered_array_color_draw, agc_recorder_cmask and agc_driver_graphics_maps_fallback pass. tools/check_conventions.py with this title and body passed. A full local CI run (cilocal.py ci: configure, build, libs, select_tests.py ctest) on the head ran 2517 tests with 0 failures and 0 errors; 29 were skipped, among them pad_sdl, which skips because this host has a joystick attached (its own message: "SDL sees 1 host joysticks"), so the run's skip check flags it. Not run: Windows, macOS.
  • The author's own run, on Windows 11 (MinGW Release, RTX 3070): the same graphics, CMASK and layered array tests passed.
  • The title that stopped at this error (PPSA34063 #4275) has not been run with this change by us.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (none added)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: #7668 (open, see above)
  • Fixes: none
  • Unblocks: PPSA34063 #4275
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux (our run); NVIDIA GeForce RTX 3070, Windows 11 (the author's run)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5031187401 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11825). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-27T08:55:34Z. --- ### What Carried from #8065 by @ArielWolle (closed by the open PR limit, not on its merits). Fast clears the CMASK of array and layered color targets instead of throwing `CMASK fast clears of a 3D or array color target are unsupported`. Each layer is cleared through its own CMASK slice: the color address, the CMASK address and the pipe-bank XOR are offset per slice, the CMASK range check covers every layer, and the written-buffer ranges cover all layers. A 3D color target and a slice or array of a mipmapped target still throw, as recorded in the technical debt entry. The per-slice CMASK stride follows Addrlib's slice size and has not been measured on hardware. The branch is the author's three commits on current `main`. The layered-draw commits it was stacked on (#7254) are already in `main`. It still contains the two commits of #7668 (CMASK offset of a color target slice), which is open: if #7668 merges first they apply as empty, and if this merges first #7668 has nothing left to add. Two commits of ours: a merge of `main`, and one that moves the pipeline journal's `sizeof(State)` guard from 912 to 928 bytes, because `ColorTarget` gained `cmaskSlice` and `cmaskSliceBytes`. Both only address a draw's CMASK data; the recipe codec and `CanonicalPipelineState` copy just the pipeline-relevant color target fields, so no recipe format changes. ### Tested - Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), on the head merged with `main` 12686b52de: `agc_driver_graphics`, `agc_driver_cmask_fast_clear`, `agc_driver_layered_array_color_draw`, `agc_recorder_cmask` and `agc_driver_graphics_maps_fallback` pass. `tools/check_conventions.py` with this title and body passed. A full local CI run (`cilocal.py ci`: configure, build, `libs`, `select_tests.py ctest`) on the head ran 2517 tests with 0 failures and 0 errors; 29 were skipped, among them `pad_sdl`, which skips because this host has a joystick attached (its own message: "SDL sees 1 host joysticks"), so the run's skip check flags it. Not run: Windows, macOS. - The author's own run, on Windows 11 (MinGW Release, RTX 3070): the same graphics, CMASK and layered array tests passed. - The title that stopped at this error (PPSA34063 #4275) has not been run with this change by us. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file (none added) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: #7668 (open, see above) - [x] Fixes: none - [x] Unblocks: PPSA34063 #4275 - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux (our run); NVIDIA GeForce RTX 3070, Windows 11 (the author's run) - [x] AI-assisted: yes
MarcZX10 commented 2026-10-27 09:24:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T09:24:23Z.

Review: CHANGES_REQUESTED


I reviewed the per-slice CMASK address path, the CPU materialization loop, and the added layout/graphics tests. The Windows product job passes, as do conventions, eligibility, intake, labels, and the progress report. The author reports focused GPU runs and a 2,517-test Linux suite; I could not run those locally because this environment has no usable GPU runtime.

Before approval, the required AGC validation from CONTRIBUTING is still missing from the report: run the same focused tests on main and this change, on the same GPU/machine, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, and ANYPS5_REQUIRE_VULKAN=1 under ctest -V; confirm the requested layer was found and compare any VUID- errors. The current PR body reports results on the change but does not include that paired validation-layer run.

The branch is also based on 5bc84038c490a0427ff272e39e2a1cdf6fdc3c0e, while current upstream main is 801d5b9bc11049e6274daca09d70690bd5b8d0a9. Please update and retest against current main. Finally, the body says this branch includes two commits from still-open #7668 and that either PR could land first; please get the overlapping authors' agreement on landing order and record the dependency accordingly, as CONTRIBUTING requires. I request changes for these validation/readiness gaps, not because I found a confirmed CMASK calculation defect.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5664801520 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11825#pullrequestreview-5664801520). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T09:24:23Z. **Review:** CHANGES_REQUESTED --- I reviewed the per-slice CMASK address path, the CPU materialization loop, and the added layout/graphics tests. The Windows product job passes, as do conventions, eligibility, intake, labels, and the progress report. The author reports focused GPU runs and a 2,517-test Linux suite; I could not run those locally because this environment has no usable GPU runtime. Before approval, the required AGC validation from CONTRIBUTING is still missing from the report: run the same focused tests on `main` and this change, on the same GPU/machine, with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, and `ANYPS5_REQUIRE_VULKAN=1` under `ctest -V`; confirm the requested layer was found and compare any `VUID-` errors. The current PR body reports results on the change but does not include that paired validation-layer run. The branch is also based on `5bc84038c490a0427ff272e39e2a1cdf6fdc3c0e`, while current upstream `main` is `801d5b9bc11049e6274daca09d70690bd5b8d0a9`. Please update and retest against current `main`. Finally, the body says this branch includes two commits from still-open #7668 and that either PR could land first; please get the overlapping authors' agreement on landing order and record the dependency accordingly, as CONTRIBUTING requires. I request changes for these validation/readiness gaps, not because I found a confirmed CMASK calculation defect.
XairRrR commented 2026-10-29 06:11:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T06:11:18Z.

Review: DISMISSED


Reviewed — changes requested

The decode, stride and per-layer split work and the focused tests pass on a clean merge, but the CPU fast-clear path writes the cleared tiles of every slice except slice 0 to the wrong texels, because it drops the slice's pipe-bank XOR.

What I ran

  • PR head: 6e05e5763ebeaab817ad3baca00de8d3c44ac8a6
  • main: 2960e9a6e7e1fc99c4ed180c71495b5eb83464c7
  • Merged tree (main + head, --no-ff, no conflicts): 7b90366b84d107024ba9429f2cbfc408630b2dd7
  • Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), Release, Ninja, in a clean worktree.
git fetch origin main pull/11825/head:refs/review/11825
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/11825
git diff --check origin/main...refs/review/11825
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10 --target agc_driver_graphics_tests agc_driver_cmask_fast_clear_tests agc_driver_layered_array_color_draw_tests agc_driver_recorder_tests
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
  ctest --test-dir build -R '^(agc_driver_graphics|agc_driver_cmask_fast_clear|agc_driver_layered_array_color_draw|agc_recorder_cmask|agc_driver_graphics_maps_fallback)$' -V --output-on-failure
# the same build and ctest command on origin/main, then back to the merged tree
# probe (local only, not pushed): one 8x8 scissored draw vs one CMASK-cleared tile per slice, see Findings

Results

Check Result
Merge into main clean
git diff --check clean
check_conventions.py 0 errors, 1 warning: [debt-length] on the CMASK fast clears entry (2586 characters; it was 1554 on main)
Build of the four test targets OK
Focused tests, merged tree, validation layer on 5/5 pass
Focused tests, main, validation layer on 5/5 pass
VUID- lines (merged / main) 0 / 0
was not found but was requested by env var VK_INSTANCE_LAYERS absent in both logs; the loader inserted VK_LAYER_KHRONOS_validation in both
Test duration each test under 6 s
Probe: CPU-cleared tile vs drawn tile, slices 1 to 3 different texels (see Blocking)
Merged tree ctest
1/5 Test  #840: agc_recorder_cmask ....................   Passed    0.21 sec
2/5 Test  #948: agc_driver_graphics ...................   Passed    4.64 sec
3/5 Test  #951: agc_driver_cmask_fast_clear ...........   Passed    0.45 sec
4/5 Test #1221: agc_driver_layered_array_color_draw ...   Passed    0.48 sec
5/5 Test #1589: agc_driver_graphics_maps_fallback .....   Passed    5.51 sec
100% tests passed out of 5
1221: [src/VulkanDevice.cpp:1288 VulkanDevice] Selected GPU name=NVIDIA GeForce RTX 4070 Ti SUPER vendor=0x10de device=0x2705 subgroup=32
840: [Vulkan Loader] INFO | LAYER:   Insert instance layer "VK_LAYER_KHRONOS_validation" (/usr/lib/libVkLayer_khronos_validation.so)
main ctest
1/5 Test  #840: agc_recorder_cmask ....................   Passed    0.20 sec
2/5 Test  #948: agc_driver_graphics ...................   Passed    4.54 sec
3/5 Test  #951: agc_driver_cmask_fast_clear ...........   Passed    0.38 sec
4/5 Test #1221: agc_driver_layered_array_color_draw ...   Passed    0.35 sec
5/5 Test #1589: agc_driver_graphics_maps_fallback .....   Passed    4.81 sec

This is the paired validation-layer run that the earlier review asked for (that review was on 45e34f8cd6). It shows no VUID- lines on either side. That review's base-branch point is also settled: the head merges cleanly onto the current main.

Negative control

Restoring every production file from main doesn't compile, because the tests use Nibble's third argument and ColorTarget::cmaskSliceBytes. ycbuzi's Windows run reported the same. Instead, I reverted one production behaviour at a time and kept the tests:

Reverted Test Result
materializeCmaskClear always calls materializeCmaskClearOf once (no per-layer split) agc_driver_layered_array_color_draw_tests fails: "the second layer (slice 1) of the two-layer view holds 0 cleared texels", same for slices 1 and 2
CmaskLayout::Nibble ignores slice agc_driver_graphics_tests fails: "CMASK nibble of a slice differs from addrlib's"
cmaskSliceOffset forced to 0 in DecodeColorBuffer agc_driver_graphics_tests fails: "slice 1 of a 2D array fast-clear target did not decode at its own CMASK block"

None of these tests catches the bug below.

Findings

Blocking

1. A partial CMASK clear of slice ≥ 1 writes the clear value into the wrong 8x8 tiles.

storeCmaskClearTexels (core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:443) builds its layout as ColorTargetLayout(width, height, tileMode, elementBytes), so pipeBankXor falls back to its default of 0. The change computes each slice's XOR, in materializeCmaskClear (one.pipeBankXor ^= ColorSliceXor(...), Draw.cpp:526) and for a plain slice in DecodeColorBuffer. The CPU path never reads that value. storeSingleTexels does pass color.pipeBankXor (Draw.cpp:319).

An array resident has more than one layer, so StorageTexture::ElementView() returns VK_NULL_HANDLE for it and the GPU recordCmaskClear path is never taken. Every array or layered fast clear therefore goes through this CPU path. When the CMASK is fully cleared the error doesn't show, because the whole slice is filled. When it is partly cleared, the clear lands on other texels of the slice than the cleared tiles.

The new RunCmaskClear test can't see this. It compares the two-layer view with the single-slice view of the same slice (LayeredArrayColorDraw.cpp L280-L288), and both go through the same CPU path. It also checks only the number of cleared texels, not where they are.

Evidence: I added a probe to the test locally. For each slice of the four-slice SW_64KB_R_X array, it (a) draws through a single-slice view with the scissor limited to one 8x8 tile and records which 32-bit words of the slice change, then (b) marks only that tile cleared in the slice's CMASK, runs the fast-clear materialization through the same single-slice view, and records which words change.

PROBE slice 0 tile (5,3): drawn 64 words first 1664, cleared 64 words first 1664, same=1
PROBE slice 0 tile (0,0): drawn 64 words first 0, cleared 64 words first 0, same=1
PROBE slice 1 tile (5,3): drawn 64 words first 17536, cleared 64 words first 18048, same=0
PROBE slice 1 tile (0,0): drawn 64 words first 16896, cleared 64 words first 16384, same=0
PROBE slice 2 tile (5,3): drawn 64 words first 34688, cleared 64 words first 34432, same=0
PROBE slice 2 tile (0,0): drawn 64 words first 33024, cleared 64 words first 32768, same=0
PROBE slice 3 tile (5,3): drawn 64 words first 50560, cleared 64 words first 50816, same=0
PROBE slice 3 tile (0,0): drawn 64 words first 49920, cleared 64 words first 49152, same=0

With the one-line fix below, every row prints same=1. The PR's agc_driver_layered_array_color_draw and agc_driver_cmask_fast_clear tests still pass with that fix.

-    const ColorTargetLayout surface(color.extent.width, color.extent.height, color.tileMode, color.elementBytes);
+    const ColorTargetLayout surface(color.extent.width, color.extent.height, color.tileMode, color.elementBytes, color.pipeBankXor);

Suggested fix: pass color.pipeBankXor as above. Also extend RunCmaskClear (or agc_driver_cmask_fast_clear with a real slice XOR) to compare the cleared texels against where a draw writes the same tile, or against ColorTargetLayout(..., pipeBankXor).Offset(x, y), so that the test fails without the fix. The fix also covers the CPU fallback for a plain slice (arrayLastSlice == 0, slice ≠ 0), which this PR (with #7668's commits) newly lets through, and a non-zero base XOR taken from the surface address.

Probe added to LayeredArrayColorDraw.cpp (local only)
VkRect2D ProbeScissor{{0, 0}, {0, 0}};
bool ProbeOn = false;
// in Draw(): state.scissor = ProbeOn ? ProbeScissor : coverNothing ? VkRect2D{{0, 0}, {0, 0}} : VkRect2D{{0, 0}, {Side, Side}};

void Probe(AgcDriver::VulkanDevice& device, std::uint8_t* texels, std::uint32_t slice, std::uint32_t tx, std::uint32_t ty) {
    using AgcDriver::Graphics::CmaskLayout;
    const auto surface = AddressOf(texels);
    const auto words = SliceBytes / 4u;
    std::fill_n(reinterpret_cast<std::uint32_t*>(texels), SurfaceBytes / 4u, Kept);
    AgcDriver::GuestMemory::CollectWrites(surface, SurfaceBytes);
    AgcDriver::GuestMemory::BumpCollectEpoch();
    ProbeOn = true;
    ProbeScissor = {{static_cast<std::int32_t>(tx * 8), static_cast<std::int32_t>(ty * 8)}, {8, 8}};
    Draw(device, DecodeColor(surface, Slices - 1u, slice, 1), 1, false);
    ProbeOn = false;
    AgcDriver::Graphics::StorageTexture::FlushPending(surface, SurfaceBytes, nullptr, "probe draw");
    device.WaitIdle();
    std::vector<std::size_t> drawn;
    const auto* w = reinterpret_cast<const std::uint32_t*>(texels);
    for (std::size_t i = slice * words; i < (slice + 1) * words; ++i) if (w[i] != Kept) drawn.push_back(i);
    const CmaskLayout cmaskLayout(Side, Side);
    std::vector<std::byte> mask(Cmask.size(), std::byte{0xff});
    const auto nibble = cmaskLayout.Nibble(tx, ty, slice);
    mask[slice * CmaskSliceBytes + nibble / 2u] &= std::byte{static_cast<std::uint8_t>((nibble % 2u) == 0 ? 0xf0u : 0x0fu)};
    std::fill_n(reinterpret_cast<std::uint32_t*>(texels), SurfaceBytes / 4u, Kept);
    {
        std::lock_guard lock(AgcDriver::GuestMemory::GpuMutex());
        AgcDriver::GuestMemory::Write(AddressOf(Cmask.data()), mask);
    }
    AgcDriver::GuestMemory::CollectWrites(surface, SurfaceBytes);
    AgcDriver::GuestMemory::BumpCollectEpoch();
    Draw(device, DecodeColor(surface, Slices - 1u, slice, 1, true), 1, true);
    AgcDriver::Graphics::StorageTexture::FlushPending(surface, SurfaceBytes, nullptr, "probe clear");
    device.WaitIdle();
    std::vector<std::size_t> cleared;
    for (std::size_t i = slice * words; i < (slice + 1) * words; ++i) if (w[i] != Kept) cleared.push_back(i);
    std::printf("PROBE slice %u tile (%u,%u): drawn %zu words first %zu, cleared %zu words first %zu, same=%d\n", slice, tx, ty, drawn.size(), drawn.empty() ? 0 : drawn[0], cleared.size(), cleared.empty() ? 0 : cleared[0], drawn == cleared ? 1 : 0);
}
// in main(): for (const std::uint32_t sl : {0u, 1u, 2u, 3u}) { Probe(*device, array.Data(), sl, 5, 3); Probe(*device, array.Data(), sl, 0, 0); }

Non-blocking

2. The one-fragment CMASK code check still reads the slice-0 nibbles. In readCmask, the coverageSamples > samples loop (core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:417, permalink) still calls layout.Nibble(tileX, tileY), while the loop below it now passes color.cmaskSlice. For slice ≥ 1 of a single-sample, multi-coverage target, it checks the codes at the slice-0 positions. On a small target those can be padding nibbles, so it can throw on leftover values or miss a real code. Pass color.cmaskSlice there too.

3. Debt entry length. check_conventions.py warns that the CMASK fast clears entry in docs/dev/debt/libSceAgcDriver.md is 2586 characters, over the 1000-character guideline; it was already 1554 on main. The new text could be shortened to the gap: the per-slice stride and Z-bit XOR follow Addrlib and are not verified on hardware, and a 3D target or a slice or array of a mipmapped target throws.

4. Landing order with #7668. The body lists #7668 under Depends on, and that PR is still open. The fix for finding 1 also applies to the plain-slice CPU path that #7668's commits enable, so whichever PR lands first should carry it.

Not verified

  • The CMASK slice stride and the Z0..Z3 XOR against PS5 hardware. Like the debt entry, I compared only the code with the Addrlib references in the tests.
  • The PPSA34063 title (discussion #4275); I did not launch any title.
  • Windows and other GPUs. I ran only the GPU named above.
  • The full test suite and the libs target. I built and ran only the AGC targets the change touches.

To get this to a good state

  1. Pass color.pipeBankXor to the ColorTargetLayout in storeCmaskClearTexels.
  2. Add a test that fails without that fix: a partial CMASK clear of slice ≥ 1 of an XOR-swizzled target, with the cleared texels checked against where a draw of the same tile lands, or against ColorTargetLayout(..., pipeBankXor).Offset.
  3. Optionally, pass color.cmaskSlice in the one-fragment code check and shorten the debt entry.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693577539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11825#pullrequestreview-5693577539). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T06:11:18Z. **Review:** DISMISSED --- # Reviewed — changes requested The decode, stride and per-layer split work and the focused tests pass on a clean merge, but the CPU fast-clear path writes the cleared tiles of every slice except slice 0 to the wrong texels, because it drops the slice's pipe-bank XOR. ## What I ran - PR head: `6e05e5763ebeaab817ad3baca00de8d3c44ac8a6` - `main`: `2960e9a6e7e1fc99c4ed180c71495b5eb83464c7` - Merged tree (`main` + head, `--no-ff`, no conflicts): `7b90366b84d107024ba9429f2cbfc408630b2dd7` - Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), Release, Ninja, in a clean worktree. ```sh git fetch origin main pull/11825/head:refs/review/11825 git checkout --detach origin/main git merge --no-ff --no-edit refs/review/11825 git diff --check origin/main...refs/review/11825 python3 tools/check_conventions.py --base origin/main cmake --build build -j10 --target agc_driver_graphics_tests agc_driver_cmask_fast_clear_tests agc_driver_layered_array_color_draw_tests agc_driver_recorder_tests VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ ctest --test-dir build -R '^(agc_driver_graphics|agc_driver_cmask_fast_clear|agc_driver_layered_array_color_draw|agc_recorder_cmask|agc_driver_graphics_maps_fallback)$' -V --output-on-failure # the same build and ctest command on origin/main, then back to the merged tree # probe (local only, not pushed): one 8x8 scissored draw vs one CMASK-cleared tile per slice, see Findings ``` ## Results | Check | Result | |---|---| | Merge into `main` | clean | | `git diff --check` | clean | | `check_conventions.py` | 0 errors, 1 warning: `[debt-length]` on the CMASK fast clears entry (2586 characters; it was 1554 on `main`) | | Build of the four test targets | OK | | Focused tests, merged tree, validation layer on | 5/5 pass | | Focused tests, `main`, validation layer on | 5/5 pass | | `VUID-` lines (merged / `main`) | 0 / 0 | | `was not found but was requested by env var VK_INSTANCE_LAYERS` | absent in both logs; the loader inserted `VK_LAYER_KHRONOS_validation` in both | | Test duration | each test under 6 s | | Probe: CPU-cleared tile vs drawn tile, slices 1 to 3 | **different texels** (see Blocking) | <details><summary>Merged tree ctest</summary> ``` 1/5 Test #840: agc_recorder_cmask .................... Passed 0.21 sec 2/5 Test #948: agc_driver_graphics ................... Passed 4.64 sec 3/5 Test #951: agc_driver_cmask_fast_clear ........... Passed 0.45 sec 4/5 Test #1221: agc_driver_layered_array_color_draw ... Passed 0.48 sec 5/5 Test #1589: agc_driver_graphics_maps_fallback ..... Passed 5.51 sec 100% tests passed out of 5 1221: [src/VulkanDevice.cpp:1288 VulkanDevice] Selected GPU name=NVIDIA GeForce RTX 4070 Ti SUPER vendor=0x10de device=0x2705 subgroup=32 840: [Vulkan Loader] INFO | LAYER: Insert instance layer "VK_LAYER_KHRONOS_validation" (/usr/lib/libVkLayer_khronos_validation.so) ``` </details> <details><summary>main ctest</summary> ``` 1/5 Test #840: agc_recorder_cmask .................... Passed 0.20 sec 2/5 Test #948: agc_driver_graphics ................... Passed 4.54 sec 3/5 Test #951: agc_driver_cmask_fast_clear ........... Passed 0.38 sec 4/5 Test #1221: agc_driver_layered_array_color_draw ... Passed 0.35 sec 5/5 Test #1589: agc_driver_graphics_maps_fallback ..... Passed 4.81 sec ``` </details> This is the paired validation-layer run that the earlier review asked for (that review was on `45e34f8cd6`). It shows no `VUID-` lines on either side. That review's base-branch point is also settled: the head merges cleanly onto the current `main`. ## Negative control Restoring every production file from `main` doesn't compile, because the tests use `Nibble`'s third argument and `ColorTarget::cmaskSliceBytes`. ycbuzi's Windows run reported the same. Instead, I reverted one production behaviour at a time and kept the tests: | Reverted | Test | Result | |---|---|---| | `materializeCmaskClear` always calls `materializeCmaskClearOf` once (no per-layer split) | `agc_driver_layered_array_color_draw_tests` | fails: "the second layer (slice 1) of the two-layer view holds 0 cleared texels", same for slices 1 and 2 | | `CmaskLayout::Nibble` ignores `slice` | `agc_driver_graphics_tests` | fails: "CMASK nibble of a slice differs from addrlib's" | | `cmaskSliceOffset` forced to 0 in `DecodeColorBuffer` | `agc_driver_graphics_tests` | fails: "slice 1 of a 2D array fast-clear target did not decode at its own CMASK block" | None of these tests catches the bug below. ## Findings ### Blocking **1. A partial CMASK clear of slice ≥ 1 writes the clear value into the wrong 8x8 tiles.** [`storeCmaskClearTexels`](https://github.com/boykopovar/AnyPS5/blob/6e05e5763ebeaab817ad3baca00de8d3c44ac8a6/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L441-L444) (core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:443) builds its layout as `ColorTargetLayout(width, height, tileMode, elementBytes)`, so `pipeBankXor` falls back to its default of 0. The change computes each slice's XOR, in [`materializeCmaskClear`](https://github.com/boykopovar/AnyPS5/blob/6e05e5763ebeaab817ad3baca00de8d3c44ac8a6/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L517-L532) (`one.pipeBankXor ^= ColorSliceXor(...)`, Draw.cpp:526) and for a plain slice in [`DecodeColorBuffer`](https://github.com/boykopovar/AnyPS5/blob/6e05e5763ebeaab817ad3baca00de8d3c44ac8a6/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L2140-L2143). The CPU path never reads that value. [`storeSingleTexels`](https://github.com/boykopovar/AnyPS5/blob/6e05e5763ebeaab817ad3baca00de8d3c44ac8a6/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L317-L319) does pass `color.pipeBankXor` (Draw.cpp:319). An array resident has more than one layer, so `StorageTexture::ElementView()` returns `VK_NULL_HANDLE` for it and the GPU `recordCmaskClear` path is never taken. Every array or layered fast clear therefore goes through this CPU path. When the CMASK is fully cleared the error doesn't show, because the whole slice is filled. When it is partly cleared, the clear lands on other texels of the slice than the cleared tiles. The new `RunCmaskClear` test can't see this. It compares the two-layer view with the single-slice view of the same slice ([LayeredArrayColorDraw.cpp L280-L288](https://github.com/boykopovar/AnyPS5/blob/6e05e5763ebeaab817ad3baca00de8d3c44ac8a6/core/libs/prx/libSceAgcDriver/tests/execution/LayeredArrayColorDraw.cpp#L280-L288)), and both go through the same CPU path. It also checks only the number of cleared texels, not where they are. Evidence: I added a probe to the test locally. For each slice of the four-slice SW_64KB_R_X array, it (a) draws through a single-slice view with the scissor limited to one 8x8 tile and records which 32-bit words of the slice change, then (b) marks only that tile cleared in the slice's CMASK, runs the fast-clear materialization through the same single-slice view, and records which words change. ``` PROBE slice 0 tile (5,3): drawn 64 words first 1664, cleared 64 words first 1664, same=1 PROBE slice 0 tile (0,0): drawn 64 words first 0, cleared 64 words first 0, same=1 PROBE slice 1 tile (5,3): drawn 64 words first 17536, cleared 64 words first 18048, same=0 PROBE slice 1 tile (0,0): drawn 64 words first 16896, cleared 64 words first 16384, same=0 PROBE slice 2 tile (5,3): drawn 64 words first 34688, cleared 64 words first 34432, same=0 PROBE slice 2 tile (0,0): drawn 64 words first 33024, cleared 64 words first 32768, same=0 PROBE slice 3 tile (5,3): drawn 64 words first 50560, cleared 64 words first 50816, same=0 PROBE slice 3 tile (0,0): drawn 64 words first 49920, cleared 64 words first 49152, same=0 ``` With the one-line fix below, every row prints `same=1`. The PR's `agc_driver_layered_array_color_draw` and `agc_driver_cmask_fast_clear` tests still pass with that fix. ```diff - const ColorTargetLayout surface(color.extent.width, color.extent.height, color.tileMode, color.elementBytes); + const ColorTargetLayout surface(color.extent.width, color.extent.height, color.tileMode, color.elementBytes, color.pipeBankXor); ``` Suggested fix: pass `color.pipeBankXor` as above. Also extend `RunCmaskClear` (or `agc_driver_cmask_fast_clear` with a real slice XOR) to compare the cleared texels against where a draw writes the same tile, or against `ColorTargetLayout(..., pipeBankXor).Offset(x, y)`, so that the test fails without the fix. The fix also covers the CPU fallback for a plain slice (`arrayLastSlice == 0`, slice ≠ 0), which this PR (with #7668's commits) newly lets through, and a non-zero base XOR taken from the surface address. <details><summary>Probe added to LayeredArrayColorDraw.cpp (local only)</summary> ```cpp VkRect2D ProbeScissor{{0, 0}, {0, 0}}; bool ProbeOn = false; // in Draw(): state.scissor = ProbeOn ? ProbeScissor : coverNothing ? VkRect2D{{0, 0}, {0, 0}} : VkRect2D{{0, 0}, {Side, Side}}; void Probe(AgcDriver::VulkanDevice& device, std::uint8_t* texels, std::uint32_t slice, std::uint32_t tx, std::uint32_t ty) { using AgcDriver::Graphics::CmaskLayout; const auto surface = AddressOf(texels); const auto words = SliceBytes / 4u; std::fill_n(reinterpret_cast<std::uint32_t*>(texels), SurfaceBytes / 4u, Kept); AgcDriver::GuestMemory::CollectWrites(surface, SurfaceBytes); AgcDriver::GuestMemory::BumpCollectEpoch(); ProbeOn = true; ProbeScissor = {{static_cast<std::int32_t>(tx * 8), static_cast<std::int32_t>(ty * 8)}, {8, 8}}; Draw(device, DecodeColor(surface, Slices - 1u, slice, 1), 1, false); ProbeOn = false; AgcDriver::Graphics::StorageTexture::FlushPending(surface, SurfaceBytes, nullptr, "probe draw"); device.WaitIdle(); std::vector<std::size_t> drawn; const auto* w = reinterpret_cast<const std::uint32_t*>(texels); for (std::size_t i = slice * words; i < (slice + 1) * words; ++i) if (w[i] != Kept) drawn.push_back(i); const CmaskLayout cmaskLayout(Side, Side); std::vector<std::byte> mask(Cmask.size(), std::byte{0xff}); const auto nibble = cmaskLayout.Nibble(tx, ty, slice); mask[slice * CmaskSliceBytes + nibble / 2u] &= std::byte{static_cast<std::uint8_t>((nibble % 2u) == 0 ? 0xf0u : 0x0fu)}; std::fill_n(reinterpret_cast<std::uint32_t*>(texels), SurfaceBytes / 4u, Kept); { std::lock_guard lock(AgcDriver::GuestMemory::GpuMutex()); AgcDriver::GuestMemory::Write(AddressOf(Cmask.data()), mask); } AgcDriver::GuestMemory::CollectWrites(surface, SurfaceBytes); AgcDriver::GuestMemory::BumpCollectEpoch(); Draw(device, DecodeColor(surface, Slices - 1u, slice, 1, true), 1, true); AgcDriver::Graphics::StorageTexture::FlushPending(surface, SurfaceBytes, nullptr, "probe clear"); device.WaitIdle(); std::vector<std::size_t> cleared; for (std::size_t i = slice * words; i < (slice + 1) * words; ++i) if (w[i] != Kept) cleared.push_back(i); std::printf("PROBE slice %u tile (%u,%u): drawn %zu words first %zu, cleared %zu words first %zu, same=%d\n", slice, tx, ty, drawn.size(), drawn.empty() ? 0 : drawn[0], cleared.size(), cleared.empty() ? 0 : cleared[0], drawn == cleared ? 1 : 0); } // in main(): for (const std::uint32_t sl : {0u, 1u, 2u, 3u}) { Probe(*device, array.Data(), sl, 5, 3); Probe(*device, array.Data(), sl, 0, 0); } ``` </details> ### Non-blocking **2. The one-fragment CMASK code check still reads the slice-0 nibbles.** In `readCmask`, the `coverageSamples > samples` loop (core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:417, [permalink](https://github.com/boykopovar/AnyPS5/blob/6e05e5763ebeaab817ad3baca00de8d3c44ac8a6/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L414-L417)) still calls `layout.Nibble(tileX, tileY)`, while the loop below it now passes `color.cmaskSlice`. For slice ≥ 1 of a single-sample, multi-coverage target, it checks the codes at the slice-0 positions. On a small target those can be padding nibbles, so it can throw on leftover values or miss a real code. Pass `color.cmaskSlice` there too. **3. Debt entry length.** `check_conventions.py` warns that the CMASK fast clears entry in `docs/dev/debt/libSceAgcDriver.md` is 2586 characters, over the 1000-character guideline; it was already 1554 on `main`. The new text could be shortened to the gap: the per-slice stride and Z-bit XOR follow Addrlib and are not verified on hardware, and a 3D target or a slice or array of a mipmapped target throws. **4. Landing order with #7668.** The body lists #7668 under Depends on, and that PR is still open. The fix for finding 1 also applies to the plain-slice CPU path that #7668's commits enable, so whichever PR lands first should carry it. ## Not verified - The CMASK slice stride and the Z0..Z3 XOR against PS5 hardware. Like the debt entry, I compared only the code with the Addrlib references in the tests. - The PPSA34063 title (discussion #4275); I did not launch any title. - Windows and other GPUs. I ran only the GPU named above. - The full test suite and the `libs` target. I built and ran only the AGC targets the change touches. ## To get this to a good state 1. Pass `color.pipeBankXor` to the `ColorTargetLayout` in `storeCmaskClearTexels`. 2. Add a test that fails without that fix: a partial CMASK clear of slice ≥ 1 of an XOR-swizzled target, with the cleared texels checked against where a draw of the same tile lands, or against `ColorTargetLayout(..., pipeBankXor).Offset`. 3. Optionally, pass `color.cmaskSlice` in the one-fragment code check and shorten the debt entry.
XairRrR commented 2026-11-02 19:52:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T19:52:08Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

This pull request does not merge cleanly into main (128b5c49ba): head 86a4136de4 conflicts in

  • core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
  • core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp

Please rebase it onto current main. I will review the change once it merges cleanly.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5742452852 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11825#pullrequestreview-5742452852). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-02T19:52:08Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested This pull request does not merge cleanly into `main` (128b5c49ba2045d59dbb7404b6e734e208e71d79): head 86a4136de4bf9a24ac7b6f1a15c37845c3e543c5 conflicts in - `core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp` - `core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp` Please rebase it onto current `main`. I will review the change once it merges cleanly. <!-- anyps5-bots job=2256 head=86a4136de4bf9a24ac7b6f1a15c37845c3e543c5 -->
XairRrR commented 2026-11-04 00:07:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-04T00:07:03Z.

Review: APPROVED


Re-checked — approved

Since my last review, storeCmaskClearTexels builds its layout with the slice's pipe-bank XOR, the one-fragment CMASK check reads the slice's own nibbles, and a new tile-against-draw test fails without the fix. The debt entry is also shorter, and the State size guard is updated for the merge of main.

What changed since my last review

I last reviewed 6e05e5763e. The branch was rebased on main since then: the layered-draw commits of #7254 were dropped and the six CMASK commits were replayed. The new commits are:

  • a01df997c0 passes color.pipeBankXor to the ColorTargetLayout in storeCmaskClearTexels, and color.cmaskSlice to Nibble in the one-fragment loop of readCmask.
  • c5b40a544c shortens the CMASK fast clears debt entry.
  • 86a4136de4 adds RunTileClearMatchesDraw to LayeredArrayColorDraw.cpp. It checks slices 0 to 3 at tiles (5,3) and (0,0), and compares the words that a scissored 8x8 draw writes with the words that a fast clear of the same tile writes.
  • 55f2963f98 merges main. It keeps the eighth push constant (slice) in DispatchCmaskClear with the Resolved dispatch calls from main.
  • c32f9d09d9 moves the sizeof(State) guard from 936 to 952. main already had 936, and the two new ColorTarget fields add 16 bytes.

What I ran

  • PR head: c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c
  • main: 1c8c0efc8c41314402e6966da5bef6ea3d639d10
  • Merged tree: 0c625f6e8d16df8d9ab1994e89deb8c6597d5cb2
  • Machine: Debian 13 VM, 32 vCPU (Xeon Gold 6136), GCC 14.2.0, Release, Ninja, Vulkan through lavapipe (Mesa 26.1.6, LLVM 19), no GPU.
git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c
python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
  ctest --test-dir build -V -j5 -R '^(agc_driver_graphics|agc_driver_cmask_fast_clear|agc_driver_layered_array_color_draw|agc_recorder_cmask|agc_driver_graphics_maps_fallback)$'
# negative control: drop ", color.pipeBankXor" from storeCmaskClearTexels (Draw.cpp:570), keep the tests
ninja -C build agc_driver_layered_array_color_draw_tests
ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R '^agc_driver_layered_array_color_draw$' --output-on-failure
# restore Draw.cpp from the merged tree, rebuild, rerun the five tests above with the validation layer
git status --porcelain
ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R '^(agc_driver_graphics|agc_driver_graphics_maps_fallback)$'
Check Result
git diff --check clean
check_conventions.py all checks passed; the earlier [debt-length] warning is gone
Build, libs (script) OK
Script test run (2184 tests) 0 new failures, 0 timeouts; 7 known failures that also fail on main
Script validation comparison 783 of 784 tests loaded the layer, none missing it. The only new VUID- lines are in agc_driver_image_gather_volume, a test that did not run on the baseline main. This PR does not touch samplers, so I do not count them against it.
Five focused tests, validation layer on 5/5 pass, 0 VUID- lines, no was not found but was requested
RunTileClearMatchesDraw tile clear against draw: 8 cases, 0 differ
Negative control fails, 6 of 8 cases differ (see below)
Worktree after the control git status --porcelain empty
Focused run, merged tree
1/5 Test #2016: agc_recorder_cmask ....................   Passed    0.18 sec
2/5 Test #1672: agc_driver_cmask_fast_clear ...........   Passed    0.37 sec
1300: tile clear against draw: 8 cases, 0 differ
3/5 Test #1300: agc_driver_layered_array_color_draw ...   Passed    1.36 sec
4/5 Test #1775: agc_driver_graphics ...................   Passed   34.74 sec
5/5 Test #1800: agc_driver_graphics_maps_fallback .....   Passed   36.33 sec
100% tests passed, 0 tests failed out of 5

Negative control

I removed only the color.pipeBankXor argument from storeCmaskClearTexels (core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:570) and kept the new test. agc_driver_layered_array_color_draw then fails. Every case of slices 1 to 3 differs, and slice 0, which has no XOR, still passes. This matches the probe in my previous review and the author's RTX 4090 result.

Output with the fix reverted
tile clear against draw: 8 cases, 6 differ
AGC graphics: a fast-cleared tile (5, 3) of slice 1: the clear changed 64 words, the draw 64, and they are not the same words
AGC graphics: a fast-cleared tile (0, 0) of slice 1: the clear changed 64 words, the draw 64, and they are not the same words
AGC graphics: a fast-cleared tile (5, 3) of slice 2: the clear changed 64 words, the draw 64, and they are not the same words
AGC graphics: a fast-cleared tile (0, 0) of slice 2: the clear changed 64 words, the draw 64, and they are not the same words
AGC graphics: a fast-cleared tile (5, 3) of slice 3: the clear changed 64 words, the draw 64, and they are not the same words
AGC graphics: a fast-cleared tile (0, 0) of slice 3: the clear changed 64 words, the draw 64, and they are not the same words
        1300 - agc_driver_layered_array_color_draw (Failed)

After restoring Draw.cpp from the merged tree and rebuilding, the test passes again.

Previous findings

  1. Blocking: the CPU fast clear of slice ≥ 1 wrote the wrong tiles. Resolved. storeCmaskClearTexels now passes color.pipeBankXor. The new RunTileClearMatchesDraw checks where the cleared words land, not only how many there are, and it fails without the fix (control above).
  2. Non-blocking: the one-fragment check read the slice-0 nibbles. Resolved. readCmask now calls Nibble(tileX, tileY, color.cmaskSlice). No test exercises this loop with slice ≥ 1, but the change is the same one-argument change the second loop already had.
  3. Non-blocking: the debt entry was too long. Resolved. check_conventions.py no longer warns. The entry now starts with the gap: what is unverified on hardware and what throws.
  4. Non-blocking: landing order with #7668. Still open, coordination only. The checklist still says Depends on: #7668 (open) and that either PR can land first. The XOR fix now lives in this PR, so if #7668 lands alone, its plain-slice CPU path would lack the fix until this PR lands. The discussion records no agreement with that PR's author.

New findings

Blocking

None.

Non-blocking

None. On this lavapipe machine, agc_driver_graphics (34.2 s) and agc_driver_graphics_maps_fallback (36.1 s) run over 30 s even without the validation layer. This PR only adds a few CPU-side DecodeColorBuffer calls to Graphics.cpp, and the NVIDIA CI comment on 86a4136 already flagged agc_driver_graphics_maps_fallback at 35.5 s. I therefore count the duration as main's, although I did not time main here. The PR's test changes do not compile against main's production files, so I could not time them in isolation.

Not verified

  • I did not time the two agc_driver_graphics* tests on main on this machine, so the 30 s overrun is attributed to main by inference only.
  • The per-slice CMASK stride and the Z0..Z3 nibble XOR against PS5 hardware. The debt entry records both as unverified.
  • Hardware GPUs. I ran only lavapipe. The RTX 4090 run and the RTX 3070 Windows run are as the author reports; ycbuzi's NVIDIA/AMD Windows run and TechLevelZero's RTX 2000 Ada run were on earlier heads.
  • PPSA34063 (discussion #4275). I launched no title.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5761277873 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11825#pullrequestreview-5761277873). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-04T00:07:03Z. **Review:** APPROVED --- # Re-checked — approved Since my last review, `storeCmaskClearTexels` builds its layout with the slice's pipe-bank XOR, the one-fragment CMASK check reads the slice's own nibbles, and a new tile-against-draw test fails without the fix. The debt entry is also shorter, and the `State` size guard is updated for the merge of `main`. ## What changed since my last review I last reviewed `6e05e5763e`. The branch was rebased on `main` since then: the layered-draw commits of #7254 were dropped and the six CMASK commits were replayed. The new commits are: - `a01df997c0` passes `color.pipeBankXor` to the `ColorTargetLayout` in `storeCmaskClearTexels`, and `color.cmaskSlice` to `Nibble` in the one-fragment loop of `readCmask`. - `c5b40a544c` shortens the CMASK fast clears debt entry. - `86a4136de4` adds `RunTileClearMatchesDraw` to `LayeredArrayColorDraw.cpp`. It checks slices 0 to 3 at tiles (5,3) and (0,0), and compares the words that a scissored 8x8 draw writes with the words that a fast clear of the same tile writes. - `55f2963f98` merges `main`. It keeps the eighth push constant (`slice`) in `DispatchCmaskClear` with the `Resolved` dispatch calls from `main`. - `c32f9d09d9` moves the `sizeof(State)` guard from 936 to 952. `main` already had 936, and the two new `ColorTarget` fields add 16 bytes. ## What I ran - PR head: `c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c` - `main`: `1c8c0efc8c41314402e6966da5bef6ea3d639d10` - Merged tree: `0c625f6e8d16df8d9ab1994e89deb8c6597d5cb2` - Machine: Debian 13 VM, 32 vCPU (Xeon Gold 6136), GCC 14.2.0, Release, Ninja, Vulkan through lavapipe (Mesa 26.1.6, LLVM 19), no GPU. ```sh git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ ctest --test-dir build -V -j5 -R '^(agc_driver_graphics|agc_driver_cmask_fast_clear|agc_driver_layered_array_color_draw|agc_recorder_cmask|agc_driver_graphics_maps_fallback)$' # negative control: drop ", color.pipeBankXor" from storeCmaskClearTexels (Draw.cpp:570), keep the tests ninja -C build agc_driver_layered_array_color_draw_tests ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R '^agc_driver_layered_array_color_draw$' --output-on-failure # restore Draw.cpp from the merged tree, rebuild, rerun the five tests above with the validation layer git status --porcelain ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R '^(agc_driver_graphics|agc_driver_graphics_maps_fallback)$' ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | all checks passed; the earlier `[debt-length]` warning is gone | | Build, `libs` (script) | OK | | Script test run (2184 tests) | 0 new failures, 0 timeouts; 7 known failures that also fail on `main` | | Script validation comparison | 783 of 784 tests loaded the layer, none missing it. The only new `VUID-` lines are in `agc_driver_image_gather_volume`, a test that did not run on the baseline `main`. This PR does not touch samplers, so I do not count them against it. | | Five focused tests, validation layer on | 5/5 pass, 0 `VUID-` lines, no `was not found but was requested` | | `RunTileClearMatchesDraw` | `tile clear against draw: 8 cases, 0 differ` | | Negative control | fails, 6 of 8 cases differ (see below) | | Worktree after the control | `git status --porcelain` empty | <details><summary>Focused run, merged tree</summary> ``` 1/5 Test #2016: agc_recorder_cmask .................... Passed 0.18 sec 2/5 Test #1672: agc_driver_cmask_fast_clear ........... Passed 0.37 sec 1300: tile clear against draw: 8 cases, 0 differ 3/5 Test #1300: agc_driver_layered_array_color_draw ... Passed 1.36 sec 4/5 Test #1775: agc_driver_graphics ................... Passed 34.74 sec 5/5 Test #1800: agc_driver_graphics_maps_fallback ..... Passed 36.33 sec 100% tests passed, 0 tests failed out of 5 ``` </details> ## Negative control I removed only the `color.pipeBankXor` argument from `storeCmaskClearTexels` (core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:570) and kept the new test. `agc_driver_layered_array_color_draw` then fails. Every case of slices 1 to 3 differs, and slice 0, which has no XOR, still passes. This matches the probe in my previous review and the author's RTX 4090 result. <details><summary>Output with the fix reverted</summary> ``` tile clear against draw: 8 cases, 6 differ AGC graphics: a fast-cleared tile (5, 3) of slice 1: the clear changed 64 words, the draw 64, and they are not the same words AGC graphics: a fast-cleared tile (0, 0) of slice 1: the clear changed 64 words, the draw 64, and they are not the same words AGC graphics: a fast-cleared tile (5, 3) of slice 2: the clear changed 64 words, the draw 64, and they are not the same words AGC graphics: a fast-cleared tile (0, 0) of slice 2: the clear changed 64 words, the draw 64, and they are not the same words AGC graphics: a fast-cleared tile (5, 3) of slice 3: the clear changed 64 words, the draw 64, and they are not the same words AGC graphics: a fast-cleared tile (0, 0) of slice 3: the clear changed 64 words, the draw 64, and they are not the same words 1300 - agc_driver_layered_array_color_draw (Failed) ``` </details> After restoring `Draw.cpp` from the merged tree and rebuilding, the test passes again. ## Previous findings 1. **Blocking: the CPU fast clear of slice ≥ 1 wrote the wrong tiles.** Resolved. [`storeCmaskClearTexels`](https://github.com/boykopovar/AnyPS5/blob/c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L568-L571) now passes `color.pipeBankXor`. The new [`RunTileClearMatchesDraw`](https://github.com/boykopovar/AnyPS5/blob/c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c/core/libs/prx/libSceAgcDriver/tests/execution/LayeredArrayColorDraw.cpp#L304-L340) checks where the cleared words land, not only how many there are, and it fails without the fix (control above). 2. **Non-blocking: the one-fragment check read the slice-0 nibbles.** Resolved. [`readCmask`](https://github.com/boykopovar/AnyPS5/blob/c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp#L541-L546) now calls `Nibble(tileX, tileY, color.cmaskSlice)`. No test exercises this loop with slice ≥ 1, but the change is the same one-argument change the second loop already had. 3. **Non-blocking: the debt entry was too long.** Resolved. `check_conventions.py` no longer warns. The entry now starts with the gap: what is unverified on hardware and what throws. 4. **Non-blocking: landing order with #7668.** Still open, coordination only. The checklist still says `Depends on: #7668 (open)` and that either PR can land first. The XOR fix now lives in this PR, so if #7668 lands alone, its plain-slice CPU path would lack the fix until this PR lands. The discussion records no agreement with that PR's author. ## New findings ### Blocking None. ### Non-blocking None. On this lavapipe machine, `agc_driver_graphics` (34.2 s) and `agc_driver_graphics_maps_fallback` (36.1 s) run over 30 s even without the validation layer. This PR only adds a few CPU-side `DecodeColorBuffer` calls to `Graphics.cpp`, and the NVIDIA CI comment on `86a4136` already flagged `agc_driver_graphics_maps_fallback` at 35.5 s. I therefore count the duration as `main`'s, although I did not time `main` here. The PR's test changes do not compile against `main`'s production files, so I could not time them in isolation. ## Not verified - I did not time the two `agc_driver_graphics*` tests on `main` on this machine, so the 30 s overrun is attributed to `main` by inference only. - The per-slice CMASK stride and the Z0..Z3 nibble XOR against PS5 hardware. The debt entry records both as unverified. - Hardware GPUs. I ran only lavapipe. The RTX 4090 run and the RTX 3070 Windows run are as the author reports; ycbuzi's NVIDIA/AMD Windows run and TechLevelZero's RTX 2000 Ada run were on earlier heads. - PPSA34063 (discussion #4275). I launched no title. <!-- anyps5-bots job=3722 head=c32f9d09d9ccecbee8dc9fba06dbe8bf8973614c -->
MarcZX10 commented 2026-11-20 08:56:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T08:56:05Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review covered the changed implementation and tests, and no verified blocking defect was found.

What I ran

Reviewed head ca2b7cc278ea7c1cae3737a5799e1da182f21393 using repo_read.py against the prepared diff and repository files. No commands or tests were run during this review; test results in the PR description are author-reported.

Results

Check Result Note
Changed code review passed Read the changed implementation and test files listed below.
Automated tests not run The description reports a Linux CI run and an author-reported Windows run.
Physical console behavior not run The description says the slice stride has not been measured on hardware.

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full text of core/libs/prx/libSceAgcDriver/tests/Graphics.cpp was excluded from the review folder due to size; I read the changed test region through repo_read.py. No tests were run. Windows, macOS, and physical-console behavior were not verified in this review. Other excluded files listed in review/manifest.json were not present; the manifest lists only Graphics.cpp as excluded by size.

Files read: core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp, core/libs/prx/libSceAgcDriver/Graphics/include/ColorTargetLayout.hpp, core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp, core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp, core/libs/prx/libSceAgcDriver/Graphics/shaders/CmaskClear.comp, core/libs/prx/libSceAgcDriver/Graphics/src/ColorTargetLayout.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp, core/libs/prx/libSceAgcDriver/tests/CmaskFastClear.cpp, core/libs/prx/libSceAgcDriver/tests/ColorTargetLayout.cpp, the changed region of core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, core/libs/prx/libSceAgcDriver/tests/execution/LayeredArrayColorDraw.cpp, and docs/dev/debt/libSceAgcDriver.md.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989921496 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11825#pullrequestreview-5989921496). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T08:56:05Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review covered the changed implementation and tests, and no verified blocking defect was found. ## What I ran Reviewed head `ca2b7cc278ea7c1cae3737a5799e1da182f21393` using `repo_read.py` against the prepared diff and repository files. No commands or tests were run during this review; test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Read the changed implementation and test files listed below. | | Automated tests | not run | The description reports a Linux CI run and an author-reported Windows run. | | Physical console behavior | not run | The description says the slice stride has not been measured on hardware. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full text of `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` was excluded from the review folder due to size; I read the changed test region through `repo_read.py`. No tests were run. Windows, macOS, and physical-console behavior were not verified in this review. Other excluded files listed in `review/manifest.json` were not present; the manifest lists only `Graphics.cpp` as excluded by size. Files read: `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/include/ColorTargetLayout.hpp`, `core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp`, `core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp`, `core/libs/prx/libSceAgcDriver/Graphics/shaders/CmaskClear.comp`, `core/libs/prx/libSceAgcDriver/Graphics/src/ColorTargetLayout.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp`, `core/libs/prx/libSceAgcDriver/tests/CmaskFastClear.cpp`, `core/libs/prx/libSceAgcDriver/tests/ColorTargetLayout.cpp`, the changed region of `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`, `core/libs/prx/libSceAgcDriver/tests/execution/LayeredArrayColorDraw.cpp`, and `docs/dev/debt/libSceAgcDriver.md`. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 22:56:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:56:38Z.

Review: COMMENTED


The trial merge conflicts in draw/state tracking, the pipeline journal and layered-array test code. The slice-relative color offset and CMASK nibble/XOR selection need the same nonzero base-layer test. Please retain a view starting after slice zero and check that both neighboring slices keep their original color and metadata after eliminate. Please put the direct AGC debt edit in a fragment. I have no paired Vulkan result for this conflicted head.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6180103350 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11825#pullrequestreview-6180103350). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T22:56:38Z. **Review:** COMMENTED --- The trial merge conflicts in draw/state tracking, the pipeline journal and layered-array test code. The slice-relative color offset and CMASK nibble/XOR selection need the same nonzero base-layer test. Please retain a view starting after slice zero and check that both neighboring slices keep their original color and metadata after eliminate. Please put the direct AGC debt edit in a fragment. I have no paired Vulkan result for this conflicted head. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/11825:upstream-pr/11825'
git switch 'upstream-pr/11825'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/11825'
git switch 'upstream-pr/11825'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/11825'
git switch 'upstream-pr/11825'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/11825'
git switch 'main'
git merge --squash 'upstream-pr/11825'
git switch 'main'
git merge --ff-only 'upstream-pr/11825'
git switch 'main'
git merge 'upstream-pr/11825'
git push origin 'main'
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!11825
No description provided.