RUNTIME 2309: a texture whose rows are in place makes its shadow at the first reach of its image

A device-gap texture over a buffer (its image refused for a reason that leaves its rows in
place: format, pitch, placement, source, dma-buf) was a shadow made at new_texture: its
VkImage, memory and views, its notice and shadow-log line, and its slot in the texture table
and every heap set. A slot whose function only reads, writes or asks its size binds the rows
in place, so a texture only ever bound that way paid for a shadow no command used (reims's
gbs91 on the 780M: hundreds of such textures, 8 to 52 MB each).

Now such a texture (rows in place, no pending in-place verdict, not over a heap's buffer) is
made with its shadow left unmade (texture/lazy_shadow.rs): the storage accessor makes it at
the first reach, once, under a lock, with the making's notice, log line and counts, then
places its slot (its resource ID reads the neutral until then). Paths that must not make it
read the recipe instead (rows binding, placement and heap-set writes, CPU copies, blits on
the bytes, shape and plan questions, logging). The reaches that make it: a slot that binds
the image (before the command's copies are planned from its uses), use_resource, a pass's
attachment, an execution of commands inheriting the bindings, a view, its VkImage handed out.
An out-of-memory making fails the reaching call, as new_texture did.

WorkCounts::shadows_left_unmade and shadows_made_at_use count both halves; docs/API.md says
when the shadowed-texture notice is given.

Not in scope: two kinds still make their shadow at new_texture. A texture waiting on its pages'
in-place verdict may move in place. A texture over a heap's buffer is made resident by use_heap
through a path that checks the shadow.

RUNTIME_VERSION moves because the run's announcements change. The shadowed-texture notice and the
shadow-log line come at the making, and a texture only ever bound through its rows gives neither.
A resource-ID read of an unmade texture gets the neutral. No new Degradation kind. No FAST-PATHS
row: the copy work follows uses, not the shadow's existence (an unbound shadow was copied 0 times
per commit before and after), so no accuracy is traded. The saving is the making: the VkImage, its
memory, views and heap-set slots.

Test: tests::texel_rows_device::a_shadow_is_made_at_the_first_reach_of_its_image, on a copied
buffer, since over the pages lavapipe lays the rows in place. Three cases:
- a written-only texture: shadows_left_unmade +1, none made, shadowed_textures 0,
  shadow_copies 0, texels inverted in the pages;
- a rows write then a sample in one command buffer: made at the sample, copies > 0, pixels equal
  to a device-own texture's;
- use_resource: made at the call.
joined_residency's helper asserts shadows_bytes() where it asserted the shadow at new_texture.

Verified, msi m3-max-30024 at 088a73d3b7:
- clippy -D warnings, runtime crate, all targets and features: plain and --cfg m2v_cpu_icd exit 0;
- lavapipe 206/206: texel_rows, shadow*, read_twin*, joined_residency, padding/kept_padding,
  exported_*, first_host_texture, surface_shapes, attached_read*, copied_device, fresh_pages,
  texture::*;
- translator api_signatures, api_surface and fast_paths: 47/47;
- the negative control in the same job (lazy = false): the test fails at "Copy: left unmade",
  (0,0,1) against (1,0,0).
This commit is contained in:
Anees Iqbal committed 2026-11-14 12:15:15 -08:00
1 parent 9972bec765
commit e453efbf0a
31 files changed
+1004 -330

No files matched your search

+9
View File
@@ -481,6 +481,13 @@ binds its rows as a texel buffer of the buffer's bytes (the pages, or the buffer
at a slot whose function only reads, writes or asks its size (section 5,
`TextureFacts::texel_rows`), and those commands copy nothing into or out of the shadow
(`WorkCounts::texel_rows_textures`, `texel_rows_bound`); a slot that samples it reads the shadow.
Such a texture's shadow (not one made before its pages' verdicts, nor one over a heap's buffer) is
made at the first reach of its image, not with the texture: a slot that binds the image, a
`use_resource` of it, a render pass's attachment, an execution of commands that inherits its
binding, a view, its `VkImage` handed out (`WorkCounts::shadows_left_unmade`,
`shadows_made_at_use`). One only ever bound through its rows, or read and written by the CPU and
blits, which reach its bytes, makes none, and its resource ID reads the neutral texture until its
shadow is made, as a texture that no command named holds nothing a read through its ID could see.
Over a buffer with a read twin, a slot that only reads the texture binds the texture's read twin
where it has one in place, and the shadow otherwise.
A texture in place renders and
@@ -2338,6 +2345,8 @@ bound.
format, rebuilding each byte from its normalized value (Vulkan defines that value as the byte over
255), with no copy of them (`WorkCounts::shadow_merges_fetched`); every other format, the sRGB and
16-bit float ones among them, copies them.
A texture whose rows are in place (section 1) gives this notice as its shadow is made, at the
first reach of its image, and one only ever bound through its rows gives none.
- `metal2vulkan-degrade-staged-texture-buffer` (performance). `StagedTextureBuffer`: A texture
buffer is viewed through a staging buffer: its texels start where the device views none
(`minTexelBufferOffsetAlignment`), or run past its buffer's length, where its staging buffer is