Runtime: a tiled texture's take whose encoder runs nothing is given back

A tiled texture of more than one level over a buffer takes its copy of the
bytes at the first use encoded after its making or a did_modify_data,
which clears its mark. Where that encoder runs nothing because its command
buffer failed before it ran (committed as failed, an encoder a failure
names, a protection fault, a submission that fails EncodedUseRebound or
DetachedBacking, a hang's discard or recovery, a predication record that
drops it), the copy was never taken but the mark stayed cleared, so every
later use read zeros or an older copy until the next did_modify_data.

The take is now given back where the runtime knows its recording will not
run: State::fail_part, the one point every such failure releases a part
through. The mark is an AtomicU64 whose low bit is the mark and whose
upper bits count the takes; LevelsCopy::take returns the take's number,
and give_back(number) sets the mark again only where that take is still
the latest and nothing set the mark since (a later take holds its own
copy; a did_modify_data since already asks for one), so giving back twice,
or after a later take, changes nothing. shadow::Takes now holds each take's
number and a weak hold of the texture's copies; every ended encoder's
record keeps its takes (not only one whose log is kept), and a recorded
segment carries its own core's takes, both given back by fail_part.
ShadowSync::forget gives its takes back by number too.

An encoder split into parts at a host step gives back every take of its
own where any of its parts runs nothing, so a take that ran in an earlier
part is taken again at the next use when only a later batch fails; that
gap is in docs/FAST-PATHS.md's known gaps. docs/API.md and shadow.rs state
the rule.

Tests: tests::shadow gains a unit test of the give-back's rules (latest
take, a later take, a mark set since, twice, forget). The device tests of
the previous commit fail without this change; the runs of both commits are
in the report.
This commit is contained in:
Anees Iqbal committed 2026-11-11 09:41:44 -08:00
1 parent 3327585df5
commit 9d024acefe
12 files changed
+235 -68

No files matched your search

+3 -1
View File
@@ -456,7 +456,9 @@ texel picks. The copy is taken as that command is encoded and runs in its comman
the GPU, so it reads the bytes as they are when the command buffer runs. A rebind that encodes the
encoder again before its command buffer's first submission (`Buffer::rebind_bytes_no_copy`) takes
the copy in the encoding again where the first encoding took it, and a `did_modify_data` made since
is left to the next use encoded. Between takes no write of
is left to the next use encoded. A take whose encoder runs nothing, its command buffer having failed
before it ran (committed as failed, or a submission that fails), is given back: the next use takes
the copy. Between takes no write of
the bytes reaches a level, and nothing the GPU writes into a level reaches the bytes or the other
levels. `get_bytes` and `replace_region` of the first level read and write the buffer's bytes, as
the Macs' do, and of a later level the image (an accepted difference, section 10). While the