RUNTIME 2452: Sparse scrubs: a rebind encodes the encoder of a scrub again

A blit or a render pass that writes a sparse texture leaves a scrub of the
unmapped tiles it wrote, recorded at its batch's submission
(Deferred::SparseScrub). Deferred::resolved_at_its_calls answered false for
it, so the commit's steps_hold kept the pages of every buffer over host pages
the command buffer used until completion, and a rebind of one before the first
submission was refused with Invalid(Rebind(EncodedUses)). Had it not been,
the encoder kept no log (Unlogged::Segments), and the submission would have
failed EncodedUseRebound.

The scrub zeroes tiles of its texture alone, as its batch mapped them, and
reads no buffer. So it is now resolved at its calls, and left again by an
encoding again: the blit or pass encoded again leaves its own scrub over the
same texture, and the first's goes unrun (finish_replay prepares it;
splice_replay retains the first's). Unlogged::Segments now names only a
GPU-written indirect dispatch's host step. The docs of records_again,
finish_replay and splice_replay name the scrub.

The test is tests/rebind_sparse_scrub.rs. The texture's left tiles are mapped,
then a blit writes the whole texture and fills a no-copy buffer behind a
shared-event gate. The buffer is rebound before the signal, and the test
asserts:
- the command buffer completed with no error;
- one encoder was encoded again;
- the fill reached the new pages and not the old;
- the mapped tiles hold the blit's texels.
The control (this commit's deferred.rs reverted) fails at the rebind with
Invalid(Rebind(EncodedUses)).

Degradation kinds added or removed: none.

Verified: m3-max-36396 at 8f4ce875f5 (same tree), clippy -D warnings of the runtime (all targets and features) 0 and rustdoc -D warnings 0. The cfg clippy, the control, the rebind tests, the suites on lavapipe and the sparse conformance replay run after the merge.
This commit is contained in:
Anees Iqbal committed 2026-11-16 05:44:09 -08:00
1 parent 56c04b2f41
commit 439b3b7280
7 files changed
+217 -22

No files matched your search

@@ -674,8 +674,9 @@ impl State {
/// part (which goes, the encoding again leaving its own over the new pages,
/// `shadow_splice.rs`), or a staged scatter's steps (which go, the encoding again staging it
/// again, `host_ram/copy.rs`), or a shadow's gated copy in (which goes, the encoding again
/// copying in for itself, `shadow::GatedCopyIn`), or its group was submitted, or the command
/// buffer completed.
/// copying in for itself, `shadow::GatedCopyIn`), or a sparse texture's scrub (which goes, the
/// encoding again leaving its own, `sparse/emulated.rs`), or its group was submitted, or the
/// command buffer completed.
pub(super) fn splice_replay(
&mut self,
at: usize,
@@ -716,8 +717,8 @@ impl State {
recorded.summary = summary;
// Its first segments go: the encoding again left a segment of its own in each
// pending dispatch's, each splice's or merge on the host's, each staged copy step's it
// staged again and each gated copy in's place, and its work on the GPU alone in
// segments of its own, and recorded each other staged gather's copy at once.
// staged again, each gated copy in's and each scrub's place, and its work on the GPU
// alone in segments of its own, and recorded each other staged gather's copy at once.
// What the commit recorded of one stays retained, never submitted, as the first
// recording does.
for segment in recorded.segments.drain(..) {