fix(agc): import undrawn R_X DCC textures and their colour-target state #21479

Merged
VicRaster merged 3 commits from upstream-pr/21479 into main 2026-11-25 23:13:29 +00:00
VicRaster commented 2026-11-16 08:04:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by VicRaster on 2026-11-16T08:04:46Z.


What

Sampling a multisampled SW_64KB_R_X texture with DCC that no draw has rendered to stops with whose compression metadata over a tile mode 7 surface is not modeled. Its metadata can still hold one of the uniform clear codes that #5939 already imports for colour targets. This change imports such a texture, then lets the owner it creates become a colour target.

Texture import. When no resident owner covers the texture, reuse the uniform DCC importer from #5939. The owner is built from the texture descriptor under the same watched-range, metadata-generation and unchanged-during-import checks as a colour-target owner. Known-zero metadata is settled before its generation is collected. A texture descriptor carries no register clear colour, so key 0x20 still throws, as do mixed or expanded keys, non-pipe-aligned metadata, compressed payloads, arrays and mips.

First colour-target use. A texture descriptor has no DCC control word, CMASK or FMASK. When the same surface is then bound as a colour target, the register state adds them, and the reuse check stopped with multisampled DCC target layout or metadata changed. A commercial title samples such a surface as a cleared texture for several hundred frames and hits this on its first draw into it.

When the owner came from a texture, no draw or storage write has reached it, and the address, DCC address, alpha placement, pipe alignment, tile mode, element size and pipe/bank XOR all match, it is imported again under the colour target's full layout. This uses the path #7641 added for a changed pipe/bank XOR, so the clear, CMASK, FMASK and register clear colour come from the current guest state under the usual rules. Before that, the store checks of an ordinary reuse run on the planes the texture import tracked, accepting only a landed whole-range DCC fill, so a write since the texture import still refuses. The write checks move into a helper unchanged.

Any other layout difference, an owner a draw has rendered to, and a later change on the resulting colour-target owner stay refused.

Two commits, one per step; the second has no use without the first.

#20534 and #21155 (same author) change the same initial-import statements, so this branch conflicts with them textually. The resolution is mechanical: keep their committed-colour and known-zero settling for each range, which already covers this change's metadata settling. That combination was built and tested before this rebase: on #21155's earlier head 75563731, these two commits passed the same selected tests that fail without them. Whichever merges second needs that resolution.

tools/pr_overlap.py --branch against 1,693 open PRs reports line conflicts with #19686, #20534 and #21155. It stopped without a full result because 14 others conflict with main; the bot's run on this PR lists two more, #17338 and #19557.

  • #19686 adds ensureGeneralLayout() next to the changed initialDccClear(use, true) call in Recreate, and replaces ApplyFastClear with PrepareForColorAttachment in acquire. The conflict is textual: keep both sides. A texture owner taken over here passes through Recreate and then the colour-attachment preparation, so with #19686 it also leaves the read-only sampled layout before its clear.
  • Not compared automatically: #6808, #7002, #7642, #9508, #10193, #13863, #13920, #13928, #13929, #13963, #16483, #17338, #17738, #17915, #17956 and #19557. Their MultisampleTarget.cpp patches were checked by hand against the points this branch changes: the constructor, Recreate, initialDccClear, checkDccCurrent, acquire's reuse branch and createFilled.
    • #7642, #9508, #10193, #13928 and #13929 change only createFilled's written storage call; this branch adds an unwritten-texture path.
    • #7002 adds a checkDccCurrent(target, false) call; that signature is unchanged.
    • #16483 reads dccRanges and metadataValid when preserving baselines before unwatch; both are unchanged.
    • #17338 and #19557 make the same change to this file: target retirement in forgetSingleClears, discardRetiredTargets, the unmap observer and HostOnlySampleRanges. They touch none of the points above.
    • The rest change none of these points.

None implements the same behaviour.

Tested

16 November 2026, Windows 11 build 26300, NVIDIA GeForce RTX 3080 Ti, driver 610.88; WinLibs GCC 15.2, Release. Khronos validation 1.4.363.1, newer than the pinned Vulkan headers.

Three arms on main 0694c4cbd6f2df1e7cc95a6681746b4de40d1e70, using the same test executables built from this branch. Only the loaded graphics library and its libc/libkernel change between arms, with hashes recorded and the candidate's restored afterwards.

Graphics implementation Passed of 26 Failures
main 20 6: initial_texture_dcc_2/4/8 and texture_dcc_target_2/4/8, at the tile-mode refusal above
main plus the texture import 23 3: texture_dcc_target_2/4/8, at multisampled DCC target layout or metadata changed
this branch 26 0

initial_texture_dcc covers 2, 4 and 8 samples, the four fixed clear codes, both alpha positions, repeated sampling and untouched zero metadata. It also checks refusals for the register-clear key, mixed keys, unaligned metadata and a metadata store after import. texture_dcc_target samples an R_X DCC texture, binds it as a colour target with CMASK, FMASK, fast clear and a nonzero DCC control, and checks the samples before, after and on reuse, with guest colour and metadata unchanged. Its controls that must still refuse are: another alpha placement, a colour store and a same-value metadata store before the bind, an owner a draw has rendered to, and another DCC control on the resulting colour-target owner. The alpha-to-coverage tests, which exercise the #7641 path this shares, pass in all arms.

$env:ANYPS5_REQUIRE_VULKAN='1'
$env:ANYPS5_NO_SHADER_CACHE='1'
$env:VK_INSTANCE_LAYERS='VK_LAYER_KHRONOS_validation'
$env:VK_LOADER_DEBUG='layer'
ctest --test-dir build -R 'fmask|initial_texture_dcc|msaa_dcc_clear|cold_texture_dcc|imported_run_texture_dcc|native_color_initial|texture_dcc_target|alpha_to_coverage' -V

All 26 selected tests ran in every arm; none skipped, disabled or missing. Each arm's log shows the loader inserting the Khronos layer for the 24 tests that open a device (the two alpha-to-coverage state tests do not), with no missing-layer message and no VUID-. All three arms log the same three Undefined-Value-ShaderOutputNotConsumed-DynamicRendering warnings in agc_driver_alpha_to_coverage; this change adds none.

On a private integration branch carrying further local fixes, the second commit takes a commercial title past this stop at 3840x2160 in SDR and HDR10. Without it, three of three launches stopped 1.3 to 1.9 s after the intro video. With it, three of three reached the main menu and new-game setup, and one reached a loading screen. That is menus, not gameplay. No Linux or macOS run and no performance claim.

check_conventions.py --base origin/main and check_main_sync.py pass. debt_fold.py --check reports one fragment that does not apply, docs-nkwebkit-drop-readded-count-lines.md, which is already on main and untouched here.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3080 Ti, NVIDIA 610.88, Windows 11 build 26300
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01CfHqvesLHKGJRvAoHQuocc

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5333339224 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21479). Originally posted by [VicRaster](https://github.com/VicRaster) on 2026-11-16T08:04:46Z. --- ### What Sampling a multisampled SW_64KB_R_X texture with DCC that no draw has rendered to stops with `whose compression metadata over a tile mode 7 surface is not modeled`. Its metadata can still hold one of the uniform clear codes that #5939 already imports for colour targets. This change imports such a texture, then lets the owner it creates become a colour target. **Texture import.** When no resident owner covers the texture, reuse the uniform DCC importer from #5939. The owner is built from the texture descriptor under the same watched-range, metadata-generation and unchanged-during-import checks as a colour-target owner. Known-zero metadata is settled before its generation is collected. A texture descriptor carries no register clear colour, so key 0x20 still throws, as do mixed or expanded keys, non-pipe-aligned metadata, compressed payloads, arrays and mips. **First colour-target use.** A texture descriptor has no DCC control word, CMASK or FMASK. When the same surface is then bound as a colour target, the register state adds them, and the reuse check stopped with `multisampled DCC target layout or metadata changed`. A commercial title samples such a surface as a cleared texture for several hundred frames and hits this on its first draw into it. When the owner came from a texture, no draw or storage write has reached it, and the address, DCC address, alpha placement, pipe alignment, tile mode, element size and pipe/bank XOR all match, it is imported again under the colour target's full layout. This uses the path #7641 added for a changed pipe/bank XOR, so the clear, CMASK, FMASK and register clear colour come from the current guest state under the usual rules. Before that, the store checks of an ordinary reuse run on the planes the texture import tracked, accepting only a landed whole-range DCC fill, so a write since the texture import still refuses. The write checks move into a helper unchanged. Any other layout difference, an owner a draw has rendered to, and a later change on the resulting colour-target owner stay refused. Two commits, one per step; the second has no use without the first. #### Related open PRs #20534 and #21155 (same author) change the same initial-import statements, so this branch conflicts with them textually. The resolution is mechanical: keep their committed-colour and known-zero settling for each range, which already covers this change's metadata settling. That combination was built and tested before this rebase: on #21155's earlier head `75563731`, these two commits passed the same selected tests that fail without them. Whichever merges second needs that resolution. `tools/pr_overlap.py --branch` against 1,693 open PRs reports line conflicts with #19686, #20534 and #21155. It stopped without a full result because 14 others conflict with main; the bot's run on this PR lists two more, #17338 and #19557. - **#19686** adds `ensureGeneralLayout()` next to the changed `initialDccClear(use, true)` call in `Recreate`, and replaces `ApplyFastClear` with `PrepareForColorAttachment` in `acquire`. The conflict is textual: keep both sides. A texture owner taken over here passes through `Recreate` and then the colour-attachment preparation, so with #19686 it also leaves the read-only sampled layout before its clear. - **Not compared automatically:** #6808, #7002, #7642, #9508, #10193, #13863, #13920, #13928, #13929, #13963, #16483, #17338, #17738, #17915, #17956 and #19557. Their `MultisampleTarget.cpp` patches were checked by hand against the points this branch changes: the constructor, `Recreate`, `initialDccClear`, `checkDccCurrent`, `acquire`'s reuse branch and `createFilled`. - #7642, #9508, #10193, #13928 and #13929 change only `createFilled`'s written storage call; this branch adds an unwritten-texture path. - #7002 adds a `checkDccCurrent(target, false)` call; that signature is unchanged. - #16483 reads `dccRanges` and `metadataValid` when preserving baselines before unwatch; both are unchanged. - #17338 and #19557 make the same change to this file: target retirement in `forgetSingleClears`, `discardRetiredTargets`, the unmap observer and `HostOnlySampleRanges`. They touch none of the points above. - The rest change none of these points. None implements the same behaviour. ### Tested 16 November 2026, Windows 11 build 26300, NVIDIA GeForce RTX 3080 Ti, driver 610.88; WinLibs GCC 15.2, Release. Khronos validation 1.4.363.1, newer than the pinned Vulkan headers. Three arms on main `0694c4cbd6f2df1e7cc95a6681746b4de40d1e70`, using the same test executables built from this branch. Only the loaded graphics library and its libc/libkernel change between arms, with hashes recorded and the candidate's restored afterwards. | Graphics implementation | Passed of 26 | Failures | | --- | ---: | --- | | main | 20 | 6: `initial_texture_dcc_2/4/8` and `texture_dcc_target_2/4/8`, at the tile-mode refusal above | | main plus the texture import | 23 | 3: `texture_dcc_target_2/4/8`, at `multisampled DCC target layout or metadata changed` | | this branch | 26 | 0 | `initial_texture_dcc` covers 2, 4 and 8 samples, the four fixed clear codes, both alpha positions, repeated sampling and untouched zero metadata. It also checks refusals for the register-clear key, mixed keys, unaligned metadata and a metadata store after import. `texture_dcc_target` samples an R_X DCC texture, binds it as a colour target with CMASK, FMASK, fast clear and a nonzero DCC control, and checks the samples before, after and on reuse, with guest colour and metadata unchanged. Its controls that must still refuse are: another alpha placement, a colour store and a same-value metadata store before the bind, an owner a draw has rendered to, and another DCC control on the resulting colour-target owner. The alpha-to-coverage tests, which exercise the #7641 path this shares, pass in all arms. ```powershell $env:ANYPS5_REQUIRE_VULKAN='1' $env:ANYPS5_NO_SHADER_CACHE='1' $env:VK_INSTANCE_LAYERS='VK_LAYER_KHRONOS_validation' $env:VK_LOADER_DEBUG='layer' ctest --test-dir build -R 'fmask|initial_texture_dcc|msaa_dcc_clear|cold_texture_dcc|imported_run_texture_dcc|native_color_initial|texture_dcc_target|alpha_to_coverage' -V ``` All 26 selected tests ran in every arm; none skipped, disabled or missing. Each arm's log shows the loader inserting the Khronos layer for the 24 tests that open a device (the two alpha-to-coverage state tests do not), with no missing-layer message and no `VUID-`. All three arms log the same three `Undefined-Value-ShaderOutputNotConsumed-DynamicRendering` warnings in `agc_driver_alpha_to_coverage`; this change adds none. On a private integration branch carrying further local fixes, the second commit takes a commercial title past this stop at 3840x2160 in SDR and HDR10. Without it, three of three launches stopped 1.3 to 1.9 s after the intro video. With it, three of three reached the main menu and new-game setup, and one reached a loading screen. That is menus, not gameplay. No Linux or macOS run and no performance claim. `check_conventions.py --base origin/main` and `check_main_sync.py` pass. `debt_fold.py --check` reports one fragment that does not apply, `docs-nkwebkit-drop-readded-count-lines.md`, which is already on main and untouched here. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.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 - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and discussion, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 3080 Ti, NVIDIA 610.88, Windows 11 build 26300 <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01CfHqvesLHKGJRvAoHQuocc
MarcZX10 commented 2026-11-16 08:10:56 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed — looks good

The reviewed change at e23cc4cd5c84785531b899fa05171750c0e1a3b8 has no verified blocking defects; author-reported checks passed, but I did not run them.

What I ran

Read the prepared diff and all three changed files through repo_read.py. No commands or tests were run; I did not fetch the diff again.

Results

Check Result Note
Diff and changed code review passed All three changed files were read
Tests not run Results in the description are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the test suite, build, or check behavior on hardware. I reviewed all files marked reviewed in the manifest: core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_sample_multisample_target_tests.cmake, core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp, and docs/dev/debt/changes/fix-texture-dcc-owner.md. No files were excluded. The description reports Windows tests and limited title progress on a private integration branch; those results were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5916790016 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21479#pullrequestreview-5916790016). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T08:10:56Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change at `e23cc4cd5c84785531b899fa05171750c0e1a3b8` has no verified blocking defects; author-reported checks passed, but I did not run them. ## What I ran Read the prepared diff and all three changed files through `repo_read.py`. No commands or tests were run; I did not fetch the diff again. ## Results | Check | Result | Note | | --- | --- | --- | | Diff and changed code review | passed | All three changed files were read | | Tests | not run | Results in the description are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the test suite, build, or check behavior on hardware. I reviewed all files marked `reviewed` in the manifest: `core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp`, `core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_sample_multisample_target_tests.cmake`, `core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp`, and `docs/dev/debt/changes/fix-texture-dcc-owner.md`. No files were excluded. The description reports Windows tests and limited title progress on a private integration branch; those results were not independently verified. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-22 22:53:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T22:53:56Z.

Review: APPROVED


Reviewed — looks good

The change was reviewed at head 8ed6ed3b4e05d9fb21926a523c53c785920bca1f; no verified blocking defects were found in the changed implementation or tests. Author-reported test results were not rerun in this review.

What I ran

Read the prepared diff and all four changed files. No build or tests were run.

Results

Check Result Note
Changed code review passed All changed files read
Build and tests not run Results in description are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

Build and runtime behavior were not independently verified. The prepared bundle contained the full text for each changed file, and all four were read: core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_sample_multisample_target_tests.cmake, core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp, and docs/dev/debt/changes/fix-texture-dcc-owner.md. No changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014964313 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21479#pullrequestreview-6014964313). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T22:53:56Z. **Review:** APPROVED --- # Reviewed — looks good The change was reviewed at head `8ed6ed3b4e05d9fb21926a523c53c785920bca1f`; no verified blocking defects were found in the changed implementation or tests. Author-reported test results were not rerun in this review. ## What I ran Read the prepared diff and all four changed files. No build or tests were run. ## Results | Check | Result | Note | | --- | --- | --- | | Changed code review | passed | All changed files read | | Build and tests | not run | Results in description are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Build and runtime behavior were not independently verified. The prepared bundle contained the full text for each changed file, and all four were read: `core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp`, `core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_sample_multisample_target_tests.cmake`, `core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp`, and `docs/dev/debt/changes/fix-texture-dcc-owner.md`. No changed files were excluded. ## To get this to a good state Nothing is required.
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!21479
No description provided.