Skip to content

test(agc): watch the sparse flush image again when a GPU store leaves it unwatched - #28086

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Ducengarth:fix/agc-upload-cache-sparse-rewatch
Dec 5, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Ducengarth:fix/agc-upload-cache-sparse-rewatch

Conversation

@Ducengarth

@Ducengarth Ducengarth commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What

agc_driver_upload_cache_read_only_flush fails on Linux at every run since #27438:

AGC graphics: sparse fixture requires an unwatched page inside a backed piece

The SparsePendingWrite case in #27438 has three phases. Its third phase unwatches page 2 of the image and requires pages 0 and 3 to stay watched. On hosts whose host imports do not stay write-watched (Linux and macOS, ImportWatched with staysWatched == false), the GPU store of the second phase already unwatches the whole image. A probe after each step on Linux shows it:

after upload(before):  pages 0-3 watched=1, page 4 (gap) watched=1, page 5 watched=0
after Store(...):      pages 0-3 watched=0, page 4 watched=1, page 5 watched=0

So the third phase could never start there. On Windows the store keeps the pages watched, so the test passed there. #27438's linux job was skipped, so CI never ran the case on Linux.

The fix registers the image for write watching again before the third phase when it is no longer watched. The third phase then runs from the same mixed coverage as on Windows. On Windows the condition is false and nothing changes; the driver is not touched.

Tested

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: NVIDIA GeForce RTX 3090 Ti, Windows 11 (validation layer 1.4.363); llvmpipe (Mesa, LLVM 20.1.2), Linux under WSL2 Ubuntu 24.04
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated a test to register write watching for an image region when it is not already watched.

… it unwatched

On hosts whose host imports do not stay write-watched (Linux and macOS),
the GPU store in SparsePendingWrite unwatches the image pages, so the
interior-unwatch phase added in boykopovar#27438 always failed its precondition
there. Register the image again before that phase; where the store keeps
the pages watched (Windows) nothing changes.

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

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Sparse write-watch test

Layer / File(s) Summary
Conditional write-watch registration
core/libs/prx/libSceAgcDriver/tests/execution/UploadCacheReadOnlyFlush.cpp
SparsePendingWrite registers write watching for the image region only when GuestMemory::Watched reports that it is not already watched.

Suggested labels: agc

Suggested reviewers: kteal, marczx10

Change: Other

Merge Risk: Minimal · up to 8b3eb

This is a test-only fix that re-registers write watching before a test phase on hosts where the store leaves the image unwatched. It does not change production behavior and carries minimal merge risk.

Security architecture risk: Minimal · up to 8b3eb

The change restores write watching when needed so an existing test can exercise mixed page coverage. It does not change production behavior or expose a new interface.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e18fe503-0e26-4286-97ff-86e4c101083a
Commits

Reviewing files that changed from the base of the PR and between 84785fa and 8b3eb6f.

Files selected for processing: 1

  • core/libs/prx/libSceAgcDriver/tests/execution/UploadCacheReadOnlyFlush.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@KainanP

KainanP commented Nov 28, 2026

Copy link
Copy Markdown

Windows data point for this one. I applied #28086 on main 01022f9a71 and ran agc_driver_upload_cache_read_only_flush with the validation layer loaded:

Device Result
RTX 4060 Laptop (10de:28a0) passes
Intel UHD, Raptor Lake (8086:a78b), no second settle queue still fails, with the same fixture-setup message

On the UHD the interior case doesn't get its stored pages watched again after the imports settle, so it can't set itself up even with this change. A variant that runs the interior case only where that re-watch happens passes there, and the rest of the test still runs. I can rebase it on top of this PR once it lands, if that's useful. I'm not opening it now, to avoid a conflicting PR.

AI-assisted: yes (Claude Code); the runs above are local.

@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 — looks good

Nothing blocks this test-only change; the conditional re-registration restores the fixture’s intended watched coverage before it unwatches page 2.

What I ran

Read the prepared diff and the changed test at head 8b3eb6fb3c04a254d5ed70857e35cf862510cb4e, plus the relevant write-watch implementation and its usage. No commands or tests were run.

Results

Check Result Note
Diff and changed test passed One added line reviewed
Related write-watch behavior passed Registration is used for this range
Tests not run Author-reported runs only

Findings

Blocking

None.

Non-blocking

None.

Not verified

Did not independently run the reported Linux or Windows tests. Read review/description.md, review/commits.md, review/manifest.json, review/diff.patch, core/libs/prx/libSceAgcDriver/tests/execution/UploadCacheReadOnlyFlush.cpp, core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp, and core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp. review/files.json was unavailable; the manifest lists one changed file, and its full text was included.

To get this to a good state

Nothing is required.

@Rug-Ket

Rug-Ket commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Tested on an Intel Arc B580 (Linux, Mesa ANV 26.2.5): real hardware where host imports are compared, not watched ([write-watch] host imports resolve write protection: yes (...); imported ranges are compared). On current main the test fails here at every run with the message in the description.

Setup: Intel Arc B580 (BMG-G21, 8086:e20b, xe kernel driver), Mesa ANV 26.2.5-arch1.1 (Vulkan 1.4.354), EndeavourOS, kernel 7.2.11-zen1, GCC 16.2.1, Release, BUILD_TESTING=ON, validation layer 1.4.363. This PR's head merged with git merge --no-ff onto main 1f27e2abfa, compared with a full sweep of that same main on the same machine. ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ANYPS5_GPU=B580; "with validation" adds VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. Targeted test: ctest --test-dir build -R "^<test>$" -V -j 1, 10 times in each mode. Full sweep: ctest --test-dir build -V -j 8 with validation (7342 tests); in every sweep all 1977 Selected GPU lines name the B580, the loader logs Insert instance layer "VK_LAYER_KHRONOS_validation" 2177 times, and was not found but was requested by env var VK_INSTANCE_LAYERS never appears.

main 1f27e2abfa with #28086 (head 8b3eb6fb3c)
agc_driver_upload_cache_read_only_flush, 10x with validation 0/10 (sparse fixture requires an unwatched page inside a backed piece) 10/10 passed
same, 10x without validation 0/10 (same error) 10/10 passed
VUID- lines in those runs 0 0

With the PR: upload cache read-only flush tests passed.

Full sweep with validation: agc_driver_upload_cache_read_only_flush leaves the failure list (9 failures on main, 8 with the PR); no other test changes; 0 VUID- and the same 89 Validation Warning lines in both; the same 75 skips.

AI-assisted: yes (Claude Code)

@ycbuzi

ycbuzi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Tested 8b3eb6fb3c merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 3 tests failed out of 7467; 99% tests passed, 4 tests failed out of 7467. 3 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7467; 100% tests passed, 0 tests failed out of 7467. run

GPU: 4 GPU tests (AGC) passed twice on a GTX 1650 SUPER (Windows 11, Vulkan required, validation layer on, shader cache off), with this pull request merged into main cf9182ff8d. No Vulkan validation message appears that main does not also produce on the same GPU.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Paired Linux runs reproduced the fixture problem. On b97867d3ce6b, agc_driver_upload_cache_read_only_flush failed before the sparse write because the intended watched and unwatched page layout was absent. The patched CTest passed after restoring the image's watch before unwatching the selected page. The scalar-buffer control passed on both. Both Mesa lavapipe logs show Khronos validation 1.4.369 inserted and zero VUID- errors.

AI-assisted: yes.

@JJenkx

JJenkx commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Linux/RADV data point for head 8b3eb6fb3c04. This is an AMD case to set beside the Windows and Intel Arc runs above.

On current main ba0ff896, agc_driver_upload_cache_read_only_flush fails on this machine in 3 of 3 runs. It stops at the fixture check sparse fixture requires an unwatched page inside a backed piece. With this PR merged onto current main, the test passes, with 0 validation errors and the Khronos layer inserted.

The driver's probes on this device report:

  • host imports resolve write protection: yes ... imported ranges are compared
  • dma-buf imports keep write protection: yes ... imported ranges stay watched

Setup: Linux 7.3.6, RX 6650 XT (RADV, Mesa 26.3.1), Release. ctest filter: ^agc_driver_upload_cache.

AI-assisted: yes

@oneandonlydean
oneandonlydean merged commit 1ab419c into boykopovar:main Dec 5, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants