fix(agc): refuse native MSAA index buffer reads #6590
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6590"
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 MarcZX10 on 2026-10-15T21:36:22Z.
What
Adds the live multisampled-target guard to fixed-function index-buffer reads after validating the guest range. The existing render-target alias check remains in place. Extends the multisample execution fixture to cover 16-bit and 32-bit index reads from a native target, the last in-range index words, and a valid neighboring index range; the target samples must remain unchanged. Updates the driver debt entry to list index reads among guarded accesses.
Fixes #6579. The issue report supplied the detailed Windows reproduction and an initial focused test/fix experiment; this PR adapts the guard and fixture to current
main.Related to #6498: that PR covers shader buffer descriptors; this change covers fixed-function index input. They share the existing multisample fixture and debt entry, but neither depends on the other.
Tested
agc_driver_sample_multisample_target_testssuccessfully. Building required a temporary localtemplateparser fix for the unrelated GCC 12 error inSrtDescriptorEvaluation.cpp; that edit is not in this PR.python3 tools/check_conventions.py --base upstream/main: passed.git diff --check: passed.Checklist
main; no open PR implements fixed-function index-buffer guard checks.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T22:07:15Z.
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.
main)docs/dev/debt/libSceAgcDriver.mdL122docs/dev/debt/libSceAgcDriver.mdL122-123core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppL5-6, L27, L29-31, L388-389core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppL5-6, L27, L29-31, L388-389core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppL5-6, L27, L29-31, L388-389core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppL5-6, L27, L29-31, L388-389core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppL5-6, L27, L29-31, L388-389Some 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.
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T23:07:47Z.
Review: COMMENTED
A run on hardware, since the description says no local GPU run was possible.
Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release,
BUILD_TESTING=ON,ANYPS5_GPU="NVIDIA GeForce RTX 3070". Head881facc4fmerged ontomain5d9dcc42d, no conflicts.GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux
agc_driver_sample_multisample_targetpasses 3/3. The fixture takes the host-import path on this driver (shared-import=1), and all four native-index cases (16/32-bit, base and edge) are refused withan index buffer read of ... overlaps multisampled color target ... whose samples are only on the host. The neighbouring index range draws the triangle.main'sDraw.cpp): fails 3/3 withAGC graphics: native indices missed 4 resident-image refusals(refused=0for all four cases). So the new test catches the missing guard on NVIDIA/Linux too, not only on the Windows RTX 5080 and AMD iGPU from #6579.ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 60: 591/593 pass, the same result as unchangedmainon this machine (agc_driver_stencil_ref_exportskipped,agc_driver_store_over_untrackedfails as onmain, #6385).Written with AI assistance (Claude Code). I ran the tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-15T23:09:08Z.
Code review location:
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp; line 340The 32-bit positive control can reuse the 16-bit triangle. I confirmed this by omitting only this draw when
indexSize == 4: the fixture still passes 5/5 fresh processes on each NVIDIA/AMD GPU.Please reset the destination before each width and verify it is clear before drawing. This six-line proposal does that through the existing native-clear path. It passes both GPUs; omitting the 32-bit draw with the correction now fails every run at the expected coverage assertion. The production guard itself passes the separate guard-removal controls.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-15T23:09:08Z.
Review: COMMENTED
Windows source review and Vulkan validation of PR head
881facc4fa50a49d4148b4f385b280b62886d144merged onto main5d9dcc42d2ec5401aebd089028b8d4d7410a77b4, plus only #6452's independent Windows test-alignment correction: compositionb3e7aa184. The submitted Draw.cpp and multisample fixture are unchanged in that composition. This is not a bare submitted-head run.Hardware: Windows 11 Enterprise 26200, WinLibs GCC 15.2r7 Release; NVIDIA RTX 5080 (
10de:2c02, 32.0.16.1062) and AMD Radeon integrated graphics (1002:13c0, 32.0.21036.18). Shader cache disabled; actual vendor/device recorded in every focused process.The production guard behaves as intended. I confirmed one fixture-oracle gap, detailed inline: omitting the 32-bit neighbor draw still passes 5/5 per GPU because the destination retains the 16-bit triangle. Six-line proposed fixture correction clears/materializes and verifies the destination before each width. It passes 5/5 per GPU, including a restored full build/check run; the same omitted-draw control with that correction now fails 5/5 per GPU at the expected zero-sample coverage assertion. Cppcheck 2.20.0 and clang-tidy 23.1.3 on Draw.cpp/the proposed fixture report no new selected diagnostic compared with the PR composition: three Cppcheck findings and one clang-tidy warning match in message/source context and remain unresolved. No parser/configuration errors or suppression. This is advisory comparison of the fixture proposal, not a clean-analyzer claim for main.
No fresh title replay, Linux runtime or PS5 console-equivalence claim. The issue's earlier Windows tests were mine; these are new tests of this PR composition. AI-assisted review/validation and proposed test correction: Codex.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T23:13:20Z.
Manual overlap check for the bot warning: #6571 changes the
CB resolve sample countdebt bullet, while this PR changes the adjacentMultisampled target guest accessbullet. They document independent fixes; there is no code dependency.git merge-treeconfirms a textual conflict indocs/dev/debt/libSceAgcDriver.mdbecause both edits are adjacent long lines. Whichever merges second should preserve both updated bullets when resolving/rebasing.Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-16T08:53:13Z.
Tested on Linux (Arch),
c++ (GCC) 16.2.1 20260810, Release,BUILD_TESTING=ON,mainat5d9dcc42d2ec5401aebd089028b8d4d7410a77b4. GPU tests ran on lavapipe (Mesa 26.2.2, llvmpipe with LLVM 22.1.8).This PR and #5881 break
agc_driver_sample_multisample_targettogether.mainpasses (2 of 2), each PR alone passes, and the pair fails (2 of 2). All four native-index cases are refused as expected, then the check after them fails:That is
CheckUniform(LoadSamples(device, source), Ones, "after native draw-input alias attempts")atSampleMultisampleTarget.cpp:358of this PR: the source target no longer holds the uniform value after the alias draws. #5881 rewrites the multisampled target write path (MultisampleTarget.cpp) and changes the fixture in the same test file, and this PR's fixture assumes the old behaviour. I did not find the exact cause.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T12:00:32Z.
Thanks for testing both changes together and reporting the standalone controls. I checked the current #5881 and #6590 heads: they merge without a textual conflict, so this is a runtime interaction, not a rebase issue. The failure is after the refused index attempts, when the test reloads the original target's samples; I won't treat the independent green runs as covering this composition.
Could you share the exact
mainand #5881 SHAs plus the command/checkout composition used? #5881 has had current head9666c3efor a while, but the report does not include the base pin. I can't run the Vulkan test on this host, so those pins would let us make sure we're investigating the same tree.Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-16T12:05:33Z.
Sure. All runs used these pins (fetched before the runs, unchanged since):
main:5d9dcc42d2ec5401aebd089028b8d4d7410a77b49666c3e102f46e4fa601e7c5c11712b3c83df858881facc4fa50a49d4148b4f385b280b62886d144Composition:
main, then #5881 merged, then this PR merged (two plainortmerges, both clean). The resulting tree isb8e65cb4e40e254c62f16ceb48608236b4672797. Each control wasmainplus one PR with the same commands.Lavapipe is Mesa 26.2.2 (llvmpipe, LLVM 22.1.8), with an Xwayland display for the device. The pair failed in all 4 runs on these pins, each time with the line from my report. One correction to my earlier comment: each PR alone passed in one run, not two;
mainalone passed twice.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T12:15:31Z.
I reconstructed your exact composition locally; the merged tree matches
b8e65cb4e40e254c62f16ceb48608236b4672797. The failure appears to be a fixture-order interaction inSampleMultisampleTarget.cpp, rather than evidence that the production write path corrupts the source: #5881 addsStoreSamples(... TargetDescriptor(block, ...), SampleWrites(oneSample)), andoneSamplewritesWrittento sample 1 of every pixel inblock. Later, #6590’sCheckNativeIndicesuses that sameblockassourcebut still asserts every sample isOnes. The reported(0.75, 0.25, 0.5, 1)is exactlyWrittenat the first stored sample. MovingCheckNativeIndicesbefore the new sample-store cases, or restoring the source to the expected uniform state before it, should remove this false failure while preserving the alias checks. I could not run the focused test here: this Linux host is an older Xeon lacking the required AVX2/BMI CPU features, and the test aborts at the project CPU guard. I have not claimed a local runtime reproduction.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T15:04:24Z.
Tested the fixture-order explanation on Linux with current heads, since no one had run it yet. Pins:
main896e1b2b7, then #5881 at6c6754861(its head has moved from 9666c3e), then this PR at881facc4f. Both merges are clean, giving tree fa5fec761. Release,BUILD_TESTING=ON, GCC 16.2.1, lavapipe (Mesa 26.2.4, llvmpipe LLVM 23.1.1), clean environment, no CPU-gate bypass.ctest -R '^agc_driver_sample_multisample_target$' --no-tests=error:sample 1 of pixel (0, 0) loaded (0.75, 0.25, 0.5, 1) after native draw-input alias attempts.CheckNativeIndices(*device, block, destination);:AgcDriver::Graphics::NoteColorMetadataFill(block.Address(), static_cast<std::size_t>(colorBytes), FillOnes);destination/ReleaseIndexDevice/CheckNativeIndicesblock to just beforeconst auto oneSample = ...also passes 3 of 3, and #5881's store checks after it still pass.With
ctest -V, both fixed versions print all fournative index ... refused=1lines, so the alias checks still run and are not skipped. This supports your reading. The failing value is the one #5881's store test writes toblock, and resetting the source or reordering the checks makes the test pass. So the failure is in the combined fixture, not the alias guard. It does not test the write path beyond what this test already covers. The assertion that fails is in this PR'sCheckNativeIndices, and the one-line refill uses only helpers this PR already uses, so it could go here whether #5881 merges first or not. The move only makes sense once #5881's store section is in the file. I tested both only on the combined tree.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:10:13Z.
Thanks for running the combined-tree check. The 3/3 failure on the merged tree and 3/3 passes after either restoring
blockor movingCheckNativeIndicesbefore the sample-store cases confirm the fixture-order interaction I suspected; the alias-refusal checks still execute in both passing variants. This is not evidence of a production write-path defect. Please apply the source reset or reorder the index check in this PR so the test remains stable when #5881 is present, then rerun the combined test.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:10:49Z.
I also checked Amoenus's inline fixture finding against the current review thread. It is independent of the
blocksource-state issue: the 32-bit positive-control draw can be omitted and still pass because the destination retains the 16-bit triangle from the previous case. Please clear/materialize the destination and assert it is empty before each index-width case (the six-line proposal linked in the inline review does this), then keep the source reset/reordering needed for #5881's sample-store fixture. The reported combined-tree runs support both changes as test-only corrections; they do not call the production guard into question.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:13:27Z.
Updated in
45fcdbaa3to address the two fixture findings:Validation:
git diff --checkpasses andagc_driver_sample_multisample_target_testsbuilds on Linux/GCC 12 after a temporary, revertedtemplatekeyword correction in unchangedSrtDescriptorEvaluation.cpp. CTest cannot run on this host: its Xeon E5-1620 v2 lacks AVX2/BMI1/BMI2 required by the project CPU gate. Current GitHub conventions, eligibility, intake and report checks pass; platform build jobs are skipped. No runtime result is claimed for this machine.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:23:04Z.
Code review location:
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp; line 340Fixed in
45fcdbaa3: each width now clears and verifies the destination before its neighboring draw, and the source metadata is restored before the final sample assertion. The focused fixture builds on Linux/GCC 12 after a temporary, reverted template-keyword correction in unchanged SrtDescriptorEvaluation.cpp; runtime CTest is blocked here by the Xeon CPU feature gate. The updated head has clean conventions/eligibility/intake/report checks. Thanks for the two independent fixture findings and their controls.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T15:39:33Z.
Reran the combined test on
45fcdbaa3as asked. Same setup as my last run, withmainnow at452494439: then #5881 at6c6754861, then this PR (clean merges, tree bd2539941), Release, GCC 16.2.1, lavapipe (Mesa 26.2.4), clean environment,ctest -R '^agc_driver_sample_multisample_target$' --no-tests=error -V.native index ... refused=1lines. This PR alone on the samemainalso passes 3 of 3.sample 2 of pixel (0, 2) loaded (0, 0, 0, 0), which the triangle covers). With the clear also removed, the same skip passes 3 of 3. So the clear closes the gap Amoenus found.sample 1 of pixel (0, 0) loaded (0.75, 0.25, 0.5, 1) after native draw-input alias attempts).One problem with where the refill sits. It runs after the alias attempts and right before the check that the source was not written by them, so that check can no longer see a write. To test this I added one line that zeroes the source's metadata just after the alias loop:
std::uint32_t missed = 0;): fails 3 of 3 (sample 0 of pixel (0, 0) loaded (0, 0, 0, 0) after native draw-input alias attempts).Suggested change: move the
NoteColorMetadataFill(source.Address(), ..., FillOnes)line from just before the finalCheckUniformto just beforestd::uint32_t missed = 0;. The source then starts clean even after #5881's store cases, and the check after the alias attempts still means something.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:42:51Z.
Fixed in
1271998d4: the sourceFillOnesmetadata refill now runs immediately before the alias attempts, soCheckUniformobserves any writes made during them instead of masking those writes. Thanks for the mutation checks; your compatible Linux/lavapipe run confirms the moved refill passes 3/3, and the added metadata invalidation fails 3/3. I builtagc_driver_sample_multisample_target_testslocally (GCC 12.2, with a temporary and reverted unrelated GCC 12templateworkaround); local CTest could not run the binary because this Xeon E5-1620 v2 lacks BMI1/BMI2/AVX2/FMA required by the project CPU gate.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:54:10Z.
Thanks for running the mutation check. You are right: the
FillOnesmetadata refill is immediately beforeCheckUniform, after the alias attempts, so it can mask writes made by those attempts. I am moving it before the alias-attempt loop and will rerun the focused fixture where the host permits; the refill must initialize the source before the test, while the post-attempt check must observe untouched metadata.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:54:52Z.
Correction after checking the published head:
1271998d4already moved the refill to immediately before the outer index-width loop, and the per-width neighbor draw precedes the alias attempts. The latest comment describes the earlier45fcdbaa3placement, which the follow-up commit fixed. I will verify the new invalidation mutation against the current published head before changing code; I do not want to move the refill without reproducing the claimed masking on this exact tree.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T16:03:48Z.
You're right:
1271998d4already has the refill abovestd::uint32_t missed = 0;. My 15:39 comment was about45fcdbaa3and went up before that commit. I re-ran the same mutation on1271998d4, and the refill does not need to move again for this check.Setup:
main452494439, then #5881 at6c6754861, then this PR at1271998d4(clean merges, tree fe901076d), Release, GCC 16.2.1, lavapipe (Mesa 26.2.4), clean environment,ctest -R '^agc_driver_sample_multisample_target$' --no-tests=error -V.native index ... refused=1lines.CheckUniform, after the alias loop:NoteColorMetadataFill(source.Address(), ..., 0u), which notes a pending zero fill on the source. Fails 3 of 3 (sample 0 of pixel (0, 0) loaded (0, 0, 0, 0) after native draw-input alias attempts). So the final check now catches a change to the source's metadata made after the alias attempts. This is the same simulated change as last time, not a real write through an alias.std::uint32_t missed = 0;removed: fails 3 of 3 (sample 1 of pixel (0, 0) loaded (0.75, 0.25, 0.5, 1) after native draw-input alias attempts).mainalso passes 3 of 3.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T16:08:51Z.
Thanks for rerunning the mutation on the published
1271998d4head and for clarifying that your earlier note predated that commit. The reported 3/3 baseline and negative-control results confirm the current refill placement catches the simulated post-attempt metadata change, while removing the initialization restores the original failure. No further source change is needed for this finding.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T23:02:38Z.
Thanks for the fixture-oracle correction. The current head
1271998d4clears the destination and checks it is uniform before each index-width neighbor draw, so residual samples from the first width cannot mask a missing draw in the second. The equivalent reset/check is present in45fcdbaa3; I did not cherry-pick the duplicate proposed patch. Your omitted-draw control and per-GPU results are useful confirmation of the fixture behavior.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-17T04:48:00Z.
Code review location:
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp; line 340@MarcZX100 Retested your current head
1271998d4merged without local fixes onto main16c607a93: exact composition1ec58a5cd. This includes merged #5881.agc_driver_sample_multisample_target, Vulkan required, project shader cache disabled:12 passing processes, maximum 0.90s. Every process verifies the selected adapter and all four base/edge refusals, neighboring 16/32-bit triangles in the same import, and the source's 1024 unchanged samples; no whole-test or alias subtest skips.
The source refill and per-width destination reset are present. A test-only omission control skips only the 32-bit neighboring draw: all three devices fail at the expected covered-sample assertion (pixel
(0,2), sample 2 remains zero). Restoring the composition passes on each. This confirms our earlier fixture finding is addressed.Full relinker/library targets and the fixture build on both OSes; conventions, registration and diff checks pass. No validation-layer or title run in this slice. This validates a current-main composition, not the PR's original base or sample publication. AI-assisted: Codex; author responsible.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-17T05:30:52Z.
@MarcZX100 Extending the same component coverage exposed a separate fixed-function vertex-input gap, reported in #7015. I've opened #7016 as a dependent follow-up to your exact #6590 head
1271998d4, preserving your commits and fixture corrections; yours is the prerequisite.The own production change is one guard call for planned vertex ranges. The index-guard parent still reproduces the vertex gap; the focused fix passes on NVIDIA, AMD and llvmpipe. Exact source pins, 25 current-head passes, 13 baseline controls and the four-file own diff are maintained in #7016. AI-assisted: Codex; author responsible.
Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-17T07:57:06Z.
First GPU runtime for this PR (the authoring host could not reach Vulkan).
RTX 3070, Ampere, driver 617.42, Windows 11 26200, WinLibs GCC 15.2.0, Release, ANYPS5_NO_SHADER_CACHE=1. Head
1271998d4, ctest serial fresh processes:7/7 pass on the PR head. The one-line Draw.cpp guard plus fixture holds on real NVIDIA hardware.