Files
metal2vulkan/docs
Anees Iqbal bc45258bdf replay: a tiled texture of more than one level plays on the new runtime as the old runtime plays the call
The new runtime takes no form of the SPI newTiledTextureWithDescriptor:offset:bytesPerRow:, and the
player made an ordinary texture in its place whose texels were not the program's: on lavapipe the
two runtimes' plays of one stream first parted at the frame whose draws first read such a
texture. Those texels now come from the buffer, as the old runtime gives them.

What the old runtime does, read from its code:
- crates/metal2vulkan-runtime/src/buffer_texture.rs:534-591 (Buffer::new_tiled_texture) and
  shadow.rs:228-250 (the module's "Copies taken at use"): a texture of more than one level is one
  image of its own. The first command of an encoder that uses any of its levels after the making
  (or after did_modify_data, or a replace_region of the first level) takes the copy, before that
  command and inside its command buffer. The take copies every texel of the first level from the
  buffer at the offset, rows bytesPerRow apart, then makes each later level from the first as
  generate_mipmaps makes it. It reads no level past the first from the buffer.
- shadow.rs:386 (LevelsCopy) and :404 (LaterLevels): the later levels come from generate_mipmaps'
  plan for the format (the device's blit chain, the compute filter, or the integer picks). For a
  format that generate_mipmaps leaves as it is or refuses, they are kept.
- buffer_texture.rs:537-538: a texture of one level is the texture over the buffer that
  new_texture makes.

The stand-in, through the runtime's public API only:
- An ordinary texture of the descriptor.
- At the first use since its making, the take is owed to that use's command buffer. A use is an
  encoder's command or a render pass's attachment naming the texture or a view of it, skipped
  encoders included.
- The take runs as one blit encoder (copy_from_buffer into level 0, then generate_mipmaps) in a
  command buffer of the play's own. It is committed on that command buffer's queue, after its
  copies from the guest's RAM and just before it, so it reads the bytes as they are when that
  command buffer runs. A format the runtime refuses mipmaps of (MipmapFormat, MipmapFilter)
  keeps its later levels.
- Counted apart from the stream's work: tiled_textures, tiled_takes, tiled_take_bytes,
  tiled_mipmap_generations, tiled_levels_kept, and tiled_gpu_nanos (its GPU time, in no frame's
  gpu_busy, as the guest RAM's copies are). The report has a "tiled textures over a buffer" line.
- A tiled texture of one level plays as the public texture over the buffer.
- A replaceRegion of a tiled texture's first level is refused. On the old runtime it writes the
  bytes and owes another take; no stream played here has one.

Where it differs from the old runtime: the take runs ahead of the whole command buffer, not just
ahead of the using encoder, so what an earlier encoder of that command buffer writes into the
bytes or the texture lands after it.

The tiled kind leaves the substitutes: substituted_tiled_textures is gone. The "substitutes read"
line now counts gap substitutes alone.

Tested by:
- rt_replay::a_tiled_texture_takes_its_buffer_s_bytes_and_levels_at_first_use (lavapipe, both
  runtimes): a 128x2 two-level tiled texture whose 2x2 squares hold one colour each. Blits of both
  levels read the buffer's texels and the squares' colours, with equal digests on both runtimes
  and one take counted.
- The unit test of the substitute lines, now gaps alone.
2026-11-19 16:55:04 -08:00
..