Files
metal2vulkan/crates
Anees Iqbal 205c8d2398 Tests: a rendered depth-and-stencil view copied into level 0 of a six-level texture, then sampled
What: tests::depth_stencil_route, a device cell (--cfg m2v_gpu or m2v_cpu_icd) of the guest route
that met Gap::TextureCopy, in the shape the consumer reported: a page's GL layer gives a drawn
Depth32Float_Stencil8 texture more levels by copying its level 0 into a new texture, then samples
it.

- A 32 x 32 Depth32Float_Stencil8 texture of one level, ShaderRead | RenderTarget |
  PixelFormatView, Private, and a view of it of the same format over level 0 and slice 0. One pass
  takes the view as its depth and its stencil attachment, Clear and Store: the stencil cleared to
  0x5a, and one draw of the owned depth_fill pair writing each quadrant's depth (0.2, 0.4, 0.6,
  0.8) under an always-passing depth test that writes.
- One blit encoder copies the view's level 0 into level 0 of a new six-level texture of the same
  usage and storage, then five never-written one-level textures, 16 x 16 down to 1 x 1, into
  levels 1 to 5, and reads level 0's two planes back through the plane options.
- A view of the six-level texture over its six levels, swizzled (R, 0, 0, 1), is sampled at each
  texel centre of level 0 by the owned rrp_mirror_clamp fixture: raw through texture2d<float>
  and a nearest sampler, and through depth2d<float> and a sampler comparing LessEqual at 0.5.

Every texel is exact: each depth bit for bit and the stencil 0x5a; each raw answer (depth, 0, 0,
1); each compared answer 1 where 0.5 <= depth and 0 elsewhere. tests::layouts records six
vkCmdCopyImage into the six-level texture, the first from the parent's image (the view's image is
asserted to be its parent's), the rest from the small ones, each TRANSFER_SRC_OPTIMAL to
TRANSFER_DST_OPTIMAL with one region of DEPTH | STENCIL on both sides. The run prints the formats,
aspects and layouts it recorded.

Why: the plain cell copies between textures made as such; the route copies from a view that is
an attachment of the pass before it, into one level of a mipmapped texture, and samples the
result through a swizzled view and a comparison sampler. A copy from a view needs nothing the
form lacks: a view's copy side is its parent's image at the view's base level and slice.

Verified: job m3-max-73322 (msi, lavapipe, Khronos validation layer 1.4.363.0) exited 0 at every
step: fmt; clippy of metal2vulkan-runtime plain, --cfg m2v_gpu and --cfg m2v_cpu_icd; rustdoc -D
warnings; refusal_surface.py --check; the rt suite on lavapipe under the validation layer, 732
passed, 3 skipped, this cell among them, no validation error; the lane's tests, 29 passed. The
per-vendor runs follow on the cards.
2026-11-24 00:36:40 -08:00
..