Skip to content

feat(agc): render layered draws into a depth view of several slices - #69

Open
Thimo188 wants to merge 6 commits into
mainfrom
upstream-pr/7256
Open

Thimo188 wants to merge 6 commits into
mainfrom
upstream-pr/7256

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#7256, originally opened by gjonn.

Source commit: 6ceaa3963ca2c9ac5a2e362b6ea6b3f4e7dbc3ad. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

Depends on: boykopovar#7254. The first four commits of this branch are boykopovar#7254's (its two changes, the review follow-up fix and its agc_driver_layered_array_color_draw test); this PR's own change is the last commit, feat(agc): render layered draws into a depth view of several slices.

With boykopovar#7254, PPSA01317 gets through the color side of a 512x512 cube map pass and then aborts with layered rendering with a depth target is unsupported. The draw exports the render target array index into a six-slice color view, with a DB_DEPTH_VIEW of slices 0 to 5.

  • Decode. In a layered draw, the depth view renders as many layers as the color views. A depth-only layered draw renders the view's own slices. A depth view whose slice count differs from the color views throws.
  • Depth surfaces. The depth surfaces of those slices share one single-sample array image, one layer each, and the draw attaches a 2D array view of it. Each slice keeps its own Z, stencil and HTILE address (one DepthSliceBytes and one HtileMetadataBytes further per slice). Each slice also keeps its own plane ownership, HTILE clears and plane copies. A later draw into one slice binds that slice's layer. Another layered view over some of the same slices (another first slice or slice count) is a separate array image that takes each slice by a whole-slice copy when it is bound.
  • A multisampled layered depth target throws, and so does a layered target without a depth plane. The debt file gets a "Layered depth targets" entry, and the color entry no longer lists the depth refusal.

Behaviour change on an existing path: a depth-only layered draw into a multisampled or stencil-only depth view of several slices used to render silently into the first slice. It now throws.

Open debt:

  • The DB clamps a layer index past the view's last slice to SLICE_MAX. That clamp is not modelled; such a layer is undefined in Vulkan.
  • A single-slice color view with a multi-slice depth view stays single-layer (the depth view's first slice), as before.

boykopovar#7194 changes the same HTILE slice-clear function in DepthSurface.cpp (taking a later slice's clear when every word has ZMask 0). It works per slice and composes with the per-slice HTILE addresses here; the two branches merge without conflicts.

Tested

Windows 11, NVIDIA GeForce RTX 5090 Laptop GPU, driver 616.92. Ninja/MinGW Release with BUILD_TESTING=ON, on top of boykopovar#7254 rebased on main 922dc89.

  • New GPU test agc_driver_layered_depth_target covers a six-layer depth-tested draw:
    • after a draw into slice 2 alone;
    • after per-layer depth fills;
    • after an HTILE clear of slice 4 alone;
    • a single-slice draw into slice 1 after the layered draws;
    • a six-layer draw after a three-layer view of slices 2 to 4;
    • each slice read back as a layer of a 2D array texture.
  • agc_driver_graphics_tests: new decode cases for depth-only layered views, color plus depth views of matching, shifted and mismatched slice counts, and views without the layer export staying single-layer.
  • 29 related tests: 28 pass, and agc_driver_stencil_ref_export is skipped because the device does not support it. The set is the layered depth target, graphics and decode state tests, every depth/HTILE/stencil execution test (agc_driver_depth_*, agc_driver_native_multisample_depth, agc_driver_sample_mask_depth_stencil, agc_driver_stencil_*), the array layer target test and the layered volume and vertex layer export tests.
  • tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass.
  • PPSA01317 gets past this abort on main with feat(agc): render layered draws into 2D array color views boykopovar/AnyPS5#7254 (checked in boots).

Checklist

gjonn and others added 6 commits October 17, 2026 17:11
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 layered draw (the vertex shader exports the render target array
index) with a depth target was refused. PPSA01317 renders a 512x512
cube map this way: a six-slice color view with a DB_DEPTH_VIEW of
slices 0 to 5.

The depth view now renders as many layers as the color views, or its
own slices in a depth-only layered draw. The depth surfaces of those
slices share one single-sample array image, one layer each, and the
draw attaches a 2D array view of it. Each slice keeps its own Z,
stencil and HTILE address, plane ownership, HTILE clears and copies,
and a later draw into one slice binds that slice's layer. A depth view
of another slice count than the color views, a multisampled layered
depth target and one without a depth plane throw.

AI-assisted: yes
Co-authored-by: gjonn <7807870+gjonn@users.noreply.github.com>
@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 1030 core/libs/prx/libSceAgcDriver/tests/execution/LayeredDepthTarget.cpp

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with main, rebase needed 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