feat(agc): draw PS4 EQAA and one-fragment color targets #18176
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18176"
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 puridanish284 on 2026-11-10T18:24:11Z.
What
A PS4 (GCN) color target with fewer fragments than samples (
CB_COLOR_ATTRIBNUM_FRAGMENTSbelowNUM_SAMPLES) stopped the run withAGC graphics: GCN color targets with fewer fragments than samples (EQAA) are not implemented. It is the current stop of Grand Theft Auto V (CUSA00419) after 34.5 s, blocker 7 in #18084, which no issue or pull request tracked.DecodeGcnColorBuffernow reads these targets as the AGC path's decoder has since #9700 and #9450:samplesis the coverage sample count andeqaaFragmentsthe fragment count, so the target is drawn at its coverage samples as a host-resident target (#9892), with its color memory guarded over the fragments it stores. It needsCB_COLOR_INFOCOMPRESSIONand aCB_COLOR_FMASKbase, as on the AGC path, and throws without them.coverageSamplesset, drawn by the AGC path's one-fragment code. WithCOMPRESSIONits FMASK base is recorded, and that code guards it.The AGC path sizes both FMASK guards (
fmaskBytesandGuardOneFragmentFmask) with theSW_64KB_Z_Xlayout, which does not hold for GCN tiling: for a 64x64 target they guard 64 KiB where the PS4 FMASK is 4 KiB, so later guest data in that range would be refused. A GCN target now records the sizeCB_COLOR_FMASK_SLICEgives inColorTarget::gcnFmaskBytes, and both guards use it for GCN tile modes: (tile max + 1) × 64 pixels ofSiLib::HwlComputeFmaskBitsbpp = 1,numSamples = 8bpp = 2bpp = 4A slice is pitch × height × bpp × samples bits in addrlib's macro-tiled layout, and Mesa programs
TILE_MAXas pitch × height / 64 − 1 of the FMASK surface (ac_surface.c). The register fields are GFX7's from Mesa'sgfx7.json.gcnFmaskBytesis 32 bits (at most 2^22 tiles × 64 pixels × 32 bits = 1 GiB) and fills padding afterfmaskPipeBankXor, sosizeof(State)stays 952 and the pipeline journal, which records no FMASK field, is unchanged.Update, 2026-11-12, later array slices (
f348629c5c, withmainc85dcfd005merged in asb58d7b1f4d): aCB_COLOR_VIEWof slice n of a target storing 2 or more fragments started n single-sample slices pastCB_COLOR_BASE, as onmain, and its CMASK and FMASK at their bases. A slice holds all stored fragments, as addrlib sizes it with its samples (egbaddrlib.cpp), and Mesa programs the color, CMASK and FMASK bases for slice 0 and the layer only inCB_COLOR_VIEW(ac_descriptors.c, L1177), so the CB steps all three per slice. Slice n of a multisampled, EQAA or one-fragment target now starts n slices of its stored fragments past the base, and its CMASK and FMASK nCB_COLOR_CMASK_SLICEandCB_COLOR_FMASK_SLICEsizes past theirs; a single-sample target keeps its stride. A later slice of the 2D-tiled modes still throws here; #18721 places single-sample ones.Unchanged: FMASK contents are not modeled (the plane is guarded, never written); a one-fragment target with
FAST_CLEARstill throws as a single-sample fast clear; and a PS4 multisampled target, EQAA or not, still throws when it is first drawn without a fast clear (initial multisample color contents with CMASK require a modeled metadata import, orinitial multisample color footprint is not implementedwithout CMASK). The new test introduces its targets with a fast clear.Debt: the "PS4 (GCN) multisampled color targets" entry now covers EQAA and one-fragment targets, the FMASK size and what still throws, and a new "PS4 (GCN) color array slice strides" entry says where a later slice, its CMASK and its FMASK start.
Overlap:
tools/pr_overlap.py --branch claude/zealous-brown-h1u67ragainstmain9e3265259eand the 2011 open pull requests reported no overlap with those it could compare and failed closed on 39 that already conflict withmainand sharedocs/dev/debt/libSceAgcDriver.md,State.hpp,State.cpporMultisampleTarget.cppwith this branch. Merged intomainand into this branch, each of the 39 conflicts in the same files with the same number of hunks, except #14212, which puts a blank line between all debt entries and gets one more hunk on the entry this branch rewrites; a merge keeps both. Of them, #9748, #9895, #10249 and #11551 editState.cpp, none in the GCN color target decode or its FMASK fields, and #9895 and #11551 keep the EQAA refusal.GTA V's target is a 4-sample, 1-fragment target with
FAST_CLEARandCOMPRESSION(adam25136's run in the comments): this PR draws it as one stored sample and still refuses its fast clear, atPS4 color target fast clear (CMASK) is not implemented. #18177 materializes the fast clears of single-sample and one-fragment PS4 targets on top of this branch and depends on it; until this PR merges, #18177's diff includes it.Tested
Windows 11 (10.0.26200.9711) with WSL2 Ubuntu 24.04.5 LTS (kernel 6.18.54.1-microsoft-standard-WSL2), gcc 13.3.0,
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON, test targets only. Vulkan device: lavapipe (llvmpipe (LLVM 20.1.2, 256 bits), Mesa 25.2.8, Vulkan 1.4.318); the machine's GeForce RTX 3080 has no Vulkan driver inside WSL2. No title or console.agc_gcn_color_target(CPU): the newFewerFragmentsDecodechecks 4/2, 8/2, 8/4 and 4/1 targets (samples, coverage samples, fragments, FMASK base and size, no FMASK or CMASK on an uncompressed one-fragment target) and the four refusals.agc_driver_gcn_eqaa_color_target(PS4 shader mode, hand-encoded GFX7 shaders, guest memory below 2^40): fast-clears and draws a 4-sample 2-fragment target and a 4x target with the same two triangles. Their CB resolves are identical and hold 102 quarter- or three-quarter-coverage channels; the EQAA FMASK guard ends at the 4 KiBCB_COLOR_FMASK_SLICEgives, as does that of a compressed one-fragment target, and the color guard covers the two stored fragments only. It passes 3 of 3 runs.main946133f92f, the same test (without its twogcnFmaskByteschecks, as the field does not exist there) stops at the title's message:AGC graphics: GCN color targets with fewer fragments than samples (EQAA) are not implemented.a test read of 0x800051000+0x100 overlaps the FMASK of EQAA color target 0x800050000+0x10000, and the same for the one-fragment target).main946133f92fand on this branch, same machine, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationin the build directory:ctest -R '^(agc_gcn_color_target|agc_driver_eqaa_color_target|agc_driver_graphics|agc_driver_gcn_.*|agc_driver_.*multisample.*|agc_driver_cached_image_multisample_guard|agc_driver_sample_multisample_target)$' -E sampled_cache_budget -j 8 --timeout 300 -V: 28 of 28 pass onmain, 29 of 29 on this branch. The Khronos validation layer is Ubuntu's 1.3.275, loaded throughVK_LAYER_PATH; the loader logsInsert instance layer "VK_LAYER_KHRONOS_validation", and neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS. The only VUID in either log isVUID-VkDeviceCreateInfo-pNext-pNextat device creation (#17693: the layer is older than the repository's headers), with the same count in every test of both runs, plus one for the new test's device.python3 tools/check_conventions.py --base upstream/main: all conventions checks passed. The branch merges cleanly withmain9e3265259e, which changed none of its files.GcnColorTarget.cppdoes.b58d7b1f4d:agc_gcn_color_target's newMultisampledSlicesDecodedecodes slice 1 of a 4x array 4 single-sample slices past the base with its CMASK one CMASK slice past its base; slice 2 of a 4-sample 2-fragment array 2 × 2 slices past, with its FMASK and CMASK two of their slices past; slice 3 of a compressed one-fragment array 3 single-fragment slices past, with its FMASK three FMASK slices past; and slice 0 at the three bases. Removing the fragment factor, the CMASK offset or the FMASK offset each fails it.mainc85dcfd005. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS, and every test logs the sameVUID-ids and counts on both (VUID-VkDeviceCreateInfo-pNext-pNextat device creation, and 2 and 36VUID-vkCmdDraw-None-07629inagc_driver_native_multisample_depthandagc_driver_sample_mask_multisample), plus the new test's device-creation message.agc_gcn_color_target,agc_driver_graphics,agc_driver_gcn_eqaa_color_target,agc_driver_gcn_fast_clear_color_targetandagc_driver_gcn_color_array_slices.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)🤖 Generated with Claude Code