Files
metal2vulkan/docs
Anees Iqbal ee3f269fa3 Heap depth textures: the copy in clamps a 32-bit float depth into [0, 1] where the device takes no other
A heap's 32-bit float depth texture whose shadow copies the heap's bytes
into its image went through vkCmdCopyBufferToImage with whatever float the
bytes held. On a device without VK_EXT_depth_range_unrestricted that is
invalid usage for a value outside [0, 1]
(VUID-vkCmdCopyBufferToImage-pRegions-07931); ANV stored it clamped, and
the runtime only announced it (restricted-depth-upload).

The tiled texel kernel (metal2vulkan::bind) now clamps a level's elements
on the way into the tight buffer where the level says so:
- TiledLevelMove::clamps_depth, set with TiledLevelMove::clamping_depth;
- the shape's level record grows to 14 words;
- the clamp compares the word's bits, so no denormal is flushed: a
  negative value becomes 0.0, one above 1.0 (and +inf) becomes 1.0, a NaN
  of either sign becomes 1.0 (as nan_clear.rs clears a NaN depth), and
  -0.0 and every value inside [0, 1] keep their bits;
- the move back is unchanged.
HeapTiledCopies::new takes the image's format and marks the 4-byte depth
planes' levels of a D32_SFLOAT or D32_SFLOAT_S8_UINT image where
ImageFacts::depth_clamps holds: exactly where restricted-depth-upload is
announced. MoltenVK, whose driver is measured to keep such values
(DriverFact::DepthImageKeepsValuesOutsideUnitRange), keeps its copies as
they were. The clamp is the device's own answer, so the notice stays and
its text now says the copy in clamps.

Tests:
- bind::tiled_texels::tests::clamped_depths_move_into_the_image_inside_0_1,
  run through the CPU interpreter;
- lane heap_textures::a_heap_depth_texture_s_copy_in_takes_no_depth_outside_0_1,
  which turns on the layer's GPU-assisted buffer-copy check
  (gpuav_buffer_copies), asserts no VUID-07931 message, and checks a blit
  reads the clamped values where the device clamps, else the bytes as
  they are.

Docs:
- the restricted-depth-upload declaration, docs/API.md's catalogue and its
  docs/FAST-PATHS.md device-gap row say the copy in clamps;
- docs/FAST-PATHS.md's known gaps gain one entry: a heap texture Metal
  keeps uncompressed lies in its driver's layout where its image fits
  Metal's answer (heap-texture-untiled-layout);
- api_signatures.tsv is blessed for the two new public items.

Verification in the tip report.

(cherry picked from commit de683c02ce08d337e8281dd752c2519f863bbe39)
2026-11-08 15:41:19 -08:00
..