Repository navigation
nvn/upload: a staged upload whose batch was flushed never reads the flushed batch's source buffer - #2516
nvn/upload: a staged upload whose batch was flushed never reads the flushed batch's source buffer#2516akratch wants to merge 1 commit into
Conversation
…lushed batch's source buffer pkg_upload_ reads a texture in a large pool through a zero-copy buffer of the upload batch (up_big_src), which the batch keeps and its completion handler takes out of the residency set and releases (up_flush). Taking the texture's staging (up_alloc) can flush that batch. The upload then asks for a buffer of the new batch (PR seedds#2378 does so only after a batch change), but when that was refused (the pool became resident or had an address given out meanwhile, the raw memory table now holds the whole pool, or Metal made no buffer) it went on with the first one: the new batch's deswizzle read a buffer the flushed batch retires, out of the residency set and released once that batch completes. A refusal after a batch change now drops the first buffer and looks the storage up as for any other pool (mtl_addr); with no buffer there the texture is read on the CPU, as for a format the GPU deswizzle refuses. It does not return nil: the caller has already counted the pages as seen. t_upload_src repeats its batch split with the second buffer refused through a test switch (t_up_src_refuse): 55 checks. With the fallback disabled the refused case fails its count check on every run; the stale read itself depends on when the flushed batch completes and the test does not make it visible. Found by reading; no game symptom is attributed to it.
|
Hi! This branch is based on a To pick up the fix, merge the current git fetch origin
git merge origin/main
git pushIf the merge has conflicts, ask here if you want help with them. |
|
Closing: current main already handles the core case this PR fixed — when the second source buffer after a batch flush is refused, main now takes a new buffer and falls back to the CPU instead of reading the flushed batch's buffer (seen on main around 31fdefe). The remaining differences here (an mtl_addr retry and in-batch wrapper reuse) are minor and not worth a separate change. Thanks for the CI note! |
pkg_upload_reads a packaged texture in a large pool through a zero-copy buffer of the open upload batch (up_big_src). The batch keeps that buffer ing_up_keep, andup_flush's completion handler removes each kept object from the residency set and releases it. Taking the texture's staging (up_alloc) can flush that batch. Since PR #2378 the upload asks for a second buffer only when the batch changed (g_up_seq != src_batch), but when that secondup_big_srcreturns nil it keeps using the first buffer, which now belongs to the flushed batch: the new batch's deswizzle is encoded against a buffer the flushed batch retires when it completes.up_big_srccan refuse between the two calls when the pool became resident or had an address given out, when the raw memory table now holds the whole pool, or when Metal makes no buffer.Fix: a refusal after a batch change drops the first buffer and looks the storage up as for any other pool (
mtl_addr). With no buffer there either, the texture takes the existing CPU path, as for a format the GPU deswizzle refuses. It does not return nil, because the caller has already counted the texture's pages as seen. The path taken when the second buffer is made is unchanged.Validation on head
173c3485based on upstream0c078130f6db7d0d32c1dc28146feaf97713f008, Apple M4 Max / macOS 27.2, Xcode 27.2, profile0400486024DEC000:make -C dm/gfx/tests GAME=0400486024DEC000 check_t_upload_src(Metal validation): 55 checks, 0 failed. The test now repeats its batch split with the second buffer refused through a test-only switch (t_up_src_refuse): no second buffer is made, the upload whose staging flushed the batch gives up the first one (g_up_src_stale= 1), and every texel matches the CPU reference.each upload whose batch was flushed gives up the flushed batch's bufferon 3 of 3 runs (55 checks, 1 failed). Fix restored, test rebuilt and passed again.check_t_upload_budget: 261 checks, 0 failed.make -C dm/host GAME=0400486024DEC000builds.python3 dm/tools/tests/test_docs.py: 6 tests pass;python3 dm/tools/docs_symptoms.py --check: current.Limits:
pkg_upload_andup_flush; no game symptom, wrong picture or GPU error is attributed to it, and no run was shown to hit the refusal (it needs the pool's state to change between the twoup_big_srccalls).mtl_addr; the CPU fallback for a pool with no buffer is not exercised.regress.py check, any game, iOS. No chain, profile or front-end interface change.Docs: new entry in
docs/reference/memory.md(after PR #2378's entry) and its symptom index line; "Found on: no game".