Repository navigation
feat(agc): model the color memory of PS4 multisampled 2D surfaces - #25802
Conversation
A 2D multisampled T# in a 2D color tile mode (display or thin) follows addrlib's color sample order: the 64 elements of each sample are stored together in the micro tile, after the pixel bits. A color mode's tile split is the sample split times the single-sample micro tile, with shadPS4's sample split of 2. PRT, linear and 1D color modes still throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MultisampledColorBytes gave no PS4 tile mode a multisampled color
footprint, so the first draw into a PS4 multisampled color target with
no CMASK threw ("initial multisample color footprint is not
implemented") and a fill over one was refused at its next use. And
createFilled, which builds the host target of a multisampled texture no
draw rendered to from its guest memory, took only PS5 tile modes. With
boykopovar#23672's PS4 multisampled color layout, inFAMOUS Second Son (CUSA00223)
stops there on a 1600x1800 2-sample texture whose memory is all zero.
For the PS4 thin and display 2D modes, MultisampledColorBytes now
returns the padded one-sample size times the stored fragments, the
slice size addrlib gives a macro-tiled surface
(ComputeSurfaceInfoMacroTiled; with EQAA it counts fragments), and
createFilled takes those modes, sized by the PS4 multisampled layout
(DescribeSurface). Memory that repeats one 32-bit value gives every
sample that value; createFilled refuses other PS4 contents itself.
A PS4 T# gives a texture's size and a PS4 CB its padded size. Over
memory a padded texture was built from, a fast-cleared draw, a CB clear
pass, a resolve or a sample-order read would not reuse that host target
and would make a second one, and a later read through the T# would get
the old samples. A PS4 target over a texture's host target it does not
match (size, format or samples) is therefore refused. PS4 1D and linear
targets keep no footprint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
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 as included in manifest.json: MultisampleTarget.cpp, TextureTiling.cpp, GcnColorTarget.cpp, tests/TextureTiling.cpp, GcnMultisampleColorFill.cpp, and the three docs/dev/debt/changes/*.md files. No changed files were excluded.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | All included changed files read |
| Automated checks | not run | Description reports author-run results |
| Console behavior | not run | PS4 hardware behavior remains unconfirmed |
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.json was 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.
|
Windows AMD run of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, AMD Radeon RX 6700 XT, driver 32.0.21045.29003.
AI-assisted: yes. |
|
Head Code. I found no problem.
Negative control. On
GPU.
The Validation.
Host:
AI-assisted: yes |
|
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.
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.
|
Independent NVIDIA Blackwell validation of
|
| OS | Windows 11 (x86-64) |
| Compiler | WinLibs GCC 16.2.0 (MinGW-w64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r3) |
| CMake / Ninja | 4.4.4 / 1.13.2, CMAKE_BUILD_TYPE=Release, BUILD_TESTING=ON |
| GPU | NVIDIA GeForce RTX 5070 Ti 16 GB, vendor=0x10de device=0x2c05, driver 621.24 |
| Validation layer | VK_LAYER_KHRONOS_validation 1.4.363 (Vulkan SDK 1.4.363) |
| Environment | ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, APS5_NO_PIPELINE_JOURNAL=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer |
| Head | 2e00b7e399 |
| Base for the control | 11f95ea8f6 (the merge base, the same one the PR body names) |
Build
cmake -S . -B build # exit 0, the new tests/execution/GcnMultisampleColorFill.cpp is picked up by the glob
ninja -C build agc_driver_gcn_multisample_color_fill_tests
Exit 0, with the usual MinGW .rsrc merge failure: multiple non-default manifests link warning.
Results
ctest --test-dir build -R '^agc_driver_gcn_multisample_color_fill$' -V, 3 consecutive runs:
| Run | Result | Device | Instance layer | Device layer | VUID- |
|---|---|---|---|---|---|
| 1 | Passed, 1.18 s | device=0x2c05 |
1 | 1 | 0 |
| 2 | Passed, 0.42 s | device=0x2c05 |
1 | 1 | 0 |
| 3 | Passed, 0.43 s | device=0x2c05 |
1 | 1 | 0 |
| implementation reverted | Failed (exit 1) | device=0x2c05 |
1 | 1 | 0 |
No was not found but was requested by env var VK_INSTANCE_LAYERS line, no skip: the suite prints its verdict and the multisample grid it measured on this device:
[gpu] largest sample location grids (vkGetPhysicalDeviceMultisamplePropertiesEXT): 1 samples 4x4, 2 samples 2x4, 4 samples 2x2, 8 samples 1x2; maxSampleLocationGridSize for every count 1x1
PS4 multisampled color fill tests passed: 2-sample 32-bit float 2D-tiled textures no draw rendered to (128x64, and 100x60 of pitch 512 whose 262144-byte footprint is padded) hold, in every sample, the value their footprint repeats, and a second value inside it is refused; a 2-sample PS4 target's first draw starts from the value its color memory repeats, reuses a texture's host target of its size and is refused over one of another size
Negative control (implementation reverted, test kept)
Keep the PR's test and revert only Graphics/src/MultisampleTarget.cpp and Graphics/src/TextureTiling.cpp to 11f95ea8f6. Rebuild is clean and the suite fails with the base behaviour:
1/1 Test #1857: agc_driver_gcn_multisample_color_fill ... ***Failed
AGC graphics: PS4 multisampled textures outside the depth tile modes are not implemented
So the new expectations are bound to the colour-memory model this PR adds, and not to pre-existing tile-mode support.
What this does and does not establish
Establishes, on native Windows 11 with GCC 16.2.0/UCRT in Release on an RTX 5070 Ti:
agc_driver_gcn_multisample_color_fillbuilds and passes on Windows 11 / desktop Blackwell with driver 621.24, 3/3 runs, validation layer inserted at instance and device, zeroVUID-lines;- the suite creates a real device and runs the fill/footprint/host-target-reuse expectations there (it prints this GPU's actual sample-location grids), rather than returning 77;
- reverting only the two implementation files makes it fail with the base "not implemented" message.
Does not establish:
- console behaviour: the repeat-value fill model is the PR's reading of PS4 colour memory, not a PS5 capture;
- the title runs (
inFAMOUSstarts, the breaks) mentioned in the PR body are not reproduced here: no title content on this machine; - other tile modes or formats: the suite covers 2-sample 32-bit float 2D-tiled, and the base message for everything outside the depth tile modes is what the control hits;
- no AMD/Intel GPU, no Windows 10 comparison: the PR's own Windows 10 / RTX 5080 result and this Windows 11 / 5070 Ti result agree, but both are NVIDIA.
Workspace cleaned up afterwards: temporary branch deleted, main left at origin/main, no local changes.
|
NVIDIA Ampere run of the Tested selection: no regression. Setup: NVIDIA GeForce RTX 3070, driver 616.56, Windows 11 Pro 10.0.26100, WinLibs GCC 15.2.0 r7, Release, Vulkan validation layer 1.4.363. Base
AI-assisted (Claude Code). |
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 feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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: feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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 feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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 (feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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 feat(shader): offer a 2D MSAA mode to GCN image loads #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 fix(libSceSysmodule): accept four PS4-only module ids in a PS4 process #18184, feat(shader): offer a 2D MSAA mode to GCN image loads #21961, feat(agc): sample and publish PS4 multisampled depth targets #25557, fix(shader): read the tenth opcode bit of PS4 VOP3 instructions #25598 and feat(agc): lay out PS4 multisampled color textures in 2D tile modes #23672 merged locally (feat(agc): lay out PS4 multisampled color textures in 2D tile modes #23672 and feat(agc): sample and publish PS4 multisampled depth targets #25557 conflict inTextureTiling.cpp; resolved by keeping feat(agc): sample and publish PS4 multisampled depth targets #25557's depth tile split and feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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 libSceGnmDriver: inFAMOUS Second Son (CUSA00223) stops at load on 47 imports that only libSceGnmDriverForNeoMode exports #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 feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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: feat(agc): draw PS4 color targets in the PRT tile modes #22514 (PS4 color targets in the PRT tile modes) intests/GcnColorTarget.cpp, next to the new test function, and my feat(agc): sample and publish PS4 multisampled depth targets #25557 inTextureTiling.cpp, the conflict it has with feat(agc): lay out PS4 multisampled color textures in 2D tile modes #23672; feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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: feat(agc): reuse a native multisample colour target and honour guest HTILE clears #6808 (it adds the PS5 Z_X and D_X cases tocreateFilled, whichmainalready has) and feat(libSceAgcDriver): support PS4 2D thick tile mode 20 for volumes #20786 (PS4 2D thick volumes, in feat(agc): lay out PS4 multisampled color textures in 2D tile modes #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