Skip to content

perf(agc): publish native multisample depth with hoisted tiling - #19585

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
muhmuhkuh:crew/ds2-perf/depth-publication-fast
Nov 16, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
muhmuhkuh:crew/ds2-perf/depth-publication-fast

Conversation

@muhmuhkuh

@muhmuhkuh muhmuhkuh commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Native multisample depth and stencil publications read back their guest-visible bytes and tiled them one element at a time. MultisampleTextureLayout::TileHoisted computes each block's address once per row and fragment, and writes the same bytes as Tile. ExpandPagedSnapshot fills the stored pages with whole-word copies instead of a byte-by-byte formula. PublicationPlane::Expand and the publish step use these two functions directly; there is no runtime switch.

The old functions stay: Tile and Detile are unchanged, and PublicationPlane::Byte is still used to compare published bytes. The layout test compares TileHoisted with Tile for every element size, fragment count and padding shape it covers, and ExpandPagedSnapshot with the byte-by-byte expansion, and it refuses overlapping or short buffers.

Overlap with open PRs: #9950 also builds a MultisampleTextureLayout for the native multisample D32 depth publication, without changing the functions named here. Other open PRs share DepthSurface.cpp without touching these functions.

Tested

Windows 11 Pro (10.0.26200), NVIDIA GeForce RTX 3080 Ti, driver 610.88, MinGW GCC 15.2 (UCRT, POSIX threads, SEH), Release, validation layer on (ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation). Built on the same machine on main ef4b938 and on this branch at 004b4a3.

  • agc_driver_msaa_layout (CPU): passes on main and on this branch. On main the test has the old checks only; on this branch it also covers TileHoisted and ExpandPagedSnapshot.
  • agc_driver_native_multisample_depth, the agc_driver_native_depth_* tests and agc_driver_msaa_layout (Vulkan): 30 of 30 pass on main and 30 of 30 on this branch ( agc_driver_native_depth_driver_queued_fill is skipped on both sides). VUID: 0 VUID- lines in both logs. The phrase was not found but was requested by env var VK_INSTANCE_LAYERS: 0 occurrences in both.
  • Red probes on this branch, each reverted afterwards: (1) the swizzle XOR removed from the layer bits of TileHoisted: the layout test fails with "the hoisted multisampled retile differs from the plain retile in element, padding or guard bytes". (2) the pattern index changed in ExpandPagedSnapshot and the word loop removed: the layout test fails with "a paged snapshot expanded page by page differs from its bytes taken one by one".
  • Not run: the full CPU suite, Linux, the other AGC tests, and any title. No timing is claimed.

Checklist

  • Based on current main (ef4b938 at posting time)
  • 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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3080 Ti, driver 610.88, Windows 11 Pro 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

@github-actions github-actions Bot added agc libSceAgc* perf Performance change perf numbers missing perf pull request without a before and after summary line labels Nov 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 6808 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 7449 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 9950 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 16368 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 17899 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 17915 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 17956 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 18057 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 18185 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 20186 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 20315 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp

@pushkarreddyy

Copy link
Copy Markdown
Contributor

Impressive performance work on native multisample depth publication!

Hoisting the swizzle coordinate lookups (xOffsets, yOffsets, layerOffsets, fragmentOffsets) in TileHoisted and moving page copying to word-sized transfers in ExpandPagedSnapshot cleanly eliminates per-sample overhead.

The testing methodology is exemplary:

  • 0 VUID- validation errors with VK_LAYER_KHRONOS_validation enabled.
  • Red probes intentionally perturbing the swizzle XOR and page patterns to prove that the tests actively catch regressions.
  • Strict adherence to the no-timing-claim policy when microbenchmarking on differing host hardware.

@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 64f2bca218, merged onto main 5891d14d99. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

agc_driver_msaa_layout passed in 3 of 3 runs in both setups:

  • GPU, through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1 (merge 24d8ad7c95). The binary matched the hash recorded at preparation, and the receipt shows exit 0 and app_count=0.
  • CPU, Vulkan hidden (merge ae2dbf91e0).

This is a correctness check only; I did not measure the performance effect.

AI-assisted: yes.

@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

Thanks @JJenkx for the AMD/Windows check of agc_driver_msaa_layout.

Windows job: the four timeouts (guest_ces_wide, guest_ces_wide_module, guest_ces_mbc, guest_ces_mbc_module) are in the CES tests. This change does not touch those files (it changes only DepthSurface.cpp, MultisampleTextureLayout.hpp/.cpp and tests/MultisampleTextureLayout.cpp). The same four timeouts also appear in the Windows jobs of two other branches in the same hour: runs 43452499284 and 43451655378. We have not rerun the job.

Performance: this PR claims only identical bytes and less work per element, not a frame time. We cannot yet give a main and change capture pair from the same title, scene and machine. On main, the sample-preserving publication accepts only VK_FORMAT_D32_SFLOAT_S8_UINT (DepthSurface.cpp:2626, PublishToGuest). Native multisample D32 depth without stencil is accepted there by #9950. We will post the pair once that path is in main.

Question for the maintainers: is a main and change pair on a base with #9950 (and #16880) applied, same machine and scene, enough? Or should this PR run without the perf label as a pure refactor, covered by the byte-equality tests?

AI-assisted: yes.

Multisampled depth and stencil publications tiled and expanded their paged snapshots one element at a time. TileHoisted computes each block's address once per row and fragment, and ExpandPagedSnapshot fills whole pages. The result bytes are the same as before: the layout test compares TileHoisted with Tile, and ExpandPagedSnapshot with the byte-by-byte expansion.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@muhmuhkuh
muhmuhkuh force-pushed the crew/ds2-perf/depth-publication-fast branch from 64f2bca to 004b4a3 Compare November 15, 2026 11:10
@muhmuhkuh

Copy link
Copy Markdown
Contributor Author

Rebased onto main ef4b9389b63 (head 004b4a37f8c) without conflicts; the content is unchanged. The PR body now lists the new base and test counts: agc_driver_native_multisample_depth, the agc_driver_native_depth_* tests and agc_driver_msaa_layout pass 30 of 30 on main and on this branch (same machine, validation layer inserted, 0 VUID- lines, no "was not found" line).

The four Windows timeouts (guest_ces_wide, guest_ces_wide_module, guest_ces_mbc, guest_ces_mbc_module) did not show up again in the 200 failed Build runs from 14 Nov 19:00 UTC to 15 Nov 10:21 UTC. This push reruns the Windows job.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit 04f7633 into boykopovar:main Nov 16, 2026
14 of 16 checks passed
@klosixgaming-arch

Copy link
Copy Markdown
Contributor

Tested on Cyberpunk 2077 (PPSA03974) 02.120.000, the intro movie at 3200x1800, Windows 11 (10.0.26200), RTX 5090 (NVIDIA 617.42), Ryzen 9 9950X3D, WinLibs GCC 15.2 Release. Base: current main e04bd77e7f + #19071 (736364e8d5), which this title needs to run the intro at full speed. This PR's head 004b4a37f8 is merged on top (3c769a2e3f, clean merge). One boot each, presents per 10 s from the 10 s summary windows; the median is over the windows after the first two (loading).

build windows median
base, boot before 126 129 114 107 118 123 122 115 123 122
this PR 100 100 116 131 123 103 117 122 93 116
base, boot after 95 117 101 86 122 114 122 133 129 117

No measurable change on this scene (single boot; separate boots of one build differ by up to about 8% here, and the base's own windows ranged from 86 to 133). The intro probably has few native multisample depth publishes, so this says little about scenes that have them. No errors or aborts.

@muhmuhkuh
muhmuhkuh deleted the crew/ds2-perf/depth-publication-fast branch November 16, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* perf numbers missing perf pull request without a before and after summary line perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants