agc_driver_multisample_fill_host_only fails intermittently: the sentinel fill after an absorbed multisampled clear does not land #6512

Closed
opened 2026-10-15 18:11:13 +00:00 by ps54all · 4 comments
ps54all commented 2026-10-15 18:11:13 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-15T18:11:13Z.


What happens

agc_driver_multisample_fill_host_only (core/libs/prx/libSceAgcDriver/tests/execution/MultisampleFillHostOnly.cpp, added in #5313) fails intermittently with:

AGC graphics: the sentinel fill did not land

On current main (03c4cb5e7) it failed 10 of 200 consecutive runs of the test binary (run directly with the ctest environment: ANYPS5_NO_SHADER_CACHE=1, PATH prepended with build/core/libs/libs/unpatched, working directory the source root). A single ctest run usually passes, so it shows up as a random red test.

Where it fails

I added a local print to Settle() (not part of any PR) that runs when the comparison fails. It shows the sentinel's value read through GuestMemory::Read, a direct host read of the block, and a second read after one more AgcDriverWaitIdle_nid_postfix(). Six failures out of 74 runs printed the same thing every time:

DIAG settle round 2 read 1,1,1,1 direct 1,1 after-second-wait 1,1

So:

  • It is always the second Settle(), the one right after DispatchFill(code, color.Address(), BlockBytes, 0), which is the fill MultisampledColorFillAbsorbs takes as the multisampled target's clear (the absorbed path in Execution/src/Driver/Memory/BufferFill.cpp).
  • The sentinel still holds round 1's value. A host read gives the same result, and so does a read after a second idle wait. So the round-2 sentinel fill (1024 bytes of 2) is lost or never written back. This does not look like a readback that comes too early.
  • The first Settle() and the later ones never failed.

How long it has been there

Failure rates over consecutive runs on one machine:

Tree Failed
main e34c47921 1/200 (0/60 in an earlier batch)
main 08a7f7a8c 2/200
main 03c4cb5e7 (current) 10/200

A first-parent bisect between e34c47921 and 38d245448 at 60 runs per step ended on a tools-only merge (#5308), which cannot affect this test. The flake is older than that range, and 60 runs are too few at these rates. I don't know which change introduced it. The rate seems to have gone up on newer main, but the samples are small.

Not measured

  • Only one machine: Windows 11, MinGW (winlibs GCC 15.2), RTX 3080 10 GB, NVIDIA 610.74. Not tried on Linux, macOS, or AMD/Intel GPUs.
  • Not tried with APS5_PIPELINE_DRAIN_FILLS=1, so I don't know whether the queue-0 ordered-fill path (DrawPipeline::Queue0().Enqueue) is involved.
  • No root cause, only the location above.

Reproduce

cmake --build build --target agc_driver_multisample_fill_host_only_tests
ctest --test-dir build -R "^agc_driver_multisample_fill_host_only$" --repeat until-fail:200

Found, measured and written with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5871486225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6512). Originally posted by [ps54all](https://github.com/ps54all) on 2026-10-15T18:11:13Z. --- ## What happens `agc_driver_multisample_fill_host_only` (`core/libs/prx/libSceAgcDriver/tests/execution/MultisampleFillHostOnly.cpp`, added in #5313) fails intermittently with: ``` AGC graphics: the sentinel fill did not land ``` On current main (03c4cb5e7) it failed 10 of 200 consecutive runs of the test binary (run directly with the ctest environment: `ANYPS5_NO_SHADER_CACHE=1`, `PATH` prepended with `build/core/libs/libs/unpatched`, working directory the source root). A single ctest run usually passes, so it shows up as a random red test. ## Where it fails I added a local print to `Settle()` (not part of any PR) that runs when the comparison fails. It shows the sentinel's value read through `GuestMemory::Read`, a direct host read of the block, and a second read after one more `AgcDriverWaitIdle_nid_postfix()`. Six failures out of 74 runs printed the same thing every time: ``` DIAG settle round 2 read 1,1,1,1 direct 1,1 after-second-wait 1,1 ``` So: - It is always the second `Settle()`, the one right after `DispatchFill(code, color.Address(), BlockBytes, 0)`, which is the fill `MultisampledColorFillAbsorbs` takes as the multisampled target's clear (the absorbed path in `Execution/src/Driver/Memory/BufferFill.cpp`). - The sentinel still holds round 1's value. A host read gives the same result, and so does a read after a second idle wait. So the round-2 sentinel fill (1024 bytes of 2) is lost or never written back. This does not look like a readback that comes too early. - The first `Settle()` and the later ones never failed. ## How long it has been there Failure rates over consecutive runs on one machine: | Tree | Failed | |---|---| | main e34c47921 | 1/200 (0/60 in an earlier batch) | | main 08a7f7a8c | 2/200 | | main 03c4cb5e7 (current) | 10/200 | A first-parent bisect between e34c47921 and 38d245448 at 60 runs per step ended on a tools-only merge (#5308), which cannot affect this test. The flake is older than that range, and 60 runs are too few at these rates. I don't know which change introduced it. The rate seems to have gone up on newer main, but the samples are small. ## Not measured - Only one machine: Windows 11, MinGW (winlibs GCC 15.2), RTX 3080 10 GB, NVIDIA 610.74. Not tried on Linux, macOS, or AMD/Intel GPUs. - Not tried with `APS5_PIPELINE_DRAIN_FILLS=1`, so I don't know whether the queue-0 ordered-fill path (`DrawPipeline::Queue0().Enqueue`) is involved. - No root cause, only the location above. ## Reproduce ``` cmake --build build --target agc_driver_multisample_fill_host_only_tests ctest --test-dir build -R "^agc_driver_multisample_fill_host_only$" --repeat until-fail:200 ``` Found, measured and written with AI assistance (Claude Code).
fanyzp commented 2026-10-15 19:59:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by fanyzp on 2026-10-15T19:59:38Z.


Not reproducible on Linux/RADV here, and one code path that can produce this shape. A change following from it is in #6548.

Measured on this machine (RADV, Radeon 680M, Mesa 26.2.3, Linux 7.2.8; ANYPS5_NO_SHADER_CACHE=1, the ctest environment, and 200 of the runs with the process pinned to two CPUs): 300 + 200 runs of agc_driver_multisample_fill_host_only_tests on RADV and 200 on lavapipe: 0 failures. A temporary print in Driver::storeBufferFill shows the absorbed multisampled clear (absorbed 1) and every sentinel fill stored 1, so they are recorded with vkCmdFillBuffer into the host import rather than written by the CPU.

What the symptom needs. An imported guest range is the guest's own memory and the CPU reads that pointer, but bindImport (core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp) binds the import to the first memory type the intersection offers (std::countr_zero), whatever that type guarantees, and nothing invalidates an imported range: there is no vkMapMemory behind it, so vkInvalidateMappedMemoryRanges does not apply. On a device whose pointer's bits put a non-HOST_COHERENT type first (a HOST_CACHED one, say), a store the GPU makes through the import can stay invisible to the CPU: the line the previous round's read cached is what the later reads return, which is why the value stays at round 1's through more reads and idle waits instead of appearing late. On this machine the pointer's bits are one coherent type, so it cannot happen here, which matches 0/700.

Which types your device reports settles it. #6548 takes a HOST_VISIBLE | HOST_COHERENT candidate for a host-pointer import (a cached one when the device offers it) and refuses the import when the device reports none, in which case the range is copied and the log says host import of 0x… failed at memory type selection without host coherency. After it: an import that is not refused is coherent and this flake should be gone; a flake that continues with no such refusal is a different cause and worth reporting here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6201093173 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6512#issuecomment-6201093173). Originally posted by [fanyzp](https://github.com/fanyzp) on 2026-10-15T19:59:38Z. --- Not reproducible on Linux/RADV here, and one code path that can produce this shape. A change following from it is in #6548. **Measured on this machine** (RADV, Radeon 680M, Mesa 26.2.3, Linux 7.2.8; `ANYPS5_NO_SHADER_CACHE=1`, the ctest environment, and 200 of the runs with the process pinned to two CPUs): 300 + 200 runs of `agc_driver_multisample_fill_host_only_tests` on RADV and 200 on lavapipe: 0 failures. A temporary print in `Driver::storeBufferFill` shows the absorbed multisampled clear (`absorbed 1`) and every sentinel fill `stored 1`, so they are recorded with `vkCmdFillBuffer` into the host import rather than written by the CPU. **What the symptom needs.** An imported guest range is the guest's own memory and the CPU reads that pointer, but `bindImport` (`core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`) binds the import to the first memory type the intersection offers (`std::countr_zero`), whatever that type guarantees, and nothing invalidates an imported range: there is no `vkMapMemory` behind it, so `vkInvalidateMappedMemoryRanges` does not apply. On a device whose pointer's bits put a non-`HOST_COHERENT` type first (a `HOST_CACHED` one, say), a store the GPU makes through the import can stay invisible to the CPU: the line the previous round's read cached is what the later reads return, which is why the value stays at round 1's through more reads and idle waits instead of appearing late. On this machine the pointer's bits are one coherent type, so it cannot happen here, which matches 0/700. **Which types your device reports settles it.** #6548 takes a `HOST_VISIBLE | HOST_COHERENT` candidate for a host-pointer import (a cached one when the device offers it) and refuses the import when the device reports none, in which case the range is copied and the log says `host import of 0x… failed at memory type selection without host coherency`. After it: an import that is not refused is coherent and this flake should be gone; a flake that continues with no such refusal is a different cause and worth reporting here.
jotitadev commented 2026-10-15 21:27:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T21:27:36Z.


A Linux + NVIDIA data point. The report has Windows + RTX 3080 only, and #6548 says it is not established which memory types a discrete GPU's driver reports for a host pointer.

Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release, BUILD_TESTING=ON. Unchanged main at 44df21632. Each run is a fresh ctest -R "^agc_driver_multisample_fill_host_only$" -j1 --timeout 60, with the selected device checked in every log.

Device (ANYPS5_GPU) Load Failed
NVIDIA GeForce RTX 3070 idle 0/230 (30 + 200)
NVIDIA GeForce RTX 3070 12 busy-loop processes on the 12 threads 0/30
llvmpipe (LLVM 21.1.8) idle 0/30
llvmpipe (LLVM 21.1.8) same load 0/30

So the flake does not reproduce on this machine.

Memory types for a host-pointer import on this driver, from a small standalone Vulkan program (not AnyPS5 code): an anonymous private 1 MiB mmap, vkGetMemoryHostPointerPropertiesEXT with HOST_ALLOCATION_BIT_EXT, intersected with the requirements of a storage + transfer buffer created for that handle type:

Device Candidate types Lowest index
RTX 3070, 595.99.02 3 HOST_VISIBLE | HOST_COHERENT; 4 HOST_VISIBLE | HOST_COHERENT | HOST_CACHED 3 (coherent, not cached)
llvmpipe 0 DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT | HOST_CACHED 0

On this NVIDIA Linux driver every candidate is coherent, so countr_zero already lands on a coherent type here. I have not checked what the Windows driver reports.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6202644877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6512#issuecomment-6202644877). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T21:27:36Z. --- A Linux + NVIDIA data point. The report has Windows + RTX 3080 only, and #6548 says it is not established which memory types a discrete GPU's driver reports for a host pointer. **Machine:** NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release, `BUILD_TESTING=ON`. Unchanged `main` at `44df21632`. Each run is a fresh `ctest -R "^agc_driver_multisample_fill_host_only$" -j1 --timeout 60`, with the selected device checked in every log. | Device (`ANYPS5_GPU`) | Load | Failed | |---|---|---| | NVIDIA GeForce RTX 3070 | idle | 0/230 (30 + 200) | | NVIDIA GeForce RTX 3070 | 12 busy-loop processes on the 12 threads | 0/30 | | llvmpipe (LLVM 21.1.8) | idle | 0/30 | | llvmpipe (LLVM 21.1.8) | same load | 0/30 | So the flake does not reproduce on this machine. Memory types for a host-pointer import on this driver, from a small standalone Vulkan program (not AnyPS5 code): an anonymous private 1 MiB `mmap`, `vkGetMemoryHostPointerPropertiesEXT` with `HOST_ALLOCATION_BIT_EXT`, intersected with the requirements of a storage + transfer buffer created for that handle type: | Device | Candidate types | Lowest index | |---|---|---| | RTX 3070, 595.99.02 | 3 `HOST_VISIBLE \| HOST_COHERENT`; 4 `HOST_VISIBLE \| HOST_COHERENT \| HOST_CACHED` | 3 (coherent, not cached) | | llvmpipe | 0 `DEVICE_LOCAL \| HOST_VISIBLE \| HOST_COHERENT \| HOST_CACHED` | 0 | On this NVIDIA Linux driver every candidate is coherent, so `countr_zero` already lands on a coherent type here. I have not checked what the Windows driver reports. Written with AI assistance (Claude Code). I ran the tests above on my machine.
Amoenus commented 2026-10-16 21:25:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-16T21:25:59Z.


I independently confirmed the device-ownership defect already addressed by #6522 while validating native multisample initialization. The finding below supports that existing PR; it is not a new fix proposal. Completed follow-up: the actual #6522 commit with the original two-device fixture preserved passes 200 processes on each of NVIDIA, AMD and llvmpipe. The separate experiment below is retained as diagnostic evidence only.

The test keeps the standalone OpenVulkanTestDevice() alive, then its first packet submission creates the driver's own device. That second constructor activates its recorder globally. The fixture still creates native images using the first device's context, while MultisampleTarget.cpp::recordCommands takes Recorder::Active() from the second device. Thus native resources and the command recorder belong to different logical Vulkan devices.

A regression assertion immediately after the existing plain-memory control dispatch, before creating any native target, fails on Windows NVIDIA, Windows AMD and Linux llvmpipe:

AGC graphics: multisampled fill: native targets and packet submissions use different Vulkan recorders

Independent fixture-isolation experiment: initialize the driver through that existing control dispatch, acquire its actual device through a private test friend, and use that device for the native targets and cleanup. The temporary availability probe is destroyed first. All original fill, sentinel, sRGB and retirement assertions remain. This experiment is preserved on the fork, but is not being submitted upstream: the original two-device fixture provides useful regression coverage for #6522.

  • Focused fork changes.
  • Assertion-only control, with main production code unchanged: fails on Linux llvmpipe. The identical assertion on main bc3c0fc13 also fails on both Windows GPUs.
  • Fixed: 200/200 fresh processes per device, no skips, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, serial CTest, 30-second individual timeout. Windows was tested at 76ba458757b7a310f3934aa2ec1e1bfd402a0253; rebasing to 3d5ff37ba7532fce1e76542eac9a57d72471f98e changes documentation only, with identical core/ contents. Linux was tested at the rebased head.
Device Driver / OS Maximum individual test
NVIDIA GeForce RTX 5080 610.62, Windows 11 Enterprise build 26200 1.40 s
AMD Radeon(TM) Graphics, device 0x13c0 32.0.21036.18, same Windows 0.64 s
llvmpipe, LLVM 20.1.2 Mesa 25.2.8, Ubuntu 24.04 on WSL2 0.31 s

This establishes an invalid fixture setup and a correction, not that every historical round-2 sentinel failure has this cause. I have not reproduced the reporter's RTX 3080 configuration or established whether #6548 addresses an additional cause. No game startup improvement is claimed.

AI-assisted: Codex. Builds, source checks and the runs above were performed locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6225007000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6512#issuecomment-6225007000). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-16T21:25:59Z. --- I independently confirmed the device-ownership defect already addressed by #6522 while validating native multisample initialization. The finding below supports that existing PR; it is not a new fix proposal. **Completed follow-up:** [the actual #6522 commit with the original two-device fixture preserved passes 200 processes on each of NVIDIA, AMD and llvmpipe](https://github.com/boykopovar/AnyPS5/pull/6522#issuecomment-6225135127). The separate experiment below is retained as diagnostic evidence only. The test keeps the standalone `OpenVulkanTestDevice()` alive, then its first packet submission creates the driver's own device. That second constructor activates its recorder globally. The fixture still creates native images using the first device's context, while `MultisampleTarget.cpp::recordCommands` takes `Recorder::Active()` from the second device. Thus native resources and the command recorder belong to different logical Vulkan devices. A regression assertion immediately after the existing plain-memory control dispatch, before creating any native target, fails on Windows NVIDIA, Windows AMD and Linux llvmpipe: ```text AGC graphics: multisampled fill: native targets and packet submissions use different Vulkan recorders ``` Independent fixture-isolation experiment: initialize the driver through that existing control dispatch, acquire its actual device through a private test friend, and use that device for the native targets and cleanup. The temporary availability probe is destroyed first. All original fill, sentinel, sRGB and retirement assertions remain. This experiment is preserved on the fork, but is not being submitted upstream: the original two-device fixture provides useful regression coverage for #6522. - [Focused fork changes](https://github.com/Amoenus/AnyPS5/compare/0dc15620d...3d5ff37ba7532fce1e76542eac9a57d72471f98e). - [Assertion-only control](https://github.com/Amoenus/AnyPS5/commit/cd2eec87a1a4583ca34fa1e0446be076c4c126fb), with main production code unchanged: fails on Linux llvmpipe. The identical assertion on main `bc3c0fc13` also fails on both Windows GPUs. - Fixed: 200/200 fresh processes per device, no skips, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, serial CTest, 30-second individual timeout. Windows was tested at `76ba458757b7a310f3934aa2ec1e1bfd402a0253`; rebasing to `3d5ff37ba7532fce1e76542eac9a57d72471f98e` changes documentation only, with identical `core/` contents. Linux was tested at the rebased head. | Device | Driver / OS | Maximum individual test | | --- | --- | --- | | NVIDIA GeForce RTX 5080 | 610.62, Windows 11 Enterprise build 26200 | 1.40 s | | AMD Radeon(TM) Graphics, device 0x13c0 | 32.0.21036.18, same Windows | 0.64 s | | llvmpipe, LLVM 20.1.2 | Mesa 25.2.8, Ubuntu 24.04 on WSL2 | 0.31 s | This establishes an invalid fixture setup and a correction, **not** that every historical round-2 sentinel failure has this cause. I have not reproduced the reporter's RTX 3080 configuration or established whether #6548 addresses an additional cause. No game startup improvement is claimed. AI-assisted: Codex. Builds, source checks and the runs above were performed locally.
cadenasynyster commented 2026-10-18 00:24:05 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-18T00:24:05Z.


Windows + NVIDIA reproduction on current main, and #6522 stops it under the same conditions.

Windows 11 10.0.26200.9711, NVIDIA GeForce RTX 5070 Ti (driver 617.42), Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. main b51c65dd1. Each run is a fresh ctest --test-dir build -R "^agc_driver_multisample_fill_host_only$".

tree load failed
main none, serial 0/200
main rest of the ^agc suite running at -j7 in the background 8/100, then 5/100
main + #6522 (head 09f5749, clean merge) same background load 0/100

The failures print AGC graphics: the sentinel fill did not land, the same message as the report. It first showed up as the single failure in a full ctest -R "^agc" -j8 run (671/672 passed). So on this machine it needs CPU/GPU contention and never happened in 200 idle runs, which may be why the Linux runs above didn't reproduce it.

With #6522 merged, 0 of 100 under load. At the main rate (13/200), 0/100 would happen by chance about 0.1% of the time. The background load isn't exactly identical between batches (it's the same suite started the same way, but the loop and the suite don't finish in lockstep).

Not checked: #6548. Its merge onto this main conflicts in docs/dev/debt/libSceAgcDriver.md, and the run was cut short. Running the agc suite in parallel produced repeated nvlddmkm event 153 GPU resets on this machine and eventually hung it, so I didn't retry under the same load. That happened on plain main too, so it says nothing about either PR.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243688561 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6512#issuecomment-6243688561). Originally posted by [cadenasynyster](https://github.com/cadenasynyster) on 2026-10-18T00:24:05Z. --- Windows + NVIDIA reproduction on current main, and #6522 stops it under the same conditions. Windows 11 10.0.26200.9711, NVIDIA GeForce RTX 5070 Ti (driver 617.42), Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. main b51c65dd1. Each run is a fresh `ctest --test-dir build -R "^agc_driver_multisample_fill_host_only$"`. | tree | load | failed | |---|---|---| | main | none, serial | 0/200 | | main | rest of the `^agc` suite running at `-j7` in the background | 8/100, then 5/100 | | main + #6522 (head 09f5749, clean merge) | same background load | **0/100** | The failures print `AGC graphics: the sentinel fill did not land`, the same message as the report. It first showed up as the single failure in a full `ctest -R "^agc" -j8` run (671/672 passed). So on this machine it needs CPU/GPU contention and never happened in 200 idle runs, which may be why the Linux runs above didn't reproduce it. With #6522 merged, 0 of 100 under load. At the main rate (13/200), 0/100 would happen by chance about 0.1% of the time. The background load isn't exactly identical between batches (it's the same suite started the same way, but the loop and the suite don't finish in lockstep). Not checked: #6548. Its merge onto this main conflicts in `docs/dev/debt/libSceAgcDriver.md`, and the run was cut short. Running the agc suite in parallel produced repeated `nvlddmkm` event 153 GPU resets on this machine and eventually hung it, so I didn't retry under the same load. That happened on plain main too, so it says nothing about either PR. AI-assisted: yes
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#6512
No description provided.