rt docs: placing at an index pending work may use is the consumer's duty, not the program's

The sentence said no work in flight may read a displaced object through the index, "the program's
duty, as it is Metal's". It was wrong on both counts:
- A placement at an index a released object still holds for an unretired command buffer writes
  set-1 elements with one vkUpdateDescriptorSets (arrays.rs place_texture, place_samplers_locked).
  Under UPDATE_UNUSED_WHILE_PENDING with PARTIALLY_BOUND, the spec allows that only where no shader
  invocation dynamically uses the element (vkspec 1.4.366, the binding flags' text), so Vulkan
  does not define it.
- Metal hands a released ID out again at once on a Radeon Pro 5300M (oracle job m3-max-63074), so
  a program may be given an ID that work in flight still reads. Keeping the write away from pending
  work is the consumer's duty: it keeps a released ID back until every command buffer committed
  before the release has retired.

The placement is not refused (form (ii), not built). Between the last holder's retirement and the
block-maker's deferred vacate the index is still the released object's, and a placement then is
defined; a refusal would meet a guest there. The displaced form stays for that window, and the docs
say so.

Docs only: the runtime README's index paragraph and sampler line, docs/RESOURCE-ID.md, the replay
player's rationale in docs/REPLAY-STREAM.md, and the safety contracts of place_texture,
place_samplers and hold_samplers and new_texture's doc. Verified: cargo fmt, the API signatures
check; Rustdoc runs in the quick check after the land.
This commit is contained in:
Anees Iqbal committed 2026-11-21 04:34:13 -08:00
1 parent 6800559b22
commit a449642cc7
5 files changed
+34 -17

No files matched your search

+13 -5
View File
@@ -1129,10 +1129,18 @@ made, with no lock, and never rewritten for layouts.
takes the ID: the new object writes its elements (a texture with no storage view writes its
storage element null where it took the index from another, so nothing stale answers there),
and the earlier object's going, at its release or once its command buffers retire, touches
neither the index nor its elements. No work in flight may read a displaced object through the
index: the program's duty, as it is Metal's, which the runtime does not check. A released one
it may: a texture's index, elements, views and image, a texture view's views, and a sampler
state's index and device samplers go once every command buffer committed before the release
neither the index nor its elements. Taking an index that a released object still holds for a
command buffer not yet retired writes elements that work in flight may use, a write Vulkan does
not define (an element of these bindings may change while a command buffer that uses the set is
pending only where no shader invocation uses it). Not asking for one is the consumer's duty, not
the program's: Metal hands a released ID out again at once (seen on a Radeon Pro 5300M), so a
program can be given the ID of an object that work in flight still reads. A consumer keeps a
released ID back from the program until every command buffer committed before the release has
retired. The runtime does not check it, and does not refuse the placement: from that retirement
until the vacate below, the index is still the released object's and a placement is defined;
the displaced form is for that window. Work in flight may read a released object that still
holds its index: a texture's index, elements, views and image, a texture view's views, and a
sampler state's index and device samplers go once every command buffer committed before the release
has retired, at once where none is in flight, so that work reads them as they were
(`Gauges::releases_waiting` counts what waits). Metal leaves that read undefined: a program that
released textures a frame in flight still sampled finished every run with no command buffer
@@ -1144,7 +1152,7 @@ made, with no lock, and never rewritten for layouts.
work in flight: equal create infos share the device's `VkSampler`s, the arrays keep the samplers last written at each index, and
an element that holds its sampler already is not written, so the placement changes no
descriptor that pending work reads (`Metrics::sampler_element_writes` counts the elements
written). A different sampler state stays the program's duty.
written). A different sampler state stays the consumer's duty.
Making one at an index not granted is `Refusal::IndicesNotGranted`. Where nothing took it, the
index is free again once its owner's last handle is gone, and with it the last command buffer
that used it: at once where nothing was in flight then, and otherwise once every command buffer
+7 -5
View File
@@ -335,8 +335,8 @@ impl Arrays {
///
/// Each view is live and of the device, of an image in that layout whenever work uses it,
/// `looped` only where the set was made with the second elements and the image has the
/// feedback usage, and no work in flight reads a displaced texture through the index (the
/// program's duty, as it is Metal's).
/// feedback usage, and where it displaces, no work in flight uses the index's elements (the
/// consumer's duty: Vulkan does not define that write).
pub(crate) unsafe fn place_texture(
&self,
device: &ash::Device,
@@ -512,8 +512,9 @@ impl Arrays {
///
/// # Safety
///
/// Each sampler is live and of the device whenever work uses it, and no work in flight reads
/// a displaced object through the index.
/// Each sampler is live and of the device whenever work uses it, and where it displaces, no
/// work in flight uses an element it writes (the consumer's duty: Vulkan does not define that
/// write).
pub(crate) unsafe fn place_samplers(
&self,
device: &ash::Device,
@@ -538,7 +539,8 @@ impl Arrays {
/// # Safety
///
/// No pending work uses an element of `added`, each sampler is live and of the device
/// whenever work uses it, and no work in flight reads a displaced object through the index.
/// whenever work uses it, and where it displaces, no work in flight uses an element it
/// writes (the consumer's duty: Vulkan does not define that write).
pub(crate) unsafe fn hold_samplers(
&self,
device: &ash::Device,
+6 -3
View File
@@ -923,9 +923,12 @@ impl Device {
/// buffer not yet retired still holds, is taken at once, as Metal's later texture at a
/// resource ID takes the ID: the new texture owns the index and its elements from then, and
/// the earlier one's going, at its release or once its command buffers retire, touches
/// neither. No work in flight may read a displaced texture through the index (the program's
/// duty, as it is Metal's; nothing checks it). A released one it may: its index, elements,
/// views and image go once every command buffer committed before the release retired
/// neither. Work in flight must not use the index's elements then: Vulkan does not define
/// that write. Keeping it away is the consumer's duty, not the program's, as Metal hands a
/// released ID out again at once (seen on a Radeon Pro 5300M): a consumer keeps a released ID
/// back from the program until every command buffer committed before the release has retired.
/// Nothing checks it. Work in flight may read a released texture that still holds its index:
/// its index, elements, views and image go once every command buffer committed before the release retired
/// ([`Gauges::releases_waiting`](crate::Gauges::releases_waiting)), the index then on the
/// block-maker thread's next pass, so that work reads it as it was. Metal leaves that read
/// undefined: a program that released textures a frame in flight still sampled finished every
+2 -2
View File
@@ -227,8 +227,8 @@ and the (name id, value) answer pairs.
it, as Metal's later texture at an ID takes the ID: the earlier object's release leaves the
index. A placement at an index waits first for the commits of the command buffers that named
an object while it held the index, live or released since, to retire (their completed handlers have run, which the runtime runs once it
has let go of what they held): Metal leaves it to the program never to take an element from
under work that runs, and the program's own timing kept that. An object named after a later
has let go of what they held): the runtime leaves it to its consumer never to write an
element that work in flight may use. An object named after a later
one took its index holds it no more: the index is the later one's, and that naming owes it
nothing. Where the runtime refuses a named index (it lies outside the object's class), the object
takes the lowest free one, and the report counts it. A constexpr sampler, which the stream names
+6 -2
View File
@@ -38,8 +38,12 @@ the program released that work in flight still holds, writes its elements and ow
once; where the earlier texture had a storage element and the later has none, the later one
writes that element null, so nothing stale answers there. The earlier object's release, and its
teardown once its work retires, touch neither the index nor its elements; the owner's empties
them. The rule rests on the duty Metal puts on a program: no work in flight reads a displaced or
released object through that ID. The runtime does not check it.
them. Vulkan does not define that write where work in flight uses the element. Keeping it away is
the consumer's duty, not the program's: Metal hands a released ID out again at once (seen on a
Radeon Pro 5300M), so a consumer keeps a released ID back from the program until every command
buffer committed before the release has retired. The runtime does not check it, and does not refuse
the placement: between that retirement and the index's vacate the placement is defined, and the
displaced form is for that window.
## The arrays