Repository navigation
fix(agc): rewatch the ranges of compared host imports that ClearHostImports drops - #13013
Conversation
…mports drops Where host imports are compared rather than watched (Windows without a second queue to settle them on, as Intel UHD drivers expose, and Linux comparison mode), creating an import takes its range off the write watch. Retiring an import puts the range back through noteRetiredUnwatched and rewatchRetired, but ClearHostImports, which runs when a Vulkan device is torn down, destroyed every import and left those ranges unwatched, so later CPU writes to them were not collected. ClearHostImports now notes the unwatched ranges of its imports and rewatches them after the imports are gone, with the same checks retirement uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The teardown path now re-watches still-owned ranges after clearing imports, and the reported Intel regression test plus the exact-head Windows CI pass support the fix.
What I ran
- PR head:
6a84c011c4a8aeb0488a781671976f8705157fd4. - Base:
upstream/mainatd820fef1827f27247cd28da7b4eec7891904bae5; clean merge preview tree689a18a135a92fa7a15db2e35c2eda834a9d3224. - Environment: Linux x86_64; no local build or GPU tests run.
git diff --check upstream/main...refs/review/pr-13013-head
git merge-tree --write-tree upstream/main refs/review/pr-13013-head
python tools/check_conventions.py --base upstream/main --head refs/review/pr-13013-head
git diff --name-only 52f212ec05...upstream/main -- core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp core/libs/prx/libSceAgcDriver/tests/execution/HostImportWindows.cppResults
| Check | Result |
|---|---|
| Patch whitespace | Pass; command exited 0 with no output. |
| Current-main merge preview | Pass; clean tree 689a18a135a92fa7a15db2e35c2eda834a9d3224. |
| Repository conventions | Pass. |
| Current-base comparison | No changes to the implementation or regression-test files since the author-reported base 52f212ec05. |
| Hosted CI | Exact-head Windows product job, eligibility, conventions, intake, labels, and report checks passed. Linux and specialized jobs were skipped. |
| Focused GPU regression | The PR reports agc_driver_host_import_windows failing on the Intel UHD 770 on main and passing 3/3 on this head; it passes on both main and this head on RTX 5070 Ti. The reports also show 0 VUIDs and a loaded validation layer. These runs are author-reported, not locally reproduced. |
Unedited local command output
python tools/check_conventions.py --base upstream/main --head refs/review/pr-13013-head
All conventions checks passed.
git merge-tree --write-tree upstream/main refs/review/pr-13013-head
689a18a135a92fa7a15db2e35c2eda834a9d3224
git diff --check upstream/main...refs/review/pr-13013-head exited 0 and produced no output. The comparison of paths changed since 52f212ec05 also produced no output.
Negative control
| Assertion | Change under test | Result |
|---|---|---|
| Clearing a comparison-mode import must restore watching so a subsequent collection sees resident writes. | Author compared main with this fix on the Intel UHD 770. |
Author reports the test fails on main with resident import collection failed and passes 3/3 on this head. I did not run this control locally. |
Not verified
- I did not build or run GPU tests locally. Linux runtime behavior and other Intel drivers were not tested; the PR reports Linux as not tested.
|
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.
|
|
@SeaSunPT thanks, the existing resident-import test does exercise the reported two-pass failure on a device using comparisons. One allocation-lifetime gap needs closing: the new lease at GuestBufferMemory.cpp:3729 is destroyed at the end of the if block, and state.imports.clear() at 3739 then releases the HostImport range pins before rewatchRetired uses the saved raw addresses. A concurrent allocation mutation can unmap/remap that address after the ownership check but before Rewatch; state.mutex serializes imports, not GuestAllocations mutations. Please retain the validated allocation lease through rewatchRetired (or revalidate under an equivalent lifetime guarantee), as the ordinary retirement path does with its caller-held lease. Moving the lease to function scope (for example a std::optional set inside the if) is enough; a deterministic test for the reuse window would be welcome if it is practical, but is not required for this fix. This is a source-derived race window; I have not reproduced a native crash. Please keep the current live-storage overlap exclusion and the existing two-pass Windows regression. |
…mports The lease that noteRetiredUnwatched checked the ranges against ended with its block, before the imports were destroyed and rewatchRetired ran, so a concurrent allocation mutation could unmap or remap a range between the ownership check and the rewatch. The lease now lives until ClearHostImports returns, as the caller-held lease does for retirement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@oneandonlydean thanks, you're right: the lease ended with the Rerun on this commit, same machine and setup as the description:
|
✅ NVIDIA GPU test: passedPR head
Intermittent validation messages (1, seen once in the parallel run, not reproduced when the test was re-run alone 2 times; not counted against this PR)Unstable on main (4, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (2, not counted against this PR)Validation IDs already present on main (4 IDs in 390 tests)Skipped (41)ReproduceAutomated 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. |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-checked — new head, looks good
The allocation lease now remains alive until rewatchRetired finishes, closing the reviewed range-reuse window; exact-head GPU reports and current-main static checks show no blocking issue.
What I ran
Reviewed PR head f99b5496f73369852453c6463f8388ddd911c8c2, recorded PR base 52f212ec053f917455f2f87674ddb708dcc545d8, against current main 91a69952c10099966378a6a9006b8ef616ae22da. The merge preview is clean (tree 46d698eb2287a20ba13d022526096d2503f4d115). Environment: Linux x86_64, Git 2.39.5, Python 3.11.2; no compiler or project build was run.
git diff --check upstream/main...f99b5496f73369852453c6463f8388ddd911c8c2
python3 tools/check_conventions.py --base upstream/main --head f99b5496f73369852453c6463f8388ddd911c8c2
git merge-tree --write-tree upstream/main f99b5496f73369852453c6463f8388ddd911c8c2Results
| Check | Result |
|---|---|
| Current-main merge preview | Clean; tree 46d698eb2287a20ba13d022526096d2503f4d115. |
git diff --check |
Passed; no output. |
| Conventions | Passed. |
| Author-reported exact-head Windows GPU run | agc_driver_host_import_windows: 3/3 on Intel UHD 770 and 3/3 on RTX 5070 Ti, with 0 VUID- lines. |
| Author-reported exact-head broader suites | RTX 5070 Ti: 1,151/1,151 AGC tests passed. Intel UHD 770 had remaining failures reported as also failing on main. The non-AGC suite had one timeout that passed 3/3 when isolated on both main and the PR. |
| Latest external NVIDIA run | Build passed; 2,258 tests passed, 6 baseline/unstable failures, 0 new failures, 41 skipped, and no new validation IDs. This run is a separate contributor report, not my local execution. |
| Hosted checks | Windows, eligibility, conventions, labels, and report passed; Linux and specialized product jobs were skipped. |
Unedited local command output
$ git diff --check upstream/main...f99b5496f73369852453c6463f8388ddd911c8c2
(no output; exit 0)
$ python3 tools/check_conventions.py --base upstream/main --head f99b5496f73369852453c6463f8388ddd911c8c2
All conventions checks passed.
$ git merge-tree --write-tree upstream/main f99b5496f73369852453c6463f8388ddd911c8c2
46d698eb2287a20ba13d022526096d2503f4d115
Negative control
The author reports agc_driver_host_import_windows fails on main with the Intel UHD 770 comparison-import path and passes 3/3 on the PR. The lease-reuse race itself has no deterministic negative-control test; the author notes that limitation, and I did not mutate the code to try to trigger it.
Findings
Blocking
None found in the reviewed head.
Non-blocking
The exact-head hardware runs are author-reported, not independently rerun here. The documented limitation remains that the regression test does not exercise this teardown path on devices using the settle-queue import mode.
Sources
- Reviewed head
- Current-main merge base
- Author’s exact-head test report
- Exact-head NVIDIA report and logs
Not verified
I did not build or run tests locally, test Linux/other Intel drivers, or test console behavior. I did not independently rerun the reported Windows or NVIDIA test matrices.
To get this to a good state
No further change is requested for this head. I will recheck the same commands and relevant tests if the PR head changes.
|
Checked the diff against |
What
Where host imports are compared rather than watched, creating an import takes its range off the write watch. On Windows that is every device without a second queue to settle imports on, such as the Intel UHD drivers in #12522, which log
[write-watch] Windows direct host imports use comparisons (no second queue to settle imports on). On Linux it is the comparison mode the import probe chooses. Retiring an import (retireLeastRecentand the retire loop that also callsnoteRetiredUnwatched) puts the range back throughrewatchRetired.ClearHostImports, whichVulkanDevicecalls when a device is torn down, destroyed every import without doing that, so those ranges stayed unwatched: later CPU writes to them were not collected, andCollectWritesUncachedover them returned 0.ClearHostImportsnow notes the unwatched ranges of its imports withnoteRetiredUnwatchedbefore destroying them and callsrewatchRetiredonce the import map is empty, so the same rules apply as for a retired import: only ranges whose allocation still owns them are rewatched, and a range a live storage texture overlaps stays unwatched.This fixes
agc_driver_host_import_windowsfrom #12522 (resident import collection failed). Its second pass collects the writes of memory the first pass imported and cleared. The other three failures in #12522 are not touched; the cause I found foragc_driver_msaa_dcc_clear_4is in a comment on the issue.Tested
Windows 11 Pro 26200, Intel Core i5-14600K, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, onmain420b6a064e. After rebasing ontomain52f212ec05,agc_driver_host_import_windowswas run again on both GPUs and passes, with 0VUID-lines. Two GPUs in the same machine, chosen withANYPS5_GPU: the CPU's integrated Intel UHD Graphics 770 (8086:a780, driver 32.0.101.6129, one queue, so imports are compared) and an NVIDIA GeForce RTX 5070 Ti (driver 610.88, which settles imports and keeps them watched). The validation layer is Khronosvulkan-sdk-1.4.363.0, built from source with the same GCC.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "^agc_driver_host_import_windows$" -V, 3 runs per GPU:mainwithresident import collection failed; passes 3 of 3 with this change.main, since its imports stay watched).VUID-lines and nowas not found but was requested by env var VK_INSTANCE_LAYERSline in any log.ctest -j 4 -R "^agc_"withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:agc_driver_host_import_windowsnow passes. The remaining failures all fail onmaintoo: the other three from AGC (Intel UHD, Raptor Lake, Windows): four agc_driver tests fail: device lost in pixel_lds_limit, host import and multisample readback failures #12522,agc_driver_packed_unorm4444_multisample_partial_write(feat(agc): draw partial writes of multisampled 4_4_4_4 targets into a temporary target #11557), andagc_driver_unclamped_normalized_blend, which fails 5 of 5 alone onmainand on this branch.agc_driver_alias_copy_labelpasses 3 of 5 alone on both.agc_driver_depth_clear_hlefailed once in the parallel run and passes 5 of 5 alone on both.ctest -j 8 -E "^agc_": 1875 of 1876 pass;pe_import_firsttimed out once in that run and passes 3 of 3 alone, onmainand on this branch.GuestBufferMemory.cpp.python tools/check_conventions.py --base origin/mainpasses;git diff --checkis clean.python tools/pr_overlap.py --branch fix/agc-rewatch-cleared-host-imports: no overlap with the 49 comparable PRs. Of the 21 that conflict withmainand share this file, only perf(agc): audit a cached template only after the host import set changed #9012 editsClearHostImports, on its last line (++state.epoch), away from these lines.No test catches this on a device that settles its imports: Windows always asks for a settle queue, and there is no switch to turn it off. On devices without one,
agc_driver_host_import_windowsis the regression test.Not tested: Linux (the same code runs there in comparison mode), other Intel drivers, titles.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)8086:a780, driver 32.0.101.6129) and NVIDIA GeForce RTX 5070 Ti (driver 610.88), Windows 11 Pro 26200🤖 Generated with Claude Code