Skip to content

fix(agc): collect fresh CPU writes before a retiring depth surface stores its stale units - #16368

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
SleglJan:fix/agc-depth-retire-collect
Nov 17, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
SleglJan:fix/agc-depth-retire-collect

Conversation

@SleglJan

@SleglJan SleglJan commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

What

A depth surface retired for an unmatched view (retireStoringStale) decides which stale units to store from WrittenUnits, whose collect of the plane is memoized. A guest write that lands after the thread's earlier walk of the plane in the same collect epoch is not stamped, the unit reads as unwritten, and the store goes over the write. #11690 fixed this decision in the flush path, where FlushDepthPlanes collects uncached first. This is the same write at the retire path.

  • test(agc): a mode of the agc_driver_depth_plane_partial_store_tests executable, registered as agc_driver_depth_plane_cpu_write_after_memo_retire. A depth draw covers the plane and the guest fills one unit, so the plane reads as overwritten in memory; the collect epoch moves and the plane is collected; the guest then writes descriptors into another unit; a view with two levels, which the surface does not serve, retires it. On main it fails with AGC graphics: the retire of a depth surface overwrote CPU descriptors written after a memoized collect. Without a write watch it skips like the flush-path step (agc_driver_depth_plane_cpu_write_after_memo).
  • fix(agc): one uncached collect of the plane before WrittenUnits in retireStoringStale, the call fix(agc): collect fresh CPU writes before depth plane stores #11690 added to the flush path.

Cost: one walk of the plane per retire of this kind.

Related: #14969 (open) covers the stale stencil plane of the same retire; it changes other lines. #15058 changes WrittenUnits itself, for shared memory; this PR adds a call in front of it. #15404 and #9895 add callers of retireStoringStale. #15059 changes the line two above the inserted one. #16011 adds a mode and its registration at the same place in the same test file and fragment; #15015 changes the same test file and adds a line to the fragment. I am happy to rebase behind any of them.

Tested

Head 4a5b07e is this PR's two commits on upstream/main 75a1ced.

  • Linux (CachyOS, kernel 7.2.10), Release, GCC 16.2.1, write watch available. ctest -V -R '^agc_driver_depth_plane_cpu_write_after_memo' with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1, on an AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.2.4) and on lavapipe (llvmpipe, LLVM 23.1.1, Mesa 26.2.4). The pattern matches the new step and the flush-path step of fix(agc): collect fresh CPU writes before depth plane stores #11690.
    • main + the test commit: on both drivers agc_driver_depth_plane_cpu_write_after_memo_retire fails with the line above, and it is a failure, not a skip; agc_driver_depth_plane_cpu_write_after_memo passes. No VUID-.
    • with the fix: both pass on both drivers (the new step in 0.17 s on the RX 9070 XT and 0.05 s on lavapipe). No VUID-.
    • On both drivers and both sides the loader's debug log shows VK_LAYER_KHRONOS_validation inserted; no log reports was not found but was requested by env var VK_INSTANCE_LAYERS.
  • ctest -R '^agc' on the RX 9070 XT, without the validation layer: 2 of 1342 fail with the test commit, 1 of 1342 with the fix. The new step is the only difference in the failed list. agc_driver_tessellation fails (segmentation fault) on both sides, and the same 23 tests skip on both.
  • python3 tools/check_conventions.py --base upstream/main: passes.

No title effect is claimed.

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: none
  • GPUs tested: AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Linux (CachyOS, kernel 7.2.10); lavapipe (llvmpipe, LLVM 23.1.1), Mesa 26.2.4, same host
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

SleglJan and others added 2 commits November 6, 2026 12:52
…t across a retire

agc_driver_depth_plane_cpu_write_after_memo_retire: the guest writes one unit of a depth plane after
the thread's earlier collect of the plane in the same collect epoch, then a view of another layout
retires the surface. The stale units stored at the retire must not go over the write.

The flush path has agc_driver_depth_plane_cpu_write_after_memo since boykopovar#11690; this is the same write at
the retire path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ores its stale units

A depth surface retired for an unmatched view decides which stale units to store from a memoized
collect of the plane. A guest write that landed after the thread's earlier walk of the plane in the
same collect epoch stays unstamped, the unit reads as unwritten, and the store goes over the write.

The flush path collects uncached before the same decision since boykopovar#11690. The retire path now does too.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added build agc libSceAgc* labels Nov 6, 2026
@JJenkx

JJenkx commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Windows check of head 4a5b07ede6, merged onto main 1ff0fe98aa (a130bd9be0, clean merge).

Correction: my first run (on e8b1bd3d7f) rebuilt only agc_driver_depth_plane_partial_store_tests. Six of the 17 tests come from five other executables that were left from an earlier build, so they didn't test this PR. I reran with all six depth-plane executables rebuilt from the merge; the result below replaces the first one.

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, Radeon RX 6700 XT, AMD driver 26.10.1. Run through the Windows test queue with ANYPS5_REQUIRE_VULKAN=1 and Vulkan validation layers 1.4.363. The hosted Windows check does not run these GPU tests on pull requests.

  • All 17 agc_driver_depth_plane_* tests, built from all six agc_driver_depth_plane_*_tests executables, pass in 3 of 3 runs on the real device, none skipped. They include this PR's cpu_write_after_memo_retire and the existing cpu_write_after_page_unwatch and cpu_write_after_partial_unwatch cases.
  • The Vulkan device was created in each run, and there were no VUID- errors.

AI-assisted: yes.

@milescoviello

Copy link
Copy Markdown
Contributor

Runs of this PR on two NVIDIA machines, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:

Machine Tree ^agc_driver_depth_plane_
Linux, RTX 4070 Ti, NVIDIA 615.71.09, GCC 15.2, Khronos layer 1.4.341 main 9a4bcc3018 16 of 16 pass, 15 devices created, no VUIDs
merge 301771c28f 17 of 17 pass (with agc_driver_depth_plane_cpu_write_after_memo_retire), 16 devices created, no VUIDs
Windows 11 VM, GT 1030, NVIDIA 582.78, WinLibs GCC 15.2 merge-base 75a1ced878 every mode of agc_driver_depth_plane_partial_store_tests passes in 3 of 3 runs
head 4a5b07ede6 the same, plus _cpu_write_after_memo_retire 3 of 3

On the VM I built only agc_driver_depth_plane_partial_store_tests, so the pattern's tests from other executables (_buffer_memory, _fill, _guest_layers) ran stale binaries on both sides (0xc0000139) and aren't counted.

AI-assisted: yes (Claude Code)

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 4a5b07e merged onto main 9fb6149 · tested 2026-11-06 23:05 UTC · 21 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 3,003 passed · 4 failed (0 new, 3 also fail on main, 1 unstable on main) · 55 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 3,062 of 4,235 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (991 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 1 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (9 IDs in 595 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (595 tests): agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_draw_space_reuse_verify, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, and 587 more
VUID-VkShaderModuleCreateInfo-pCode-08737 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08739 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08741 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_prepared_exports
VUID-VkPipelineShaderStageCreateInfo-module-parameter (1 test): agc_driver_float16_unused_nan_payloads
VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849 (1 test): agc_driver_float16_unused_nan_payloads
Skipped (55)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_net_ctl_disconnected: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_device_capability: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_four_k: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_height_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_limit: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_malformed: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_width_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in curre
Reproduce
git fetch origin 4a5b07ede668434de9e752bdf0eb4a725f7e576b 9fb6149d12d51e8dc769943c828f2f23635acb4d
git checkout 9fb6149d12d51e8dc769943c828f2f23635acb4d && git merge --no-ff 4a5b07ede668434de9e752bdf0eb4a725f7e576b
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions

github-actions Bot commented Nov 7, 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 7642 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_depth_plane_partial_store_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/DepthPlanePartialStore.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 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 17915 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 17956 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 20315 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp

# Conflicts:
#	core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_depth_plane_partial_store_tests.cmake
#	core/libs/prx/libSceAgcDriver/tests/execution/DepthPlanePartialStore.cpp
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 17, 2026
@oneandonlydean
oneandonlydean merged commit 5a4ce27 into boykopovar:main Nov 17, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants