feat(agc): model the color memory of PS4 multisampled 2D surfaces #25802
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25802"
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 adam25136 on 2026-11-22T17:59:26Z.
What
AnyPS5 gives no PS4 tile mode a multisampled color footprint:
MultisampledColorBytes(MultisampleTarget.cpp) returns 0 for every PS4 target, and the paths that need the range a multisampled target's color memory covers refuse it:initial multisample color footprint is not implemented(PrepareMultisampleTargetForDraw_nid_no_patch);... of a multisampled target whose footprint is not modeled), and one that starts inside it is ignored;createFilled, which builds the host target of a multisampled texture no draw rendered to from its T# and its guest memory, takes only PS5 tile modes. With #23672, which lays out PS4 multisampled color textures in the 2D tile modes, a PS4 one throws... which no draw rendered to and whose tile mode 18 has no modeled multisampled color footprint, is not implemented(18 is AnyPS5'skGcnThin2D, GCN tile index 14); without it,DescribeSurfacethrows first (PS4 multisampled textures outside the depth tile modes are not implemented).This PR, for the PS4 thin and display 2D modes:
MultisampledColorBytesreturns the padded one-sample size times the stored fragments (bytestimes its fragments): the slice size addrlib gives a macro-tiled surface, padded pitch times padded height times bytes per element times samples (egbaddrlib.cpp L619-L620,ComputeSurfaceInfoMacroTiled), with fragments in place of samples for EQAA (L95-L98), and the rangeguardedColorBytesalready guards. So the first draw into a PS4 multisampled target with no CMASK starts from the value its color memory repeats (other contents thrownonuniform initial multisample color tiling is not implemented); a fill over the whole of it clears it, and an exact uniform one is absorbed by the host target instead of being stored to guest memory, as for a PS5 target; a fill over part of it, from its base or from inside it, is refused at its next use (partly covers). PS4 1D and linear targets keep no footprint: #23672 lays out PS4 multisampled color only in the 2D modes, and addrlib's linear path notes "No linear MSAA on real H/W" (egbaddrlib.cpp L211, Mesa 25.0.7's addrlib).createFilledtakes those two modes and sizes the surface withDescribeSurface, that is with #23672's layout. Samples interleave inside each micro tile there, so samples times one padded sample is the size, not the layout. As for a PS5 texture, memory that repeats one 32-bit value gives every sample that value. Other PS4 contents are refused increateFilleditself, with the range:whose PS4 color memory 0x...+0x... does not repeat one 32-bit value.requireNoTextureHost, called fromacquireand fromPrepareMultisampleTargetForDraw_nid_no_patch):the WxH PS4 multisampled color target 0x... over the WxH host target a texture built at 0x..., which it does not match in size, format or samples, is not implemented. A PS4 T# gives the texture's size and a PS4 CB its padded pitch and height, which differ whenever the texture is padded (inFAMOUS's texture is 1600x1800 in a surface padded to 1664x1856): without this, a fast-cleared draw would make a second host target over the same memory, and a later read through the T# would get the texture's old samples. A target that matches still reuses the texture's host target.alt_tile_modeandcompression_enbits (shadPS4 resource.h), so an alternate-tiled or compressed surface is sized and checked over the base layout's footprint (#23672's alternate tiling entry).PS4 multisampled color memory(the range and what uses it, the absorbed fills, that an undrawn PS4 surface holding its samples in its memory is inferred, word 6, the refused target) and changesMultisampled texture no draw rendered to(PS4 thin and display 2D textures, non-uniform PS4 memory throws).It depends on #23672, whose
DescribeSurfacelayoutcreateFilleduses; this branch carries #23672's commit, so its diff includes that change until #23672 is merged.Tested
Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 (r7), Release. The selected tests and the validation-layer runs ran on this change on
main35067f305f; the breaks and the inFAMOUS starts on it before a rebase, on9facbf1309; it is now on11f95ea8f6. None of themaincommits in between change a file this PR changes, and its changed lines are the same.agc_driver_gcn_multisample_color_fill(new): it calls the driver functionsShaderResources.cppcalls for a multisampled T#,MultisampleTargetFirstSample(a 2D image binding) and, once,MultisampleTargetTexture(a multisampled view), and reads every sample back. It does not dispatch a PS4 compute shader: onmainthe recompiler offers a PS4 image load no 2D MSAA mode (our #21961 adds one). The texture cases are PS4 T#s of 2-sample 32-bit float textures, thin 2D unless named:PrepareMultisampleTargetForDraw_nid_no_patch): over zeroed memory and over memory that repeats 1.5 every sample starts from that value, and a second value halfway through its color memory is refused;MaterializeMultisampleTargetClear).agc_gcn_color_target(newMultisampledFootprintsAndFills): a 1D-tiled 4x target has no footprint; the color memory of thin 2D 2x and 4x, display 2D 2x and thin 2D 4-sample 2-fragment targets is 2, 4, 2 and 2 times the size CB_COLOR_SLICE gives; a fill of all of a 4x target is taken as a clear, and fills of its first quarter or from inside it are refused (partly covers).main), the per-sample size taken as the whole surface, halved, or fromColorTargetLayoutof the T# size, the footprint one sample instead of one per fragment, the non-uniform PS4 refusal removed, the refusal over a texture's host target removed from the draw preparation or fromacquire, and the footprint given to every PS4 tile mode. Withmain'sMultisampledColorBytes, the first-draw case throwsinitial multisample color footprint is not implemented.tools/select_tests.pyselects for the 8 changed files (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), on this branch and onmain35067f305f(3,417, without the new test):agc_driver_bda_devicefails on both;agc_driver_frame_replay_rewind_storeandpad_timelinefailed only on the branch, and in 10 reruns each passed 9 times on the branch and 9 and 8 times onmain; the same 24 tests are skipped on both.VK_LAYER_KHRONOS_validation1.4.367 (VK_ADD_LAYER_PATH=<the layer's folder> VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer VK_LOADER_LAYERS_DISABLE=~implicit~ ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), the tests matchinggcn|Gcn|multisample|msaa|color_target|agc_driver_graphics$|agc_driver_recorder$|alpha_to_coverage,ctest -V: 84 on the branch and 83 onmain, all pass; the logs have 82 and 81Insert instance layerlines (tests that open no Vulkan instance, such asagc_gcn_color_target, have none), nowas not foundand no VUID.libc.prxandlibSceFios2.prxunwrapped with our local PS4 variant oftools/unwrap_self.py, converted with each build's relinker (--windows --registry --trace-imports), two starts of up to 60 s per build, no input. Both builds aremain9facbf1309with #18184, #21961, #25557, #25598 and #23672 merged locally (#23672 and #25557 conflict inTextureTiling.cpp; resolved by keeping #25557's depth tile split and #23672's color tile split) and one local relinker change in no PR: a title that needslibSceGnmDriver.prxalso loadslibSceGnmDriverForNeoMode.prx, so the Neo-mode GNM exports it imports resolve (see #17581).0x2f2fb2100withsampling the 1600x1800 multisampled texture 0x3075c0000 of 2 samples, which no draw rendered to and whose tile mode 18 has no modeled multisampled color footprint, is not implemented;a one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is unsupported for points or lines and with alpha-to-coverage, ..., which is outside this PR. The time to the stop is about the same; what changes is where they stop.main7eb79b0c48, and for the T# on9facbf1309) showed that no draw binds a multisampled PS4 color target before that stop, that the texture's 23.6 MiB footprint (pitch 1664, height padded to 1856, 4 bytes, 2 samples) and the 8 MiB after it hold only zeros, so the zeros reach 2,486 rows at that pitch, past any padding of 1,800 rows, and that its T# is03075c00 10400000 71c1c63f e4e10204 00cfe000 00000000 01000000 00000000: 1600x1800 of pitch 1664, 2 samples, tile index 14, a 32-bit format, and word 60x01000000, soalt_tile_modeis set andcompression_enis clear. The texture is alternate-tiled, like the color targets #23672's entry records for this title, and not compressed, so its zeros are its samples whichever of the two footprints applies.python tools/check_conventions.py --base origin/mainwith this title and description: all checks passed.python tools/pr_overlap.py --branch feat/gcn-msaa-color-fill(2,372 open pull requests probed): 2 that merge withmainconflict with this branch on nearby lines: #22514 (PS4 color targets in the PRT tile modes) intests/GcnColorTarget.cpp, next to the new test function, and my #25557 inTextureTiling.cpp, the conflict it has with #23672; #23672 itself, whose commit this branch carries, is listed for the new debt fragment both add. Of the 13 that conflict withmainand were not compared, 2 change lines inside this branch's hunks: #6808 (it adds the PS5 Z_X and D_X cases tocreateFilled, whichmainalready has) and #20786 (PS4 2D thick volumes, in #23672'sTextureTiling.cpphunk). None of them sizes PS4 multisampled color.Checklist
main; no other open PR implements the same functionsNotImplemented_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)AI-assisted: Claude Code found the cause, wrote the change and its tests, ran the tests and the inFAMOUS starts, and drafted this description; separate review agents checked it.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T18:25:15Z.
Review: APPROVED
Reviewed — looks good
The inspected changes consistently model PS4 2D multisampled color footprints and reject the unsupported cases; the reported checks are author-reported and were not run in this review.
What I ran
Reviewed head
2e00b7e399b088b3f98140fb7272f3c1459880db; no commands or tests were run. Read all seven changed files listed asincludedinmanifest.json:MultisampleTarget.cpp,TextureTiling.cpp,GcnColorTarget.cpp,tests/TextureTiling.cpp,GcnMultisampleColorFill.cpp, and the threedocs/dev/debt/changes/*.mdfiles. No changed files were excluded.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported test runs and inFAMOUS starts were not independently verified. No PS4/PS4 Pro measurement was performed; the documentation identifies the undrawn-surface sample interpretation and PS4 color layout as unverified on console.
files.jsonwas not available as a review document, but the review folder listing and manifest enumerate seven changed files, all included.To get this to a good state
Nothing is required.