fix(agc): keep DCC keys in the merge descriptor of a color target #28350
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28350"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by zeezey on 2026-11-30T09:03:52Z.
What
With #28197's blend into 4_4_4_4 targets and #28311's DCC 4_4_4_4 targets, PPSA38500's blend into its DCC-compressed 4_4_4_4 target (CB_COLOR_INFO
0x1000884c: format 19, SWAP_ALT, BLEND_CLAMP, DCC_ENABLE; 2560x1440, one sample) still throws inExportTargetMerges:only single-level multisampled surfaces and surfaces without metadata have a texture descriptor encoding.EncodeTextureResourcebuilds the T# that the pixel-interlock merge binds as a storage image, and it refused every surface with DCC keys. lgqdaxia suggested that this follow #28311 and #28197. This PR is based on #28197's headcf8530434emerged with #28311's head9f73b6670c(the merge,ad224f36ee, has no conflicts), not on currentmain(see Depends on). Two commits on top of that merge:fix(agc): keep DCC keys in the merge descriptor of a color target, the change.EncodeTextureResourceencodes a single-sample surface's DCC keys the wayDecodeTextureResourcereads them: META_DATA_ADDRESS in word 6 bits 24-31 and word 7, COMPRESSION_EN (word 6 bit 21), ALPHA_IS_ON_MSB (bit 22) and META_PIPE_ALIGNED (bit 19). A key address that is not 256-byte aligned, or that is at or above 2^48 (so its 256-byte unit does not fit those 40 bits), throws (the surface's DCC key address has no texture descriptor encoding). A surface without keys encodes as before.TargetMergeSurface(a merge into a 2D array color target with DCC keys is not implemented: the merge surface starts at the array, the keys at the viewed slice). It threw inExportTargetMergesbefore, with the message above, and with resident targets the draw refuses every DCC 2D array view, merge or not (a slice of a 2D array color target with DCC, CMASK or an attachment proxy has no resident array image).APS5_NO_RESIDENT_TARGETS, a proxied target or an unrecorded draw).changed the bytes after its 512 DCC keys). Reaching it takes keys at the same address whose pipe alignment changes between draws.agc-merge-dcc-descriptor.mdrecords the multisample, 2D array, mip and non-resident limits.lgqdaxia tested this commit as
7e46c8259ad3(see Tested), on top ofc58e1457c183, #28311's first commit before its review changes, on #28197's head. Since then it was rebased onto the mergead224f36ee, and review here added the 2D array refusal and the shorter debt entry.GuestTextureResource.cppand its test are unchanged.PackedUnorm4444DccTarget.cppconflicted with #28311's test commit, where both add cases and changeDraw; the resolution keeps both:Drawtakes the target by value and keeps #28311'sbeforeDrawhook, the six-caseKeyCasesandFillUnderKeysmove out ofClearTestsbeside #28311's cases, and the final line keeps both notes. Intests/Graphics.cpponly the surrounding lines differ.test(agc): cover more merges into DCC targets and DCC keys in texture descriptors, tests only:agc_driver_unclamped_normalized_blenddraws an unclamped blend (SRC_ALPHA / ONE_MINUS_SRC_ALPHA for color, ONE / ONE_MINUS_SRC_ALPHA for alpha, a source with out-of-range channels) into a one-mip DCC 8_8_8_8 UNORM target under each key state (uncompressed, 0000, 0001, 1110, 1111, register clear), once with pipe-aligned and once with unaligned keys, each in its own memory. The blend reads the destination in every channel, so each clear value gives a different result, and each result differs from a clamped blend. It compares every texel inside the scissor with the CPU blend over the destination the keys describe and every texel outside it with that destination, and checks that the keys end as 0xff and the bytes after them stay unchanged. Every draw of the test checks that its merge descriptor names the target's keys, alpha position and pipe alignment.agc_driver_packed_unorm4444_dcc_targetadds a partial write of red and blue under each key state and component swap: the unwritten nibbles keep the cleared value inside the scissor, and the whole texel keeps it outside.agc_driver_graphicschecks the merge descriptor of an unclamped blend into a DCC 8_8 UNORM target and into mip 1 of a four-mip DCC 8_8 UNORM chain; that a merge into slice 0 or 1 of a four-slice DCC 8_8 UNORM array is refused; and encode/decode round trips with DCC keys of a 2D array (slices 2 to 5), of one mip of a chain and of a key address above 2^40, with a key address of 2^48 refused.No new switch.
Tested
lgqdaxia tested the first commit as
7e46c8259ad3(onc58e1457c183, on #28197's head) on an NVIDIA GeForce RTX 3080 Laptop GPU (driver 621.14, Windows 11): all 24 blends on the resident target matched the 4-bit reference across four component orders and six initial states, and with resident targets disabled the clear still passed and the blend was refused as expected; both Vulkan tests passed with no skips or validation errors. That run predates the rebase ontoad224f36ee, the 2D array refusal and the second commit.Here: Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release,
-DBUILD_TESTING=ON -DANYPS5_RELINKER_CLI=ON -DANYPS5_VIDEO_OUT_TEST_DRIVER=windows, NVIDIA GeForce RTX 4090 (driver 621.24), Khronos validation layer from Vulkan SDK 1.4.363. Every run below except thebuild.ymlsteps hadANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer. The base (ad224f36ee) and this PR were built in separate build directories with the same toolchain and options.Most runs below are of
914fdd576c, this PR's head before a second review. The head2d889dbc20differs from it only inKeyedTargetTestsofUnclampedNormalizedBlend.cpp(each pass gets its own target and keys, and the bytes after the keys are checked) and in one sentence of the debt fragment, so of the test executables onlyagc_driver_unclamped_normalized_blend_testsis built from changed sources. The runs of2d889dbc20come first.2d889dbc20:agc_driver_unclamped_normalized_blend, 20 times alone: all passed. Once under each of the 14 switches listed below: it passes under all butAPS5_NO_RESIDENT_TARGETS, where it fails witha partial write of a packed color target is merged into its resident image by a recorded draw only, as on the base. NoVUID-,SYNC-HAZARDorValidation Errorline.The 106 tests of the changed test executables (named below) once, one at a time: all passed, with no
VUID-,SYNC-HAZARDorValidation Errorline.The complete
ctest(no-R,-j 8,--timeout 300): 7428 tests, 7388 passed and 36 skipped, the same 36 as on the base. Not passing:agc_driver_linear_target_import_creation, as on the base;agc_driver_rect_list_vertex_layer, an access violation on a thread whose stack holds only NVIDIA driver (nvoglv64.dll) frames;frame_capture_minimize, a Python tool test, at its 20 s timeout; this PR changes nothing undertools/;guest_pthread_mutex_contention, at its timeout.Alone, 5 times on each side, alternating:
agc_driver_rect_list_vertex_layerpassed 5 of 5 here and 5 of 5 on the base,frame_capture_minimize4 and 5,guest_pthread_mutex_contention2 and 3. The layer is inserted 2172 times, 4 fewer than on the base, because the crashedagc_driver_rect_list_vertex_layerrun opened 13 of its 17 devices. NoVUID-,SYNC-HAZARDorValidation Errorline. The 99Validation Warninglines are the 89 of the base and the 10 described in the next bullet.The NVIDIA validation gate,
tools/vulkan_validation_gate.py --repeat 20, against the base:libs. Left out are the 3 that skip on Windows (agc_driver_msaa_dcc_compared_import_2,_4and_8) and the 16agc_driver_packed_fma_f16_rounding_*tests, whose 60 sTIMEOUTthe gate refuses.VUID-orSYNC-HAZARDdiagnostic and no problem.Undefined-Value-ShaderOutputNotConsumed-DynamicRenderinginagc_driver_packed_unorm4444_dcc_target: 10 per run (the layer's duplicate-message limit), 200 in all.it writes to [Output variable, Location 0, "out_mrt_0"] but there is no VkRenderingInfo::pColorAttachments[0] (imageView is VK_NULL_HANDLE) and this write is unused. It comes from8d6d864053onmain, which leaves a merged target out of the draw's attachments, so the pixel shader's export of that target is a dead write.agc_driver_packed_float_blend,agc_driver_packed_unorm4444_partial_writeandagc_driver_unclamped_normalized_blend.agc_driver_packed_unorm4444_dcc_targethas no merging draws; this PR adds its 24 blends and 24 partial writes, which would throw on the base's code.Validation Warning,VUID-,SYNC-HAZARDorValidation Errorline. With the duplicate limit raised (VK_LAYER_DUPLICATE_MESSAGE_LIMIT=100000), one run gives 48 such lines here, one per merging draw, and none on the base.914fdd576c, the completectest(no-R,-j 8,--timeout 300) on the base and on this PR: 7428 tests on each, 7391 and 7388 passed, 36 skipped on both. The layer is inserted 2176 times on each side, no line reports it missing, and neither log has aVUID-,SYNC-HAZARDorValidation Errorline. TheValidation Warninglines are 89 on the base and 99 here; the 10 more areUndefined-Value-ShaderOutputNotConsumed-DynamicRenderinginagc_driver_packed_unorm4444_dcc_target, whose merged draws (blends and partial writes) use a color write mask of 0 (the warningagc_driver_packed_unorm4444_partial_writegives on both sides).agc_driver_linear_target_import_creation, which then failed 5 of 5 times alone on each side.guest_pthread_mutex_contention(timeout),guest_select(exit 0xc0000409) andwindows_write_watch. Alone, alternating with the base:guest_pthread_mutex_contentionpassed 5 of 5 on this PR and 4 of 5 on the base,windows_write_watch5 of 5 and 4 of 5, andguest_select14 of 15 and 15 of 15.agc_driver_draw_recipe_data(clearing the resource cache did not expire the recipe template), which passed on the base; alone, alternating, it then passed 14 of 15 times on914fdd576cand 15 of 15 on the base. Neither it norguest_selectreaches the changed code:EncodeTextureResourcebuilds only merge descriptors.914fdd576c, every test matchingdcc|4444|clear|blend|interlock|merge|unclamped|packed|agc_shader_memory|agc_driver_graphicsplus the 106 tests of the changed test executables (agc_driver_graphics_tests,agc_driver_packed_unorm4444_dcc_target_tests,agc_driver_unclamped_normalized_blend_tests, andagc_shader_memory_tests, which buildsGuestTextureResource.cpp), 286 tests, 20 times withctest -j 8, alternating between the base and this PR. Every run passed with the same 3 skipped on both sides (agc_driver_msaa_dcc_compared_import_2,_4and_8, Linux comparison mode only), except the last run on this PR, whereagc_import_settle_initial_dcchit its 30 s timeout while other builds and test runs loaded the machine; it then passed 5 of 5 alone on each side. Each run inserts the layer 180 times, with noVUID-,SYNC-HAZARDorValidation Errorline; theValidation Warninglines are 30 per run on the base and 40 here (the 10 above).914fdd576c, the same 286 tests once on each side under each of 14 switches read on these paths:APS5_NO_RESIDENT_TARGETS,APS5_NO_KEY_FAST_PATH,APS5_NO_TARGET_MEMO,APS5_NO_DCC_MIP_FAST_CLEAR,APS5_KEYS_FILL_CLEAR=1,APS5_CPU_DCC_KEYS,APS5_NO_KEYS_FILL_MEMO,APS5_NO_DCC_WORD_SCAN,APS5_NO_RECORDED_CLEAR,APS5_NO_PASS_ATTACHMENT_MEMOwithAPS5_DRAW_PIPELINE=1, three that the storage binding of a merge descriptor reads (APS5_NO_STORAGE_DEDUPE,APS5_NO_OWN_IMAGE_REFRESH,APS5_NO_DCC_PRESYNC), andAPS5_NO_KEYS_RESCAN, which the sampled lookup of a DCC surface reads. The tests that do not pass are the same on both sides under every switch (7, 5, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1 and 0; underAPS5_NO_RESIDENT_TARGETSthey includeagc_driver_unclamped_normalized_blend, whose merges need resident targets on both sides), and no log has aVUID-,SYNC-HAZARDorValidation Errorline.914fdd576c, the 106 tests of the changed test executables, 20 times in a row, one at a time: every run passed, with noVUID-orValidation Errorline. The longest wereagc_driver_graphics(22.24 s) andagc_graphics_profile_draw(21.72 s); the changed execution tests took at most 1.21 s (agc_driver_unclamped_normalized_blend) and 1.19 s (agc_driver_packed_unorm4444_dcc_target).Linux: Ubuntu 24.04 (a chroot in WSL 2), GCC 13.3.0, Ninja, Release, lavapipe from Mesa 25.2.8 (llvmpipe, LLVM 20.1.2), Khronos validation layer from Vulkan SDK 1.4.335, the same four variables.
914fdd576c, the completectest(-j 6) on the base and on this PR: 7321 tests on each, 7095 passed and 219 skipped on both, and the same 7 fail on both (agc_driver_flat_aperture_lds_bounds,agc_driver_gcn_multisample_color_fill,agc_driver_image_d16_load,agc_driver_image_filter_mode_three,agc_driver_image_sample_lod_clamp_shader_lane,agc_driver_upload_cache_read_only_flush,agc_driver_write_back_guest_newer). The layer is inserted 2114 times on each, with noVUID-,SYNC-HAZARDorValidation Errorline; theValidation Warninglines are 86 and 96, the same 10 more as on Windows.914fdd576c: the area set above (191 tests on Linux) passed on both sides. The 104 of the 106 tests of the changed test executables that Linux registers, 20 times one at a time, all passed;agc_driver_graphicstook at most 24.62 s and the changed execution tests at most 3.53 s. The 107 tests of the changed executables once: all passed. The 104 under each of the 14 switches, on this PR only: all passed exceptagc_driver_unclamped_normalized_blendunderAPS5_NO_RESIDENT_TARGETS(on Windows it fails there on both sides).2d889dbc20:agc_driver_unclamped_normalized_blend20 times alone, and the 104 tests once: all passed. The changed test under each of the 14 switches, on this PR only: it passes under all butAPS5_NO_RESIDENT_TARGETS. The completectest: 7321 tests, 7094 passed and 219 skipped; the same 7 fail as on the base, andguest_pthread_mutex_contentionhit its 60 s timeout. Alone, under the same load, it then timed out 6 of 6 times on the base and 6 of 6 on this PR (rebuilt in turn in one build tree); in the earlier complete runs it passed in 26.79 s on the base and 55.12 s on914fdd576c, close to its 60 s limit. The layer is inserted 2114 times, with noVUID-,SYNC-HAZARDorValidation Errorline, and 96Validation Warninglines.VUID-,SYNC-HAZARDorValidation Errorline in any Linux run.914fdd576c, the pull-request steps of thebuild.ymlwindows job, run here withmain's copies of the tools over the 20 files this PR changes againstmain(including #27966's, #28197's and #28311's), without the four validation variables as in CI:check_test_registration.py buildpasses,build_mingw_host_only_tests.pybuilds its 83 host-only test executables, andbuild_changed_guest_tests.pyran 6208 tests, all passing butagc_driver_linear_target_import_creation, which fails on the base too.python3 -I tools/check_conventions.py --base ad224f36ee(and with the default base, which covers #27966's, #28197's and #28311's commits too), withmain's checker, with this title and body, passes.tools/debt_fold.py --checkandtools/check_test_registration.py buildpass. The branch merges into currentmain(1b8f79a5b5) without conflicts, and #28197's headcf8530434eand #28311's head9f73b6670care unchanged (checked 2026-11-30).tools/pr_overlap.py --branch, frommain(1b8f79a5b5), reports three line overlaps, none on this PR's own lines:State.cpp,SpirvModuleEmitter.cppandShaderInputInfoBuilder.cppthat #27966 and #28197 change;SpirvModuleEmitter.cppthat #28197 changes;A1R5G5B5_UNORM_PACK16entry goes on the same line of the DCC layout table as #28311'sR4G4B4A4_UNORM_PACK16entry.It ends with "overlap check failed closed", because 82 older open PRs that conflict with
maintouch the same files and could not be compared.Open PRs that touch the same files, all merging with this branch without a textual conflict: #28192 (GFX10 single-component DCC clears) changes how
FillDccClearfills one-channel formats, which this PR does not change (its new tests use two- and four-channel targets); #28218 and #28229 (quad-masked early tests) changetests/Graphics.cppin other functions.Not tested: an execution test of a merge into one mip of a mipmapped DCC target (checked through its descriptor only); a merge into a SNORM DCC target; a merge into a two-channel DCC target in an execution test (its descriptor is checked in
agc_driver_graphics); an eviction of the resident image between the target's lookup and the merge's, where the descriptor's keys decide the new image's contents; multisampled DCC merges (refused); a PPSA38500 boot of this exact branch; a console; other GPUs.Checklist
cf8530434emerged with #28311's head9f73b6670c, not on currentmain(see Depends on); no other open PR implements the same functions (see the overlap check under Tested)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)7e46c8259ad3, before the rebase, tested by lgqdaxia)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T09:16:29Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (1)
Advisory architecture findings (1)
db18a578-65b2-431d-835b-07b35e82472cReviewing files that changed from the base of the PR and between
0f107f9812and2d889dbc20.core/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestTextureResource.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/GuestTextureResource.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_packed_unorm4444_dcc_target_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444ColorTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444DccTarget.cppcore/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cppcore/libs/prx/libSceAgcDriver/tests/execution/UnclampedNormalizedBlend.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppcore/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cppdocs/dev/debt/changes/agc-4444-color-blend.mddocs/dev/debt/changes/agc-dcc-4444-color-targets.mddocs/dev/debt/changes/agc-merge-dcc-descriptor.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T09:22:18Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and supplied test evidence support merging, with one changed test source excluded from the review folder and checked through the pinned reader.
What I ran
Reviewed head
2d889dbc20abe018e3d2b732798f27058856266c. Read the prepared description, commits, manifest and diff, plus targeted repository ranges usingrepo_read.py. No commands or tests were run during this review; the test runs below are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. The PR reports passing changed tests and broad Windows/Linux test runs, with documented existing or intermittent failures. I reviewed all 20 changed files: 19 were included in the prepared review folder;
core/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded for size and its relevant changed ranges were read through the pinned reader. No other changed files were excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T06:05:23Z.
Review: APPROVED
I read the diff at
2d889dbc20. Windows 11, GCC 15.2, merged intomainatcf556db18c3together with other open PRs (so not an isolated build), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validationon an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).agc_driver_unclamped_normalized_blend, the threepacked_unorm4444tests and the 60 tests ofagc_driver_graphics_tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has aVUID-orSYNC-HAZARDline.main's):agc_driver_unclamped_normalized_blendfails on both GPUs: "only single-level multisampled surfaces and surfaces without metadata have a texture descriptor encoding".The macOS relinker job is red (2026-11-30). This PR doesn't touch the relinker and that job failed the same way on other such PRs around then, but I didn't read its log.
Not checked: a title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:44:26Z.
Review: COMMENTED
The expanded tests check pixels and final DCC keys for one-level targets, and check the mip-chain case by inspecting the encoded descriptor. Could the mip-chain case also draw into mip 1 and verify that mip 0 and its keys stay unchanged? The descriptor round-trip confirms the selected level and the key address survive encoding. The draw would also exercise how the storage merge locates the keys for that level.
Source review at
2d889dbc20. A trial merge onto484e8e6b77succeeds. Vulkan execution on that base is pending.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.