Skip to content

fix(agc): release a resident multisample depth before a GPU buffer may write over it - #11369

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
QRMOE:fix/agc-msaa-depth-buffer-write
Oct 28, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
QRMOE:fix/agc-msaa-depth-buffer-write

Conversation

@QRMOE

@QRMOE QRMOE commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What

A GPU buffer a shader may write could land on the memory of a resident native multisampled depth surface without the surface being released first. Guest, DMA, texture, storage-image, index and vertex reads already go through RequireNoResidentDepthRead_nid_no_patch before they touch that memory; a writable storage buffer did not. When the buffer was a host import, the GPU wrote straight into guest memory, the surface's guarded generation moved, and the next access to the surface (for example a read that asked for guest publication) stopped on guest writes over native multisample depth are not implemented.

GuestBufferMemory::UploadFinish now calls RequireNoResidentDepthRead_nid_no_patch for each range in Writes(), next to the existing FlushDepthPlanes call and before the GPU runs. This is the order a console sees: the buffer's stores land on top of whatever the depth surface left in memory.

Buffers bound read-only are not covered; a new debt entry says so.

Tested

Windows 11 Home 26200, Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (AMD 32.0.31021.1015, Vulkan 1.4.349), WinLibs GCC 15.2.0 r7, Release. The regression test and the validation comparison below were run on this branch as pushed (a65bb53, on main b27cc84); the selected-test run was on the same commit on main efd368f, before a rebase with no conflicts.

  • agc_driver_native_multisample_depth gains CheckBufferWrites: a fresh D16 and D32 surface at 2, 4 and 8 samples, on a device created with VK_EXT_external_memory_host and buffer device addresses, so the written range is bound as a host import (the test requires HostImportCovers; without the extension it prints a skip line). Two cases per format and sample count:
    • an unrelated writable buffer keeps the surface resident;
    • a writable buffer over the last 256 bytes of the depth plane, and one over the HTILE range, retire the unwritten surface and leave its guest bytes and HTILE unchanged;
    • On main: fails with a buffer the GPU may write left an unwritten native depth surface resident over it. With this PR: passes.
  • Khronos validation layer (Vulkan SDK 1.4.363.0), same machine and GPU, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest --test-dir build -R "^agc_driver_native_multisample_depth" -V: neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS; VUID- occurrences are 0 on main and 0 with this PR. The main run stops at the new check, so it covers less of the test than the PR run.
  • tools/select_tests.py selected 1490 of 2398 tests for this diff, -j4, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: 8 failures, and the same 8 fail on main on this machine: select_tests, nid_database_cache, agc_host_import_cut_lifetime, agc_driver_depth_plane_partial_store, agc_driver_sample_order_grid_reference, agc_driver_frame_capture_eop, agc_driver_frame_replay_shader, agc_driver_frame_replay_shader_host.
  • Title: RESIDENT EVIL requiem (PPSA31246, 01.200.000), on main 29ce6d8 with fix(libScePad): return an error for unsupported port probes #10935, fix(agc): keep buffer owners when a staged address space dissolves #10304, feat(agc): publish a written native multisample D32 depth surface to its guest planes on access #9950 and fix(shader): keep pixel helper lanes out of guest lane masks #11199 applied locally. Same title, inputs and other libraries in every run, frame dumps checked:
    • Without this change, 5 of 5 runs stopped about 10 minutes in, after the start-up logos, on guest writes over native multisample depth are not implemented (these runs carried temporary diagnostics, removed since). In four of them a temporary write watch showed the last writes to the 4x D32 128x64 surface at 0x20008d0000 were MarkPossiblyWritten stamps over 0x20008d0000+0x30000 from GuestBufferMemory::MarkDirectWrites and GuestBufferMemory::WriteBack, after the surface's draws; the access that then stopped was the guest publication request of a later read.
    • With this change, 3 of 3 runs passed that point and reached the main menu, Main Story, New Game, Game Mode and the opening title card. (A fourth run with every import traced, which slows the title down, stopped earlier on an unrelated shader-decode error.) After the title card the title shows a black screen while still drawing; one run left there for 40 minutes stopped on VK_ERROR_OUT_OF_DEVICE_MEMORY. Both are separate from this change and not investigated here. Gameplay was not reached.
  • Rerun on the current head 946de28 (on main 18ef6be), same machine and validation-layer environment, ctest --test-dir build -R "^agc_driver_native_multisample_depth$" -V: this branch passes; the same tree with GuestBufferMemory.cpp from main fails with a buffer the GPU may write left an unwritten native depth surface resident over it; this branch merged with fix(agc): refuse writable buffer feedback with native depth #10497 (8a0dcd5, which carries fix(agc): reclaim published native depth owners safely #10469 and fix(agc): publish native depth before cached buffer recording #10492) passes. 0 VUID- occurrences and no missing-layer line in any of the three logs.
  • Rerun on 609f4f1, after dropping the written-surface refusal case, same machine and validation-layer environment: this branch passes, and the same tree with GuestBufferMemory.cpp from the base main 18ef6be fails with a buffer the GPU may write left an unwritten native depth surface resident over it. The buffer-write cases ran for formats 124 and 126 at 2, 4 and 8 samples (checked=24 unavailable=0); 0 VUID- lines.
  • Not run: Linux, other GPU vendors, the full CTest suite.
  • tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py --branch fix/agc-msaa-depth-buffer-write: test(agc): enable VK_KHR_portability_subset in the tests that create their own device #10920 edits the same two lines of the test's own Device setup (it adds the portability subset). Not listed by the tool, since the only shared file is the debt file:

Checklist

  • Based on current main; 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 (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA31246 RESIDENT EVIL requiem (PPSA31246) #11599 (RESIDENT EVIL requiem)
  • GPUs tested: AMD Radeon RX 9070 XT, AMD driver 32.0.31021.1015 (Vulkan 1.4.349), Windows 11 Home 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head a65bb53c25c5bad83b638deed03fa0caeca2f7b6.

The production change appears to retire or publish a resident native depth surface before the GPU can write into an overlapping guest buffer, and the test covers unrelated, depth-plane, HTILE, and already-written cases. I found one portability issue in the new Device(importHost=true) fixture that can prevent the added cases from running on otherwise usable Vulkan devices.

At NativeMultisampleDepth.cpp, the fixture enables VkPhysicalDeviceBufferDeviceAddressFeatures::bufferDeviceAddress = VK_TRUE whenever both extension names are enumerated. Extension presence does not establish support for this optional feature. The Vulkan feature structure must be queried with vkGetPhysicalDeviceFeatures2, and only a supported feature may be enabled at device creation. If a device exposes both extension names but reports bufferDeviceAddress == VK_FALSE, this fixture fails vkCreateDevice rather than skipping only the host-import cases. Please query the feature and gate the import-host device/test path on its support (while retaining the existing extension checks), then rerun the focused test on the author GPU and a Vulkan configuration without BDA if available.

I did not run the AGC test locally: this environment has no /dev/dri GPU device. Current hosted eligibility, conventions, intake, labels, and report checks pass; product and GPU build jobs are skipped by the repository path policy. The reported Windows/RX 9070 XT test remains author-provided evidence.

@QRMOE

QRMOE commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Fixed in 7ab89a4. When both extension names are present, the fixture now queries VkPhysicalDeviceBufferDeviceAddressFeatures through vkGetPhysicalDeviceFeatures2. It enables the extensions and the feature (bufferDeviceAddress only; capture-replay and multi-device stay off) only when bufferDeviceAddress is reported. Otherwise it creates the device without them, leaves hostImportAlignment at 0, and CheckBufferWrites prints a skip line naming the missing extension or feature.

Rerun on 7ab89a4, same RX 9070 XT machine, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest --test-dir build -R "^agc_driver_native_multisample_depth$" -V:

  • As built: passes. All six format and sample-count combinations ran the buffer-write cases and none skipped. 0 VUID- occurrences, and no was not found but was requested by env var VK_INSTANCE_LAYERS.
  • I have no Vulkan device here that lacks the feature. To check the gate itself, a local build forced it off: device creation succeeded, all six combinations printed the skip line, and the test passed with 0 VUID- occurrences. That build was not committed.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-reviewed exact head 7ab89a42bdceca2d1f33f63282e9708d3d9a0800 against current main 4e43321bd6ceccdc1ae28568bbbc35d9a6446464. The new vkGetPhysicalDeviceFeatures2 query now gates bufferDeviceAddress; unsupported devices create without the optional extensions and the test skips host-import cases. The author reports the focused test passed on the RX 9070 XT and the forced-off path skipped all six combinations. I found no remaining issue with that feature query.

Two merge-readiness items remain:

  • tools/check_main_sync.py reports this branch is 2 commits ahead and 84 behind current main (merge base b27cc8416f820e40ce187f165d34138e24373dd7). The merge preview with main is clean and main has not changed the PR's touched paths since that base, but the repository requires branches to stay current. Please rebase/sync to current main and rerun the focused Vulkan test and conventions on the resulting exact head.
  • Open #10920 also modifies the Device setup in NativeMultisampleDepth.cpp to enable VK_KHR_portability_subset. A three-way merge preview of the current heads reports a content conflict in that file, in the same setup region this PR now changes for BDA. Please coordinate integration order and preserve both the portability-subset setup and this feature-gated host-import setup; add Depends on: #10920 if that PR must land first.

On this host, check_conventions.py and git diff --check pass for the current PR head, and the main merge preview is clean. I could not run the Vulkan test locally because /dev/dri is absent. Hosted eligibility, conventions, labels and report pass; product/GPU build jobs are skipped by path policy.

@github-actions

github-actions Bot commented Oct 26, 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 10920 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp L114-115

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 2434 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 4449 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5021 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6185 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6194 docs/dev/debt/libSceAgcDriver.md
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6300 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6804 docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6918 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6977 docs/dev/debt/libSceAgcDriver.md
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7457 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7622 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8223 docs/dev/debt/libSceAgcDriver.md
PR 8319 docs/dev/debt/libSceAgcDriver.md
PR 8395 docs/dev/debt/libSceAgcDriver.md
PR 8542 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9012 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 9020 docs/dev/debt/libSceAgcDriver.md
PR 9335 docs/dev/debt/libSceAgcDriver.md
PR 9356 docs/dev/debt/libSceAgcDriver.md
PR 9387 docs/dev/debt/libSceAgcDriver.md
PR 9432 docs/dev/debt/libSceAgcDriver.md
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9672 docs/dev/debt/libSceAgcDriver.md
PR 9673 docs/dev/debt/libSceAgcDriver.md
PR 9674 docs/dev/debt/libSceAgcDriver.md
PR 9675 docs/dev/debt/libSceAgcDriver.md
PR 9676 docs/dev/debt/libSceAgcDriver.md
PR 9700 docs/dev/debt/libSceAgcDriver.md
PR 9748 docs/dev/debt/libSceAgcDriver.md
PR 9842 docs/dev/debt/libSceAgcDriver.md
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 9891 docs/dev/debt/libSceAgcDriver.md
PR 9892 docs/dev/debt/libSceAgcDriver.md
PR 9893 docs/dev/debt/libSceAgcDriver.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9898 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9950 core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10049 docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10194 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 10233 docs/dev/debt/libSceAgcDriver.md
PR 10333 docs/dev/debt/libSceAgcDriver.md
PR 10351 docs/dev/debt/libSceAgcDriver.md
PR 10359 docs/dev/debt/libSceAgcDriver.md
PR 10435 docs/dev/debt/libSceAgcDriver.md
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 10581 docs/dev/debt/libSceAgcDriver.md
PR 11075 docs/dev/debt/libSceAgcDriver.md
PR 11557 docs/dev/debt/libSceAgcDriver.md
PR 11920 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 11998 docs/dev/debt/libSceAgcDriver.md
PR 12157 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 12238 docs/dev/debt/libSceAgcDriver.md
PR 12246 docs/dev/debt/libSceAgcDriver.md

@github-actions github-actions Bot added docs agc libSceAgc* labels Oct 26, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The BDA feature gate fix and the reported RX 9070 XT/forced-off test results remain useful; this exact head is still 7ab89a42bdceca2d1f33f63282e9708d3d9a0800. Current main is now 5b5d24cb22, leaving the branch 87 commits behind. The merge preview is clean, but docs/dev/debt/libSceAgcDriver.md changed on main since the branch base, so the rebase must retain those descriptor notes along with this PR’s debt. Please rebase and rerun the focused Vulkan test and conventions on the resulting head. The open #10920 integration conflict in NativeMultisampleDepth.cpp remains: coordinate the portability-subset setup and BDA feature setup, and record Depends on if order is required. Current conventions and diff checks pass on the existing head; product/GPU jobs are skipped by path policy.

@QRMOE
QRMOE force-pushed the fix/agc-msaa-depth-buffer-write branch from 7ab89a4 to 8e4361a Compare October 26, 2026 11:53
@QRMOE

QRMOE commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: the head is now 8e4361a on main 7a01e6a (tools/check_main_sync.py: 2 ahead, 0 behind, merge clean). The debt file keeps main's new descriptor notes. This PR still adds one entry, in the Functional section after the HTILE entry.

Rerun on that exact head, same RX 9070 XT machine, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest --test-dir build -R "^agc_driver_native_multisample_depth$" -V:

  • This branch: passes, with all six format and sample-count combinations running the buffer-write cases.
  • Same tree with GuestBufferMemory.cpp from main: fails with a buffer the GPU may write left an unwritten native depth surface resident over it.
  • Neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS; VUID- occurrences are 0 in both.
  • tools/check_conventions.py --base origin/main passes.

On #10920: the two edits are independent and need no ordering. #10920 lets PortabilitySubset::Enable set the device's extension list. This PR's Device(importHost) path adds VK_EXT_external_memory_host and VK_KHR_buffer_device_address, and chains VkPhysicalDeviceBufferDeviceAddressFeatures, only when the device reports the feature. Whichever lands second should append these two names to the extension vector Enable receives and keep the features chain. I've left Depends on: none.

@SeaSunPT

Copy link
Copy Markdown
Contributor

An NVIDIA run, to go with the RX 9070 XT.

Windows 11 Pro 26200, Intel Core i5-14600K, NVIDIA GeForce RTX 5070 Ti (driver 610.88), WinLibs GCC 15.2.0 r7, Release. Head 7ab89a42b merged onto main cbaacd2910 (clean), compared with that main. Your new head 8e4361ae4 is a rebase with the same changes.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "^agc_driver_native_multisample_depth" -V, 3 runs each:

  • This PR: passes every run, with no skip line, so the device has the host-import and buffer-device-address support the new CheckBufferWrites cases need, and they ran.
  • main: passes every run (without the new cases).
  • 0 VUID- lines and no missing-layer line in any log. The validation layer is Khronos vulkan-sdk-1.4.363.0, built from source with the same GCC (mimalloc off).

I did not run the new test against main's GuestBufferMemory.cpp, so this shows the new cases pass on NVIDIA, not the red/green.

Full ctest -j 8 with ANYPS5_REQUIRE_VULKAN=1: 2450 of 2452 pass. The two failures, agc_host_import_cut_lifetime (#10746) and agc_driver_depth_plane_partial_store (#10664), fail on main on this machine too.

@MarcZX10

Copy link
Copy Markdown
Contributor

I rechecked the exact current heads. This PR's merge base is 7a01e6a494, while current main is 2cce8bc51d; main has since added the #9789 raw-32-bit color-target debt entry in docs/dev/debt/libSceAgcDriver.md. Please sync current main and retain that entry along with this PR's buffer-write note, then rerun the focused test/conventions on the resulting head.

I also ran a three-way merge preview of current #10920 and #11369: it reports a content conflict in NativeMultisampleDepth.cpp. Your note about combining the extension list and feature chain is useful; please preserve both PortabilitySubset::Enable and the host-import/BDA feature setup when the integration is resolved, and record a dependency only if one PR actually has to land first. Approval remains pending the current-base update and that integration plan; the hardware/runtime results are otherwise substantial and clearly reported.

@QRMOE

QRMOE commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Synced: the head is now 462a19f on main 48c160c (tools/check_main_sync.py: 2 ahead, 0 behind, merge clean). docs/dev/debt/libSceAgcDriver.md keeps main's entries, including #9789's raw 32-bit color-target note; this PR still adds only its buffer-write entry.

Rerun on that exact head (submodules updated to main's, including the new 3rdparty/jxrlib), same RX 9070 XT machine, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest --test-dir build -R "^agc_driver_native_multisample_depth$" -V:

  • This branch: passes, with all six format and sample-count combinations running the buffer-write cases.
  • Same tree with GuestBufferMemory.cpp from main: fails with a buffer the GPU may write left an unwritten native depth surface resident over it.
  • 0 VUID- occurrences and no was not found but was requested by env var VK_INSTANCE_LAYERS in either log.
  • tools/check_conventions.py --base origin/main passes.

On #10920, the integration plan is unchanged and no ordering is needed. Whichever PR lands second keeps PortabilitySubset::Enable and passes it an extension list that also holds VK_EXT_external_memory_host and VK_KHR_buffer_device_address when the importing device asks for them. VkPhysicalDeviceBufferDeviceAddressFeatures stays in the create-info chain, gated on the queried bufferDeviceAddress. Depends on stays none.

Thanks @SeaSunPT for the NVIDIA run.

@thuanquang

Copy link
Copy Markdown
Contributor

@QRMOE, two cross-PR issues. Neither is a bug against main alone. I found both by reading the code at 462a19f and merging trees with git merge-tree. Nothing was built or run.

1. The production line duplicates open #6498. #6498 (also carried by #10492 and #10497) adds ShaderResources::requireGuestBuffers(). For every guest buffer, read-only or writable, it calls RequireNoMultisampleTarget(address, size, "a shader buffer access") before UploadPrepare, before UploadFinish, in PrepareDrawBindings and in Bind. RequireNoMultisampleTarget starts with RequireNoResidentDepthRead_nid_no_patch (MultisampleTarget.cpp:1427), the call this PR adds at GuestBufferMemory.cpp:5086. In production, every writes range comes from AddWritable at ShaderResources.cpp:4399 or :2104, and each of those also pushes a guest allocation. The only UploadFinish caller is ShaderResources.cpp:2404.

The two PRs merge without conflicts. Their only shared file is the debt md, so neither the overlap bot nor pr_overlap.py lists #6498. In the merged tree, requireGuestBuffers() runs at ShaderResources.cpp:2405, right before UploadFinish, so the new loop never finds a live guard. The merged debt file then contradicts itself. #6498's entry says shader buffer descriptors keep the refusal. This PR's entry (libSceAgcDriver.md:180) says a read-only buffer is not handled.

Suggested fix: name #6498 in the overlap note and the checklist, and agree with its author on an order. Whichever lands second drops the duplicate call and the read-only sentence.

2. The new Written case fails once the #9950 stack lands. NativeMultisampleDepth.cpp:1156 expects "sample-preserving guest publication". Only DepthSurface.cpp:1896 throws that string. #10469, #10492 and #10497 replace that check with publishWrittenDepth, and their tests already switched to PublicationRefusal(format). Each merges cleanly with this PR, keeping line 1156 unchanged. Then, for D16, UploadFinish leads to PublishToGuest, which throws "guest publication of a written native multisample D16 depth is not implemented". TargetRefuses then fails with "multisample target refusal did not match sample-preserving guest publication". Hosted CI skips GPU jobs here. The body says "with #9950 it publishes the samples first", but it has Depends on: none.

Suggested fix: list the stack as overlapping. Whichever lands second then switches this line to PublicationRefusal(format). Alternatively, match the substring "guest publication", which both versions' messages contain.

AI-assisted: yes (Claude Code).

QRMOE and others added 3 commits October 26, 2026 19:44
…y write over it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QRMOE
QRMOE force-pushed the fix/agc-msaa-depth-buffer-write branch from 462a19f to 946de28 Compare October 26, 2026 21:01
@QRMOE

QRMOE commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@thuanquang Thanks, both points hold; I checked them against the code and ran the second one.

  1. fix(agc): refuse buffer aliases of native MSAA targets #6498's requireGuestBuffers() calls RequireNoMultisampleTarget for every guest buffer right before UploadFinish, and that starts with RequireNoResidentDepthRead_nid_no_patch, so it covers this PR's line (and read-only buffers too). The description now lists fix(agc): refuse buffer aliases of native MSAA targets #6498 in the overlap notes. Whichever lands second drops the duplicate: if fix(agc): refuse buffer aliases of native MSAA targets #6498 lands first, this PR drops its UploadFinish line and the read-only sentence of its debt entry and keeps only the test; if this one lands first, fix(agc): refuse buffer aliases of native MSAA targets #6498 can drop that line from GuestBufferMemory.cpp and the sentence when it rebases. @Amoenus, does that order work for you?
  2. The Written case now matches guest publication (946de28), which main's message and PublicationRefusal(format) of the fix(agc): reclaim published native depth owners safely #10469 stack both contain, for D16 and D32. Same RX 9070 XT machine, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest --test-dir build -R "^agc_driver_native_multisample_depth$" -V:

@Amoenus

Amoenus commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

@QRMOE Thanks for retaining the lower-level guard and regression in either landing order. I independently checked your final 609f4f1205 merged onto main b99bbebacd1d (qualification abc874ac2ce1, original authorship retained), after the requested written-surface refusal test was removed.

Windows11 Enterprise26200, GCC15.2r7 Release; RTX5080/NVIDIA621.01 and AMD Radeon Graphics(gfx1036)/26.10.1. Required Vulkan, shader cache disabled, inserted Khronos1.4.363 and actual adapters verified.

Check, per GPU Result
Literal main's original native-depth/retirement/clear modes 3/3 pass
Main production + same merged regression 0/3 pass; expected a buffer the GPU may write left an unwritten native depth surface resident over it
Candidate regression 3/3 pass
Candidate retirement/clear modes 2/2 pass

22 processes total:16 pass,6 intended control failures; max2.265 s, no skips/timeouts or validation warnings/errors/VUIDs. Each positive regression explicitly ran D16(124)/D32(126),2/4/8 samples, depth-plane and HTILE writes, unrelated-owner preservation and unchanged-byte checks; host import required. The aggregate checked=24 counter is separate from those buffer-write cases.

Full verbose logs, exact source/build/artifact pins and limits. Full native/relinker/real fixture builds and conventions pass; pre/post hashes match. Main's newer fixture setup was retained; peer regression/production deltas are unchanged. This is a pinned-main composition, with no title, Linux, full-suite or approval claim.

The agreed #6498 integration contract remains: keep your UploadFinish guard/test, since this fixture calls Upload directly and bypasses our descriptor checks; adjust only the read-only debt sentence when #6498 is present. This replaces my earlier source-only review with measured validation, without adding a dependency or claiming a combined #6498 run. AI-assisted: yes (Codex); author responsible.

@QRMOE

QRMOE commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@Amoenus Agreed, thanks: the test drives GuestBufferMemory::Upload directly, so #6498's descriptor checks don't stand in for the guard. I'll keep the UploadFinish guard and its regression test in either landing order, and drop only the read-only sentence of the debt entry once #6498 is in. The description's overlap note now says that instead of dropping the line.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Linux NVIDIA and lavapipe run. The runs so far are Windows only (RX 9070 XT, RTX 5070 Ti).

Setup: Ubuntu 26.04, GCC 15.2, Release. RTX 3070 (NVIDIA 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), each selected with VK_DRIVER_FILES. Head 946de281e merged with --no-commit onto main b7105f728 (clean; it also merges cleanly onto 8df2c3ed0). Focused runs use ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Khronos layer 1.4.341). VK_LOADER_DEBUG=layer shows the layer inserted, and no log has the missing-layer message.

  • Control (main + only this PR's NativeMultisampleDepth.cpp): agc_driver_native_multisample_depth fails on both devices with a buffer the GPU may write left an unwritten native depth surface resident over it, so CheckBufferWrites reaches the host-import path on both.
  • With the PR: agc_driver_native_multisample_depth passes 3/3 on both devices.
    • 3070: Native multisampled depth cases checked=24 unavailable=0, with the "GPU buffer write over the depth or HTILE released the unwritten surface and refused the written one" line for every sample count.
    • lavapipe: checked=16 unavailable=8.
  • Focused set (^agc_driver_native_multisample_depth, ^agc_driver_multisample, guest_buffer, 16 tests): 16/16 3/3 on the 3070. On lavapipe it is 15/16 3/3; the failure is agc_driver_multisample_retirement, which fails the same way on main on this host. 0 VUID- on either device.
  • ^agc suite (without display/flip/lds_atomics64, -j1 --timeout 30): 3070 1042/1042; lavapipe 1041/1042, with the same multisample_retirement failure as main.
  • Builds clean on Linux, so the sizeof asserts in ShaderDiskCache.cpp and PipelineJournal.cpp hold. public_headers passes with main 8df2c3ed0.

GPUs tested: NVIDIA RTX 3070 (Linux), lavapipe

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@adriadam10 adriadam10 self-assigned this Oct 27, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 27, 2026 21:31

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@QRMOE thanks. At 946de281e1, please drop the new BufferWrite::Written refusal case in NativeMultisampleDepth.cpp (the block at lines 1154-1158, the enum member at 1123, its entry in the loop at 1172, and the part of the final success message that claims it). It asserts that a valid but unimplemented native-depth guest publication throws (TargetRefuses(..., "guest publication")). We keep tests to implemented behavior and argument validation, and a pin like that breaks as soon as publication is implemented; widening the expected message text doesn't change that. Please keep the UploadFinish guard in production and the unrelated and unwritten depth/HTILE retirement and unchanged-byte regression cases. I'm not asking you to implement publication or to loosen the fail-closed behavior. After that, please rerun the remaining native-depth regression on the final head, including its main-production control, and say which host-import format and sample cases actually ran.

The case asserted that a valid but unimplemented guest publication of a
written native depth throws. Tests keep to implemented behaviour, so it
is removed; the unwritten depth-plane and HTILE cases remain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QRMOE

QRMOE commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Done in 609f4f1:

  • Removed: the BufferWrite::Written member, its refusal block, its entry in the CheckBufferWrites loop, and "and refused the written one" in the success message.
  • Unchanged: the UploadFinish guard in production, and the depth-plane and HTILE cases for an unwritten surface. Those still check that an unrelated buffer write keeps the surface resident and that a buffer write over the depth plane or HTILE releases it with guest bytes and HTILE unchanged.

Rerun on the final head 609f4f1, RX 9070 XT, AMD 26.6.2, Windows 11 26200, Vulkan SDK 1.4.363.0, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:

agc_driver_native_multisample_depth Message
This PR Passed 0 VUID- lines
Same test with GuestBufferMemory.cpp from the PR's base (18ef6be0cd, main production) Failed a buffer the GPU may write left an unwritten native depth surface resident over it

Cases that ran:

  • Buffer-write check: host-import format 124 (D16_UNORM) and 126 (D32_SFLOAT) at 2, 4 and 8 samples. Each ran both the depth-plane and the HTILE write.
  • Whole test: checked=24 unavailable=0, so none was skipped for a missing format or sample count.

tools/check_conventions.py --base origin/main passes.

AI-assisted: yes (Claude Code).

@adriadam10

Copy link
Copy Markdown
Collaborator

Rechecked 609f4f1205: the only change is dropping the BufferWrite::Written refusal case that @oneandonlydean asked to remove (enum member, block, loop entry, success-message text). The UploadFinish guard, the unrelated-buffer, depth-plane and HTILE cases and the debt entry are unchanged. Rerun on the final head by the author (RX 9070 XT); merged.

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

Labels

agc libSceAgc* docs unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants