What: Device::texture takes the fence that Buffer::new_texture_fenced and
Buffer::new_texture_in_place_fenced pass. On a restored make alone (in place over host memory's
import, Keep::Restore), after the refusals ahead of the restore, the make runs on its own thread:
it waits for the progress already submitted (Work::progress), calls the fence's before, adds the
image's move home to the upload (Work::home), flushes, waits for that value, and calls after.
before comes ahead of home and not just ahead of flush because a commit from another thread can
carry the upload out as soon as the move is in it (take_uploads). after is called from a drop
guard (Fenced), so it runs on every exit once before returned Ok: the make done, Quiesced from
home, a lost device in the wait, or a panic unwinding. A before that answers Err(reason) refuses
the make with Refusal::RestoreFenceRefused { reason }. Then nothing is recorded, saved, moved or
written back, the texture made so far is dropped, nothing counts, and after is not called: before
undoes its own work, and after always pairs with a before that returned Ok. Every other make, and
every make with no fence, takes the match's other arm, so an unused seam costs one branch. The
make itself is unchanged.
Public shape: a trait object (&mut dyn RestoreFence, before -> Result<(), &'static str> and after)
on two new twins, not an Option argument on new_texture and new_texture_in_place. This tree has
about 90 four-argument calls of those two, and the consumer's development has 6, of which 2 need
the fence; the twins leave every other call unchanged. A &mut trait object lets before keep a guard
or a token in the fence for after to release. The reason is &'static str so that the refusal stays
Copy, as Refusal is.
Docs: the runtime README (Imported blocks, "The caller's fence"; the known gap of memory blocks;
the API list) states the contract. Between before and after the runtime saves, moves and writes
back the block's bytes, so a host write to them in that span is lost; the span holds the whole
submission that carries the upload, a group's included. A caller with such a writer fences it
there; one without passes nothing. Vulkan documents no form that keeps the bytes without the
write-back (sections 12.10.1 and 7.7.6: an acquire keeps bytes only after the other owner's
release; section 11.2.6: host-pointer memory is shared with the host under host access
synchronization). The rustdoc of the trait, the twins, the refusal and Buffer::new_texture says
Metal has no such span. Refusal::InScheduledHandler's doc names the twins. docs/REFUSALS.md is
regenerated (RestoreFenceRefused, one site). Not touched: RUNTIME_VERSION and runtime-sources.sha256,
whose inputs are the translator's listed files (metal2vulkan/src, metal2vulkan-air/src); this change
edits none of them.
Verified, red: at 4e941d8015 (the fence passed nowhere) the new test failed on lavapipe (llvmpipe,
LLVM 23.1.1, Mesa 26.2.4), job m3-max-82710. With no fence, 632 of 86,252 stamped words were lost.
With the unwired fence, 7,507 of 98,879 were lost, 0 writes found the gate held, and before and
after ran 0 times. Green runs and the gate follow in the lane's report.