Files
metal2vulkan/docs
Anees Iqbal 437e37cb59 Keep the driver's compression for textures Metal compresses, the uncompressed heap image behind HeapCompressionPolicy
On a compressing driver (ANV's CCS on the Iris Xe), textures the runtime made uncompressed for
reasons that no longer hold now keep the driver's compression.

What changes:
- A device's own texture without allowGPUOptimizedContents makes its image from the descriptor's
  usage alone (TextureDescriptor::own_image_usage), not with PixelFormatView usage, so the driver
  keeps it compressed. Its layout is never visible (no size answer, no aliasing; views, blits and
  fresh contents follow the descriptor), so this is exact. Heap, sparse and shared textures keep the
  PixelFormatView image. On MoltenVK, whose blits of a compressed RG11B10Float or RGB9E5Float
  texture rewrite texels (RuntimeDriverDefect::CompressedImageCopiesRewriteTexels), such a texture
  keeps the uncompressed image, deciding from the image the device's Metal would compress.
- A heap's colour texture that Metal itself compresses (by heap_tiled::metal_compresses_layout)
  takes the driver's optimal, compressed image by default, announced once as the new degradation
  kind heap-texture-compressed (Precision). New DevicePolicy::heap_compression,
  HeapCompressionPolicy { Compressed (default), Uncompressed }; exact_answers() selects
  Uncompressed, the host-transfer or linear image that keeps aliased writes visible byte for byte.
  It is the runtime's choice alone and keys no profile. Textures Metal keeps uncompressed keep
  that form under both values.
- optimized-depth-stencil-texture is announced only for heap textures and heap size answers, the
  only places the difference shows; a device's own or shared depth texture no longer announces it.
- Docs: a FAST-PATHS row with both forms' costs, the API.md catalogue entries, and the docs of
  allow_gpu_optimized_contents, the degradation and DriverFact::DepthStencilImagesStayGpuOptimized.

Why: the uncompressed form costs a 2048x2048 RGBA8Unorm render target's clear 676 us against 27 us
compressed on the Iris Xe. And Metal does not show aliased writes over a texture it compresses
either: on an M3 Max under macOS 27.0.1, a buffer fill over a compressed texture's bytes made every
covered texel of drawn content read opaque magenta, never the written value; only clear-only
content and uncompressed (ShaderWrite) textures showed the write. So the uncompressed heap image
matched Metal only for clear-only content.

Verified:
- runtime_lane::heap_textures::heap_compression_costs (new, ignored) on the Iris Xe, release, ABAB:
  compressed clear 26.9 us and copy 647.7-649.1 us; uncompressed clear 676.2-676.5 us and copy
  673.9-693.2 us.
- On ANV: the new heap test (compressed textures kept 4096 to 9696 texels unchanged under an
  aliasing write, uncompressed ones 0; notice counts exact), the heap_textures, heap_layouts,
  heap_metal_sizes, compressed_blits, fresh_contents and mipmaps_exact lanes, 53 passed, 0 failed.
- runtime_lane::compressed_blits on the M3 Max caught the MoltenVK blit defect (an RG11B10Float
  byte read back as 224 where Metal keeps 250), which the uncompressed image fixes.
- The translator's fast_paths and driver_facts tests (17) and api_surface (11) on gem10; the
  runtime's image_plan and texture_descriptor tests; clippy -D warnings (m2v_gpu).
2026-10-19 00:15:59 +03:00
..