Skip to content

fix(agc): submit tiled multisample test targets before destroying them - #4907

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
oneandonlydean:up4/fix-msaa-guest-access-segv
Oct 13, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
oneandonlydean:up4/fix-msaa-guest-access-segv

Conversation

@oneandonlydean

Copy link
Copy Markdown
Collaborator

What

agc_multisample_guest_access segfaults in the Linux CI job on current main (llvmpipe). It started with #4199, which added three tiled cases to multisampleGuestAccessTests in tests/Recorder.cpp.

Each new case calls MultisampleTargetView, which records the new image's layout transition and clear into the recorder's open batch, and then ClearMultisampleTargets, which destroys the image. Nothing is submitted in between. The recorder submits that batch later (at the latest in ~Recorder), so the queue executes commands for images that no longer exist. lavapipe runs the commands on the CPU and crashes in its queue thread while the main thread waits in Recorder::~Recorder -> Sync.

The 2x case also ran without checking that the device renders 2x color. lavapipe reports 1x and 4x only, so the target constructor throws "the device cannot render color with the target's sample count" there. The 8x case already has this check.

The test passed for the testers on Windows NVIDIA and Linux RADV, which support 2x and did not crash on the stale commands. #4199 was merged without a full build, so the llvmpipe job never ran on it.

The fix is in the test only:

  • each tiled case submits and waits (Submit, WaitQueue, Sync) before ClearMultisampleTargets, as the linear case above them already does;
  • the 2x case runs only when framebufferColorSampleCounts has VK_SAMPLE_COUNT_2_BIT.

guard() in MultisampleTarget.cpp is unchanged. The emulator's own teardown syncs and destroys the recorder before ClearMultisampleTargets.

Tested

  • Ubuntu 24.04 container, GCC 13.3, Mesa 25.2.8 llvmpipe (LLVM 20.1.2), Release with BUILD_TESTING=ON:
    • current main (c13dc7e): agc_multisample_guest_access segfaults, the same as the CI Linux job;
    • with only the submit added, it fails cleanly on the 2x sample count;
    • with this PR it passes, 3 of 3 runs.
  • Same container, ctest -R "agc|shader" with this PR: 453 of 457 pass. The four failures are agc_driver_prepared_shaders*, which this does not touch; they pass in the CI Linux job and were not rerun on unmodified main in this container.
  • Not run on the host GPU.
  • python3 tools/check_conventions.py passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

The tiled cases of agc_multisample_guest_access destroyed each target while its layout transition and clear were still recorded, so the recorder later submitted commands for destroyed images and lavapipe crashed executing them. Each case now submits and waits first, as the linear case does. The 2x case runs only when the device renders 2x color, like the 8x case.
@oneandonlydean oneandonlydean self-assigned this Oct 13, 2026
@oneandonlydean
oneandonlydean merged commit 6124bf0 into boykopovar:main Oct 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant