Skip to content

fix(agc): let a native multisample depth clear supersede one no use retired yet - #124

Merged
utkuhalis merged 1 commit into
mainfrom
fix/msaa-depth-clear-overlap
Nov 13, 2026
Merged

utkuhalis merged 1 commit into
mainfrom
fix/msaa-depth-clear-overlap

Conversation

@utkuhalis

Copy link
Copy Markdown
Collaborator

Plants vs. Zombies: Replanted (PPSA29802) stopped about two minutes in with AGC graphics: overlapping native multisample depth clear transitions are not implemented (issue #123).

Cause

NoteHtileDepthClear and NoteDepthMetadataFill in Graphics/src/DepthSurface.cpp refused a second whole-HTILE clear of a native multisample depth target while the first was still pending (noted, recorded or filled, but not yet retired by a draw or a sampling).

What changes

Both clears cover the whole HTILE and run in command order, and every use of the surface retires its clear first (settlePendingHtileClear, then CheckCurrent). So nothing saw the earlier clear, and the later one supersedes it, as on the GPU. The transition starts over with the newer clear, which needs the same proof at its use as a first clear.

  • clearPending counts the noted dispatches not yet recorded, so two noted before either is armed both arm, and the clear generation is the newest recorded one.
  • clearCompletions replaces clearCompletionQueued and counts the recorded dispatches whose completion has not run. A use waits for every dispatch still in flight, not only for the first to finish.
  • A fill over an unretired fill only counts a store made after the earlier fill was noted. It does not take the earlier fill's queued write (or a queued write of another word) as its own.

A fill over a pending dispatch and overlapping stencil plane fills stay refused, as before.

Tests

  • agc_driver_native_depth_clears: a dispatch over a recorded dispatch, two dispatches noted before either is recorded, a dispatch recorded while the first is in flight and completes first, a dispatch over a fill, and a fill (stored by the CPU and queued on the GPU) over a fill of the other value. Clear values 0 and 1, three clears each.
  • agc_driver_native_depth_stencil: a fill of the other value, then the real fill noted twice.
  • agc_driver_native_depth_clear_refusals and the stencil refusals no longer list the overlap, which is now accepted.

Each of these sequences was refused before this change. The engine is shared by the macOS, Windows and Linux builds, and the change uses no platform API. The Vulkan cases run on the Linux lavapipe job.

…etired yet

A second whole-HTILE clear (an HTILE clear dispatch or a metadata fill) of a native
multisample depth target before any draw or sampling retired the first was refused as
"overlapping native multisample depth clear transitions are not implemented", which
killed Plants vs. Zombies: Replanted about two minutes in (issue #123).

Both clears cover the whole HTILE and run in command order, and every use of the surface
retires its clear first (settlePendingHtileClear, then CheckCurrent), so nothing saw the
earlier clear: the later one supersedes it, as on the GPU. The transition now starts over
with the newer clear, which needs the same proof at its use as a first clear.

- clearPending counts the noted dispatches not yet recorded, so two noted before either
  is armed both arm, and the clear generation is the newest recorded one.
- clearCompletions counts the recorded dispatches whose completion has not run, so a use
  waits for every one still in flight, not only for the first to finish.
- A fill over an unretired fill only counts a store made after the earlier fill was noted,
  and does not take the earlier fill's queued write (or one of another word) as its own.

A fill over a pending dispatch and overlapping stencil plane fills stay refused.

Tests (agc_driver_native_depth_clears): a dispatch over a recorded dispatch, two
dispatches noted before either is recorded, a dispatch recorded while the first is in
flight and completes first, a dispatch over a fill, and a fill (CPU-stored and queued on
the GPU) over a fill of the other value. agc_driver_native_depth_stencil: a fill of the
other value, then the real fill noted twice. Each used to be refused.
@utkuhalis
utkuhalis merged commit bf37c7f into main Nov 13, 2026
18 of 20 checks passed
@utkuhalis
utkuhalis deleted the fix/msaa-depth-clear-overlap branch November 13, 2026 09:12
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