Repository navigation
asahi: avoid eager batch flush after staging blit in agx_transfer_unmap - #840
Conversation
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at 5c4e0de. Dropping the transfer does not drop the staging BO held by the recorded batch. Please include a G14G staged texture upload followed immediately by sampling and CPU readback. Also cover a source resource released at unmap and a subsequent transfer from a second context, so a lost writer dependency or early return to the BO cache is visible. The G16G test row checks the successful same-context path.
|
@RyanTheTide Thanks for the review on Staging BO Lifetime & Writer Dependency (applies identically on
|
| Format | Size | Iters | Checks | Pixels Verified | Mismatches | Result |
|---|---|---|---|---|---|---|
RGBA8 |
64×64 |
64 | 512 | 2,097,152 |
0 | PASS |
RGBA8 |
256×256 |
64 | 512 | 33,554,432 |
0 | PASS |
RGBA8 |
512×512 |
64 | 512 | 134,217,728 |
0 | PASS |
RGBA16F |
64×64 |
64 | 512 | 2,097,152 |
0 | PASS |
RGBA16F |
256×256 |
64 | 512 | 33,554,432 |
0 | PASS |
RGBA16F |
512×512 |
64 | 512 | 134,217,728 |
0 | PASS |
Assisted-by: LLM (Gemini:4 Neon)
The threaded-context test compares a texture's readback with its upload. On a compressed level both directions go through GPU staging blits, which the no-op shim never executes. The comparison passed only while the readback's staging BO was the upload's, recycled through the BO cache. Once the upload's batch stays queued after the staging blit, it no longer is, and the readback holds whatever the new staging BO contained. Compare uncompressed levels only. Signed-off-by: Diljit Singh <hey@djdev.me>
agx_blit_from_staging() records a GPU blit reading trans->staging.rsrc into the current batch, which takes a BO reference on the staging resource via agx_batch_reads(). Flushing readers immediately in agx_transfer_unmap() prematurely splits and submits the batch on every staged texture upload, even though dropping the Gallium resource reference safely leaves the staging BO alive until the batch completes. Signed-off-by: Diljit Singh <hey@djdev.me>
5c4e0de to
4db5fff
Compare
satchlj
left a comment
There was a problem hiding this comment.
Reviewed at head 4db5fff5abc4897572df4f21beec24a5461de868 (asahi: avoid eager batch flush after staging blit in agx_transfer_unmap).
Code audit
- Staging BO lifetime & dependency ordering: Verified that removing
agx_flush_readers(agx_context(pctx), agx_resource(trans->staging.rsrc), ...)inagx_transfer_unmap()is sound.agx_blit_from_staging()routes throughagx_blit(), which recordsagx_batch_reads(batch, staging)(acquiring a batch BO reference viaagx_batch_add_bo()->agx_bo_reference()) andagx_batch_writes(batch, dst). Dropping the Galliumtrans->staging.rsrcreference immediately after leaves the staging BO owned by the batch until GPU fence retirement, preventing premature BO-cache reuse while avoiding an unnecessary flush before subsequent draws/uploads. - Threaded-context test update: Verified the companion
test-agx-threaded-context.cadjustment restricting the level-byte comparison to uncompressed levels (!ail_is_level_twiddled_uncompressedvs compressed layout check).
Verification
Built in an isolated debugoptimized build (-Dtools=drm-shim, MESA_SHADER_CACHE_DISABLE=1) and tested on J775c (Apple M5 Max, G17C B1, Linux 7.3) (OpenGL ES 3.2 Mesa 26.3.0-devel (git-4db5fff5ab)):
meson test --suite asahi: 247/248 PASS — all Gallium/Asahi tests includingasahi-{g13g,g16g,g17p}-threaded-contextandasahi-{g13g,g17p,t6041}-gallium-submitpass; the single failure ishk_sync_stampsline 545 (later stamped work follows the earlier stamp), which is unrelated to this PR and comes from the branch base (187c457f792) predating#912onaurora-wip.- Live Gallium / GLES3 CTS on
Apple M5 Max (G17C B1)(--deqp-surface-type=fbo):dEQP-GLES3.info.renderer: 1/1 PASSdEQP-GLES3.functional.texture.specification.basic_texsubimage2d.*: 99/99 PASSdEQP-GLES3.functional.texture.specification.texsubimage2d_pbo.*: 109/109 PASSdEQP-GLES3.functional.texture.specification.basic_texsubimage3d.*: 49/49 PASSdEQP-GLES3.functional.fbo.color.tex2d.*: 36/36 PASS- 294/294 PASS, zero GPU faults in
dmesg.
Untested scope
- Rebased merge-commit test run on top of post-
#912aurora-wip(notehk_sync_stampsabove). - Live non-M5 hardware (
G13/G14/G15/G16/G17P) and full GLES3/GL46 texture-streaming / BO-cache memory-pressure stress workloads beyond the targeted suites above.
|
Merged into
|
Summary
Removes the redundant eager batch flush after the staging blit in
agx_transfer_unmap()(src/gallium/drivers/asahi/agx_pipe.c).agx_blit_from_staging()already records a GPU blit readingtrans->staging.rsrcinto the current batch, which holds a BO reference on the staging resource viaagx_batch_reads(). Flushing readers immediately inagx_transfer_unmap()prematurely splits and submits the batch on every staged texture upload, whereas dropping the Gallium resource reference safely keeps the staging BO alive until the batch completes.Commits (
2commits, rebased ontoaurora-wip187c457f7920)cf07e99a7e4—asahi: compare only uncompressed levels in the threaded-context test:asahi-threaded-context(added with u_threaded_context) compares a texture's readback with its upload. On a compressed level both directions are GPU staging blits that the no-op drm-shim never executes, so the check passed only while the readback reused the upload's staging BO from the BO cache. With the upload's batch still queued (commit 2) that reuse stops. The test now compares uncompressed levels only. This is the same hunk as in asahi: coalesce multi-pass batches and emit fragment barriers and few-primitives hints #822, so whichever lands first leaves the other a no-op.4db5fff5abc—asahi: avoid eager batch flush after staging blit in agx_transfer_unmap(1 file changed, -2). Rebased acrosse11f293a/439ab416/be4cf473: the only conflict wastransfer->usagebecoming the localusage. The recorded batch still takes its own BO reference on the staging resource (agx_batch_add_bo()→agx_bo_reference()).Verification
4db5fff5abc) mirror CI (DjDeveloperr/mesa,ci/pr840-rebased):aurora-agent-policy: PASS, run 45372465703asahi:252/253, run 45372465639.asahi-{g13g,g16g,g17p}-threaded-contextOK. The one failure ishk_sync_stamps, which fails the same way on the base187c457f7920itself (run 45372466413); borealis/tests: match AGX3 compute timestamp scope in hk_sync_stamps #911 / borealis: expect queue-ordered compute stamps on M5 in the stamps test #912 fix it.LOCAL=1 DEFAULT_BRANCH=<aurora-wip> agent-policy.sh pr HEAD:PR is clean.5c4e0de2c026:meson test --suite asahi—164/164OK.G16G B0,7.3.0-ARCH-m4prod23) verification (dcp95-v17-gpubench):gpubench-glnative:70/70PASS (0fail,0bad CRCs)dEQP-GLES3FBO/texture CTS:159/160PASS (0FAIL,1NS)0GPU dmesg errors,0recoveries,POST_IDLE=IDLE_CLEAN.