Skip to content

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

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
VicRaster:fix/texture-dcc-owner
Nov 25, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
VicRaster:fix/texture-dcc-owner

Conversation

@VicRaster

@VicRaster VicRaster commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Real-AMD cross-HW confirmation across 3 gens (Linux/RADV) — head e23cc4cd. The new --initial-texture-dcc / --texture-dcc-target cases are Linux-runnable (not #ifdef _WIN32; gating is GPU sample-count capability only — they ran, none skipped). ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 + KHRONOS validation layer:

  • Vega GCN5 (RADV VEGA10): agc_driver_initial_texture_dcc_{2,4,8} + agc_driver_texture_dcc_target_{2,4,8} → 6/6 PASS, 0 VUID
  • RDNA2 (RADV RAPHAEL): 6/6 PASS, 0 VUID
  • RDNA3 (RADV NAVI31): 6/6 PASS, 0 VUID

Negative control (RDNA3): removing the fix's import block in MultisampleTarget.cpp (createFilled, the !written && dccAddress != 0 && tileMode == RenderTarget path) → the undrawn R_X DCC sample throws exactly …whose compression metadata over a tile mode 7 surface is not modeled, is not implemented (falls through to the :1435 refuse), exit 1. Confirms the tests genuinely exercise the fix.

No cross-gen divergence: the per-sample CheckUniform DCC clear-code decode (key 0x40/0xc0→1.0, 0x80/0xc0→the other channel, both alpha placements, untouched-zero metadata) and the unsupported-state refusals (register-clear 0x20, mixed DCC, non-pipe-aligned, metadata/color stores, alpha/control/layout changes, drawn owner) matched identically on all three gens. So the DCC-import result is deterministic across AMD generations — this is execution confirmation, not a divergence. (Consistent with your debt note's "Console equivalence is unmeasured" — this confirms cross-AMD-gen host behavior, not PS5-hardware equivalence.)

AI-assisted: yes

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

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 19686 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L551

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 6808 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 7642 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
PR 9508 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
PR 9915 core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 10193 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
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 13928 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
PR 13929 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
PR 23252 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
PR 24049 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp

VicRaster and others added 2 commits November 17, 2026 00:25
Reuse the uniform DCC importer introduced by boykopovar#5939 when a compressed R_X texture is sampled without a resident owner. Preserve watched range and metadata generation checks, settle known-zero metadata before collecting writes, and refuse register clears whose colour is absent from the texture descriptor.

Cover 2, 4 and 8 samples, fixed clear codes, alpha placement, repeated sampling, metadata stores, untouched metadata and unsupported states.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfHqvesLHKGJRvAoHQuocc
A multisampled R_X DCC owner created from a texture descriptor holds no DCC control, CMASK or FMASK. Its first colour-target use carries them and was refused as a changed layout. Import the owner again under the full layout when no draw has rendered to it, after the existing store checks on its imported planes.

Other layout differences, drawn owners, stores since the texture import and later changes on a colour-target owner stay refused. Cover 2, 4 and 8 samples.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfHqvesLHKGJRvAoHQuocc
@VicRaster
VicRaster force-pushed the fix/texture-dcc-owner branch from e23cc4c to 543bdaf Compare November 16, 2026 14:38
@domx4q

domx4q commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Ran the multisample target tests with the Khronos validation layer on NVIDIA's proprietary Linux driver, to complement the Windows (RTX 3080 Ti) run in the PR.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 543bdaf1a3 merged onto main 89b0eef7ab with --no-ff, clean merge. Main baseline is a Release build of 89b0eef7ab on the same machine.

WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 ANYPS5_REQUIRE_DISPLAY=1 \
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_(sample_multisample_target|native_color_|native_fmask_|native_msaa_vertex_input|initial_texture_dcc_|texture_dcc_target_)' -V
main 89b0eef7ab this PR
Result 14/14 passed 20/20 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 14 20
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

The pattern covers every test of agc_driver_sample_multisample_target_tests, plus agc_driver_sample_multisample_target. The six new tests, agc_driver_initial_texture_dcc_{2,4,8} and agc_driver_texture_dcc_target_{2,4,8}, do not exist on main and pass with the PR. The 14 existing tests pass on both sides. Every device selection picked the RTX 4090.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@AbuMshMsh24

Copy link
Copy Markdown
Contributor

Heads-up: head 543bdaf1a3 merges onto main 0fa9357c04 without conflicts but does not compile. The merged MultisampleTarget.cpp:1517 calls guard(context, use, created.active, created.metadataValid, created.use), and #16483 (8dca5225d0, merged 17 Nov) added a std::shared_ptr<MultisampleTarget> parameter to guard, so GCC 15.2 reports "too few arguments" (built on main 42f6354612; the call and the signature are unchanged on 0fa9357c04). I couldn't run the tests here because of it.

AI-assisted: yes (Claude Code)

@birdmarty

birdmarty commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested on Forza Horizon 5 (PPSA22327 01.685.672), where this fixes a stop we hit.

Windows 11 Pro (build 26300), i9-9900K, RX 6800 (AMD 26.10.1, Vulkan 1.4.315), MinGW GCC 15.3.0 Release. Head 543bdaf, merged onto a local stack of open PRs for the game.

  • Without this PR: every run stopped after ~70 s at sampling the 3840x2160 multisampled texture 0x3eefb00000 of 4 samples, which no draw rendered to and whose compression metadata over a tile mode 7 surface is not modeled. A diagnostic showed no draw ever rendered to that surface, and its 294,912 DCC bytes were all 0x00.
  • With this PR: that stop is gone, and it did not come back in any of the 96 later runs, all with this PR in the stack.
  • On the head: check_conventions passes. The PR's tests (agc_driver_initial_texture_dcc_*, agc_driver_texture_dcc_target_*) and the native FMASK and colour-initial tests pass with the validation layer: 15/15, layer loaded 15 times, 0 VUID- lines. debt_fold --check fails only on docs-nkwebkit-drop-readded-count-lines.md, which fails the same way on its base 7c444b7.

With this and the other open PRs listed in #25152, the game now gets through the title screen and menus into the start of the intro.

So it fixes a real stop in this game, and its tests are clean here.

Not done: other GPUs, Linux, console comparison.

AI-assisted: yes (Claude Code).

@VicRaster

Copy link
Copy Markdown
Contributor Author

Thanks @AbuMshMsh24 — fixed in 8ed6ed3, in response to your build report.

Merged main at e080bf3781d4 and added created.shared_from_this() as the sixth argument to the texture-import guard() call, matching the created-target calls from #16483. The clean merge reproduced the reported “too few arguments” error before that correction; the corrected translation unit, graphics library and focused test targets build successfully.

Windows 11 build 26300, NVIDIA GeForce RTX 3080 Ti (610.88), WinLibs GCC 15.2.0 r7 UCRT, Release; Khronos validation 1.4.363.

Implementation Passed Failed Skipped Validation layer insertions VUIDs
Fixed PR, initial run 32 0 0 30 0
Main graphics implementation, same fixtures 26 6 expected 0 30 0
Fixed PR restored 32 0 0 30 0

The six failures on main are exactly agc_driver_initial_texture_dcc_{2,4,8} and agc_driver_texture_dcc_target_{2,4,8}, at the unmodeled tile-mode-7 DCC refusal. The focused set also includes native colour initial states, native FMASK, FMASK image reads, DCC clears, alpha-to-coverage, and #16483’s unwatch/publication-gate tests.

The paired main/restored comparison uses main’s exact MultisampleTarget.cpp with otherwise matching production sources, identical test executables, and fixed libc/libkernel binaries. Every GPU test selected the RTX 3080 Ti and loaded the validation layer; the two state-only tests open no device. Both implementations produce the same three existing Undefined-Value-ShaderOutputNotConsumed-DynamicRendering warnings in agc_driver_alpha_to_coverage.

All runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer. Conventions, main-sync, debt-fold and whitespace checks pass. These are local focused results.

AI-assisted: yes (Codex).

@birdmarty

Copy link
Copy Markdown
Contributor

We hit the same build error when we merged this onto our Forza Horizon 5 stack, and fixed it the same way: created.shared_from_this() as the sixth argument. The three guard(...) calls in our build are character-for-character the ones in 8ed6ed3, so the game results in my earlier comment were run with exactly this code and carry over to the new head.

AI-assisted: yes (Claude Code).

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants