Skip to content

feat(agc): fast clear the CMASK of array and layered color targets - #8065

Closed
ArielWolle wants to merge 7 commits into
boykopovar:mainfrom
ArielWolle:feat/agc-cmask-fast-clear-array-layers
Closed

ArielWolle wants to merge 7 commits into
boykopovar:mainfrom
ArielWolle:feat/agc-cmask-fast-clear-array-layers

Conversation

@ArielWolle

Copy link
Copy Markdown

What

Fast clears the CMASK of array and layered color targets instead of throwing CMASK fast clears of a 3D or array color target are unsupported. Each layer is cleared through its own CMASK slice: the color address, the CMASK address and the pipe-bank XOR are offset per slice, the CMASK range check covers every layer, and the written-buffer ranges cover all layers. A 3D color target and a slice or array of a mipmapped target still throw, as recorded in the technical debt entry. The per-slice CMASK stride follows Addrlib's slice size and has not been measured on hardware.

Stacked on #7254 (layered draws into 2D array color views) and #7668 (CMASK offset of a color target slice); their commits are in this branch until they merge.

Tested

Windows 11, MinGW Release build based on main c0adf025b, with ANYPS5_REQUIRE_VULKAN=1:

  • ctest -R '^(agc_driver_graphics|agc_driver_cmask_fast_clear)$' --output-on-failure: passed (2/2)
  • ctest -R layered_array_color_draw --output-on-failure: passed
  • python3 tools/check_conventions.py --base origin/main: 0 errors (the existing debt-length warnings)
  • NHL 27 (PPSA34063) used to stop at this error in the menus; the full title run with this change is in progress.

Checklist

gjonn and others added 7 commits October 19, 2026 15:12
A draw whose vertex shader exports the render target array index into a
color view of several slices of a 2D array target was refused. The view
now renders layers lastSlice - slice + 1 through a 2D array attachment
view of the array's resident image starting at its first slice, and the
draw marks every rendered slice dirty. A view of several slices of a
surface that is not a 2D array is still refused, as is a layered draw
without the array's resident image.

AI-assisted: yes
…of its view's slices

A layered draw into a color view of slices 0 to 5 of a 2D surface whose
CB_COLOR_ATTRIB3 declares one slice was refused. The CB clamps the
render target array index to the view's SLICE_MAX, not to the surface's
slice count, so each layer is written one slice pitch further on.
PPSA01317 renders a 512x512 cube map this way. Such a view now renders as
a 2D array of the view's last slice + 1 slices.

AI-assisted: yes
…the volume layer guard

The resident image of a 2D array color view only compared the view's own
slice offset with the image's layer pitch, which is trivially equal for
slice 0. Every slice of the array image is now checked against the slice
size DecodeColorBuffer offsets the view by. AttachmentView again requires
layer 0 for a 3D target, as it did before layered 2D array views.

AI-assisted: yes
A vertex shader exporting the render target index draws one value per
layer into a CB_COLOR_VIEW of slices 1 to 3 of a four-slice 2D array and
into slices 0 to 2 of a surface of one slice. After the write-back every
slice of guest memory must hold its layer's value, and the slices
outside the view (slice 0, and slice 3 of the one-slice surface) their
initial bytes.

AI-assisted: yes
A view that selects slice N of a single-mip 2D color target moved the
color address by N slices but kept the CMASK register's address, and a
CMASK fast clear of such a slice threw. The CMASK of slice N now sits N
whole-slice CMASKs after the register. 3D targets, targets with an array
depth and slices of mipmapped targets still throw.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AMD Addrlib's HwlComputeCmaskAddrFromCoord passes the slice into the
swizzle pattern as its Z coordinate as well as stepping by sliceSize.
The pipe-aligned 16-pipe pattern puts Z0..Z3 into nibble bits 12, 11,
10 and 9, so a slice moves its tiles inside its own block. A uniform
CMASK reads the same at every slice, but a mixed one was read at the
slice 0 nibbles.

CmaskLayout::Nibble takes the slice, ColorTarget carries it as
cmaskSlice, and the CMASK clear shader gets it as a push constant, so
the CPU and GPU paths agree. The tests pin nibbles evaluated from the
Mesa mesa-25.2.0 pattern text and clear partial CMASKs of slices 1, 2,
3 and 8 on the device.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Clear every layer of an array or layered color target through its own
CMASK slice, offsetting the color address, the CMASK address and the
pipe-bank XOR per slice, and widen the written ranges to cover all layers.
The per-slice CMASK stride follows Addrlib's slice size; it has not been
measured on hardware.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20 labels Oct 19, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

@github-actions github-actions Bot closed this Oct 19, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 20, 2026
@oneandonlydean

oneandonlydean commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

This was closed by the open-PR limit while our intake was paused, not on its merits. GitHub won't reopen it because the branch changed after the close, so we'll carry it in a new PR that credits you, and review it under the normal process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20 unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants