Repository navigation
fix(agc): preserve GPU edge results after unchanged CPU writes - #1918
nikhilpanchal1 wants to merge 2 commits into
Conversation
Merge partial storage-image edges against bounded immutable baselines while preserving real CPU changes, newer driver stores, and allocation ownership. Cover deferred uploads, clears, copies, aliases, fallback, and writeback with runtime regressions.
klosixgaming-arch
left a comment
There was a problem hiding this comment.
I'm not approving this yet, and I want to be specific about why rather than rubber-stamp it. This is a large, intricate change to the write-back / write-tracking core, and I don't think the diff alone gives me enough grounded confidence to sign off.
What I'd want before this is approvable:
-
The core invariant isn't demonstrable from the diff. The whole point is "preserve GPU results in bytes that still equal the baseline, while keeping real CPU edits." That depends on the interaction of four new pieces —
MergeChangedCommitted's per-byte CAS againstoriginal,driverStoredOver/driverBlocks,edgeSnapshot'sallocationweak_ptr ownership, andfinishEdgeMerges'DriverStoredOvergate. The failure mode that matters (a GPU writeback being silently dropped on a CPU-stamped edge, or a CPU edit being overwritten by a stale GPU result) is exactly the class of bug that's easy to miss in review and hard to prove from reading. Can you point me to a concrete before/after capture — the specific glyph/edge that used to be lost and now survives — plus the test that fails onmainand passes here? The body references finding 2 of #865 and "glyphs", but I want the repro, not the claim. -
Competing implementation. You disclose #1599 targets the same finding with a whole-range equality check, and this is a "different" implementation. That's a maintainer decision, but I'd want it made before review, not after — otherwise two large divergent write-back rewrites both sit in review and one gets merged by accident. Which one is the project going with, and is this the chosen one?
-
The CAS merge assumes
originalis a trustworthy per-byte baseline. InMergeChangedCommitted,compare_exchange_strong(expected=original[byte], desired=current[byte])keeps a byte only if the current destination still equalsoriginal. If a CPU wrote to that byte after the baseline was captured but before this merge ran, the CAS would fail and the CPU write survives — good. But if the GPU and CPU both touched the byte, the GPU result wins. Is that the intended precedence, and is it stated in the debt entry? The body says "Newer driver stores retain ownership even when they write the same value" — I want that precedence made explicit and tested, because it's the load-bearing assumption. -
Pre-existing failure disclosure. You report
agc_driver_f32_denormal_flushfailing (lane 20 FMA0x00800000vs0x00ffffff) and claim it reproduces on unmodifiedf1451396. That's plausible (llvmpipe denormal handling), but it's exactly the kind of "it fails and I blame the host" that needs a clean proof. A short note with the exact command and the unmodified-checkout output would close it.
I'm not asking you to prove it's wrong — I'm asking for the evidence that lets me verify the one thing that matters (GPU results not silently lost, CPU edits not clobbered) without having to fully simulate the ownership model in my head. If you can supply 1, 2 and 3, I'll re-review and this is very likely approvable.
Written with AI assistance.
|
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.
|
@klosixgaming-arch Thanks for the review. Added regression tests and documented the merge precedence in 97655b6: changed CPU bytes survive, same-value/ABA writes permit GPU merging, and newer driver stores block stale merges. The updated edge test passes locally, uncached and with synchronization validation; CI is still running. Native/title validation and the choice between #1599 and #1918 remain open. |
|
Native Windows run, since the description notes Windows wasn't tested. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head The new
Everything else passes:
No title was run. 🤖 Addressed by Claude Code |
|
@popcoder565 thanks for the native Windows run, seems you were right about the stack allocation. Fixed in eca4eee: the untracked-range checks now use an address-only range outside the guest arena, and run before Vulkan setup so missing GPU support cannot hide them. All three assertions are preserved. The updated regression passes 10/10 on Linux, plus three runs with Vulkan synchronization validation. I haven’t rerun it on native Windows; could you check the updated head when you have time? |
|
@nikhilpanchal1 thanks. Also, since #2096 merged, the branch conflicts with 🤖 Addressed by Claude Code |
|
@popcoder565 it's cause the PR is closed. You'll have to fetch from fork unfortunately |
|
@nikhilpanchal1 thanks. I hadn't noticed this was closed in favour of #1599 before my run. The branch also conflicts with 🤖 Addressed by Claude Code |
What
Addresses finding 2 of #865. A same-value CPU write dirties a page even when its bytes still hold the allocator fill. Storage-image writeback previously discarded the GPU results for that CPU-stamped edge, losing glyphs.
Keep immutable baselines for at most the two partial 64 KiB edges. Merge GPU results into bytes that still equal the baseline while preserving actual CPU edits. Newer driver stores retain ownership even when they write the same value; retired allocation identities cannot authorize a merge into replacement memory.
Capture baselines before uploads, clears, and copies return, waiting only for earlier physical writes overlapping an edge. Alias borrowing retains baseline ownership, and ordinary GPU writeback renews baselines from the exact immutable retiled output. Full-block ownership and upstream Windows import coverage policy remain intact.
Related open PR: #1599 targets the same finding with a whole-range equality check. This is an alternative implementation that also preserves GPU bytes beside real CPU edits in the same edge and distinguishes ordered driver stores from CPU page stamps. It has no dependency on that PR.
Tested
Linux Release build, GCC 14, Mesa 26.1.6 llvmpipe; Vulkan execution required.
f1451396.agc_driver_f32_denormal_flush: lane 20 FMA returns0x00800000versus expected0x00ffffff. It reproduces after rebuilding and running that target on an unmodified checkout of upstreamf1451396. Shader translation and this floating-point test are unchanged by this patch.ANYPS5_REQUIRE_VULKANis unset; the same setup fails with it set.This host lacks userfaultfd. The new Linux regression uses a test-only page-watch backend; allocation tracking, host imports, detiling, GPU commands, and readback are production code. Native write-watch and subgroup/rasterization capability skips are reported separately from passes. Windows and interactive title testing were not performed.
Checklist
main; competing implementation fix(agc): store GPU results over CPU-stamped bytes the CPU left unchanged #1599 is disclosed above