Skip to content

feat(agc): sample native multisampled depth attachments - #5496

Merged
adriadam10 merged 8 commits into
boykopovar:mainfrom
Amoenus:codex/native-msaa-depth
Oct 15, 2026
Merged

adriadam10 merged 8 commits into
boykopovar:mainfrom
Amoenus:codex/native-msaa-depth

Conversation

@Amoenus

@Amoenus Amoenus commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Support numeric sampling of resident D16/D32 depth attachments with 2, 4 or 8 samples, one Z_X slice/mip, and a proven initial zero/one HTILE clear. Preserve ITERATE_256, attachment identity and image lifetime, and barrier depth writes before shader reads. Sampling an attached native depth image is refused before pipeline creation.

The existing stencil byte-format filter runs before multisample routing, so a color texture at a stencil-plane address is not claimed as a depth reader. Stencil import, comparison/raw-bit/storage/array sampling, unproven guest/external GPU changes and unsupported metadata/publication transitions remain explicit refusals. Retirement and completion-proven clears are separate follow-ups (#5524/#5554).

The conditional Sonic Unleashed Recompiled PPSA99902 need and pinned title controls are documented in #3262 and bring-up #4443. This focused PR builds independently; its current head has not been replayed on the title. The retained bring-up integration contains additional work and its progress is reported separately.

Sources: PAL ITERATE_256 bit10, descriptor construction, Addrlib dimensions. HTILE restrictions follow the Mesa sources recorded in #3262 and library debt. PS5 equivalence has not been measured on a console.

Tested

Head 008f91501, base main3c87cdfda, Windows 11 Enterprise 26200, WinLibs GCC15.2.0, Release, bundled dependencies, SPIRV-Tools enabled:

  • Full Windows application/library build, patched-library validation, conventions and test registration pass.
  • Native-depth regression passes first, then14 selected groups pass once and five repetitions under each NVIDIA/AMD selector: no CTest failures/skips, slowest5.52633s repeated/5.50905s once; timeout30s.
  • Per-fixture output confirms nine runtime groups on each physical vendor. Other groups are CPU/unit evidence. Native D16/D32 ×2/4/8 samples ×zero/one clears execute12 cases per vendor, unavailable0.
  • The review follow-up adds an actual driver draw sampling its attached native depth image, and four contradictory HTILE/clear configurations: zero HTILE with clear1 in both layouts, and 0xfffc0000/0xfffffff0 with clear0.
  • Three one-line controls (delete Draw's feedback call; admit wrong zero-clear; admit wrong one-clear) each fail for the intended assertion five times per physical vendor: 30 expected failures. Controls ran on source-tree-equivalent9a74c0393. Production files were restored byte-for-byte, then the complete build and test matrix above was rerun on008f91501.
  • Requested depth_surface_reuse and guest_texture_resource cases execute through agc_driver_graphics; they are not separate CTest registrations.
  • Merge-tree check into later mainab9a47684 is clean. That merged composition is not runtime-tested. Full upstream CI still requires maintainer dispatch.

The earlier stencil-ordering control and title/source history remain in #3262. Current evidence covers Windows fixtures; Linux, a full CTest suite and an isolated title replay were not run for this head. No performance claim.

Checklist

  • Based on recent main (tested3c87; clean merge intoab9 checked); 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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source: n/a, none added
  • Generic behaviour, not specific to one title
  • Depends on: none (feat(agc): sample a multisampled color target through its 2D MSAA texture #4820 merged)
  • Unblocks: PPSA99902 Sonic Unleashed Recompiled (PPSA99902): initial gameplay on fork and remaining work #4443 (conditional native-depth sampling stop; not whole-game boot)
  • GPUs tested: NVIDIA GeForce RTX5080, driver610.62/32.0.16.1062; AMD Radeon(TM) Graphics (Ryzen9950X3D integrated), driver32.0.21036.18; both Windows11 Enterprise26200
  • AI-assisted: yes, Codex; author reviewed and tested locally

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed build docs agc libSceAgc* labels Oct 13, 2026
@Amoenus
Amoenus force-pushed the codex/native-msaa-depth branch from 77c1fbc to 08e15d5 Compare October 13, 2026 22:02
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@Amoenus
Amoenus force-pushed the codex/native-msaa-depth branch from 08e15d5 to 6733508 Compare October 13, 2026 22:22
@Amoenus

Amoenus commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Checked the newly surfaced overlaps at main bf8dc61. #5445 imports uniform guest color memory; #5499 performs a DB depth-to-color copy. Neither duplicates descriptor-based native-depth sampling here or the release retirement in #5524.

@codingreapermaps: #5499 and this PR share sampled-depth image/capability setup. I propose merging #5496 then #5524 first, so your copy path can reuse that foundation and skip inactive owners in its new lookup. If #5499 lands first, I can rebase this pair instead. The separate copy eligibility needs to remain explicit: your no-HTILE/two-sample clear0.375 fixture differs from this PR's creation-proven numeric sampling subset; this is a source composition check, not runtime validation of your PR.

@nicolasabosch: #5445 builds on #4820's color lookup. The inactive-owner correction is being validated in our existing #4820 comment. #5445's uniform import makes a no-resident lookup a supported path, so the important remap control there is selecting the new contents rather than imposing #4820's current no-draw refusal.

The functional prerequisites for this PR remain #4820; #5524 depends on this PR. AI-assisted: Codex.

@Amoenus
Amoenus force-pushed the codex/native-msaa-depth branch 2 times, most recently from 751ca8d to 7b8996a Compare October 13, 2026 23:42
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@Amoenus
Amoenus force-pushed the codex/native-msaa-depth branch from 7b8996a to db71c52 Compare October 14, 2026 01:02
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@Amoenus

Amoenus commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@Gashrod1 Implemented and tested the narrow ordering correction in head804c1b390, rebased onto main411e5e6d9. The existing stencil byte-format filter now runs before native multisample routing.

The CPU regression covers D16S8/D24S8/D32S8 ×2/4/8 samples:27 color aliases are declined and18 plane-reader recording checks remain. The native device fixture checks a single-sample R11G11B10 request at a D32S8 stencil address is declined while actual stencil access retains its unsupported-import refusal. Published615 production with test-only additions builds and fails on the erroneous recording requirement;804 passes.

Full Windows app/libs/checkers and14 groups once+5 under NVIDIA/AMD selectors pass without failures/skips, max5.85142s; runtime device identities are verified. Combined depth/stencil import and Windows tracking remain unsupported. This is classification validation, not a replay of DAVE THE DIVER or verification of its other bypasses. Items1/4 remain associated with #5554's completion-proven clear work.

@Amoenus
Amoenus force-pushed the codex/native-msaa-depth branch from 6154640 to 804c1b3 Compare October 14, 2026 20:24
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, the head builds on its own now. I rebuilt it merged onto current main (the only conflict was the include list in MultisampleTarget.cpp:3, keep both ColorTargetLayout.hpp and DepthSurface.hpp), agc_driver_native_multisample_depth passes. I then mutated the code to check that the new tests pin the behaviour, and two mutants survive:

  • Graphics/src/Draw.cpp:2115: deleting the RequireNoNativeDepthFeedback_nid_no_patch(...) call leaves every test green. tests/execution/NativeMultisampleDepth.cpp:536-547 calls the function directly, so nothing checks that Draw actually calls it before the pipeline is created. Please add a case that goes through a draw sampling the attached native depth image and expects the refusal.
  • Graphics/src/DepthSurface.cpp:67: changing if (depth == 0u) return clearDepth == 0.0f; to return true; also passes. The clear-value refusals at NativeMultisampleDepth.cpp:668-674 never use all-zero HTILE with clearDepth = 1.0f, which is the case that would import a wrong initial depth. Please add it (and the mirror: 0xfffc0000 / 0xfffffff0 words with clearDepth = 0).

Please also rebase onto main for the include conflict above and re-run agc_driver_native_multisample_depth, depth_surface_reuse and guest_texture_resource.

Not covered by what I could run here: the HTILE encodings and ITERATE_256 behaviour follow Mesa/PAL, not measured on a console, and nothing ran on NVIDIA/Windows.

Adapt our preserved native-depth sampling work from c0d9edf and sample-aware footprint work from 6e35a87, retaining creation-time coherence and initial HTILE proof. The descriptor interface in upstream PR 4820 remains a separate prerequisite. This source draft has not been built or run.
Reject native sampled views of the depth image attached by the same draw before pipeline creation. Keep unrelated views, other devices and the single-sample path unaffected. Add unrun native-view refusal and scope controls; full dependency-stack build and runtime validation remain pending.
@Amoenus
Amoenus force-pushed the codex/native-msaa-depth branch from 804c1b3 to 008f915 Compare October 14, 2026 23:56
@Amoenus

Amoenus commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@adriadam10 Addressed both surviving mutants in 008f91501: the regression goes through the driver draw, and the four contradictory HTILE/clear cases are covered. All three fault controls fail for the intended assertion ×5 on NVIDIA and ×5 on AMD; production restored/rebuilt,14 groups pass once+5 per GPU. Depth-reuse/guest-texture cases run inside agc_driver_graphics. Rebased onto main3c87; merge into later mainab9 is clean. The PR description now contains only current validation and links to the older evidence. AI-assisted: yes.

Merged: #5496 landed as c4f03522a70d0392d1426f092f712009b1d55675 and is included in main 0afa6a607. @adriadam10's approval and independent validation remain linked; no re-review request is pending. Our follow-up compositions and their residual import-tracking failure are separately scoped in #6060's maintained report. Earlier local evidence above retains its tested pins.

@github-actions

github-actions Bot commented Oct 15, 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
#454 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp L125-126, L139-141, L863-864
#5982 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp L856-857

@Gashrod1

Copy link
Copy Markdown
Contributor

Independent test of 008f915 on a title: DAVE THE DIVER (PPSA19115), Windows 11, NVIDIA GeForce RTX 5060 (596.36). Same session, same dump, only the libs change:

Build Stops at
main ab9a476 frame 1: guest texture descriptor uses MSAA which is not implemented
main + #5496 (008f915) frame 1: sampling the 1920x1080 multisampled texture 0x22b790000 of 2 samples, which no draw rendered to and whose tile mode 4 has no modeled multisampled color footprint, is not implemented

So this PR moves the title past the ITERATE_256 refusal on current main; the merge onto ab9a476 was clean.

The next stop is outside this PR: a 2x Z_X depth texture sampled before any draw, with an all-zero HTILE. I have a follow-up for it (undrawn Z/D 64 KiB swizzle textures, and Z ones whose HTILE is all cleared, load as a uniform value). With it on top of this PR the title reaches frame 17 and stops on the D32S8 native depth case I described on #5554. I will open it once this PR is merged, since it is only reachable after it.

AI-assisted: yes

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 15, 2026
@Amoenus
Amoenus requested a review from adriadam10 October 15, 2026 07:26

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the new head: the two surviving mutants now fail (removing the RequireNoNativeDepthFeedback_nid_no_patch call in Draw.cpp:2203 and return true at DepthSurface.cpp:74 both fail agc_driver_native_multisample_depth). Built merged onto current main with no conflicts; agc_driver_native_multisample_depth and agc_driver_graphics (which runs depth_surface_reuse and guest_texture_resource) pass. agc_driver_tessellation segfaults here, but it does the same on a plain main build. Merging once the full Build is green.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants