Files
metal2vulkan/docs
Anees Iqbal 880b03cb2b Blend into a padded attachment over unclamped operands; padded tiles announced
Measured on the M3 Max under macOS 27.0.1 (probes/padded_and_bfloat_blends.m,
targets without Metal's optimized layout, whose blits moved every texel):
- Metal clamps nothing before a blend into a padded attachment (R10Unorm_X6,
  RG10Unorm_X12, their sRGB twins, RGB10A2Unorm_sRGB): sources, second
  sources and blend colors past both ends of [0, 1], alpha among them, blend
  as they are. With the operands unclamped, the stored codes of 18 blend states
  under fast and safe math, half and float outputs, match the f32 model within
  one code for the linear forms (16-bit safe-math half outputs exactly in half
  arithmetic), apart from NaN and infinity results; clamped to [0, 1], up to
  1023 codes off in 30-50% of channels.
- A padded attachment's tile holds half through the pass: a premultiplied blend
  of (0, 0, 0, 0.5) over a clear of 0.33371 stored code 171 (the half's), not
  170 (code 341's), and over an unblended draw of values in [-0.5, 1.5] it
  matched the unclamped half in every channel (65,536 texels of R10Unorm_X6,
  131,072 channels of RG10Unorm_X12).

So blend::extended_ranges is None for a padded form (native() clamps nothing),
source_range drops its padded arm, and the model test clamps no padded lane:
every_blend_is_the_devices_arithmetic's random sources past the range fail it
with the clamp. The runtime's extended-range-blends-stored-codes now covers
padded colors (render.rs extended_colors), and ExtendedRange::clear_read_back
answers a padded form's clear by its codes' values (c / 1023, the sRGB twins'
transfer, RG10Unorm_X12_sRGB linear), so a blend over a clear between two codes
is announced as for the extended-range forms. Docs: the blend-source notes, the
stored-codes kind and its catalogue entry, ExtendedRangeColor.

(cherry picked from commit 5750641750642bdb7800da8e9618f98919d2cc9f)
2026-11-10 01:35:19 -08:00
..