diff --git a/crates/metal2vulkan/src/lower/sampler/level.rs b/crates/metal2vulkan/src/lower/sampler/level.rs index e81ac955c..8779a7739 100644 --- a/crates/metal2vulkan/src/lower/sampler/level.rs +++ b/crates/metal2vulkan/src/lower/sampler/level.rs @@ -11,8 +11,11 @@ //! - a nearest mip filter reads level `L + 1` where `q > 1/2`, else level `L`; //! - a linear mip filter blends levels `L` and `L + 1` with weights `1 - q` and `q`; //! - a sampler without a mip filter reads level 0; -//! - every sampler magnifies (its magnification filter) where `L + q` is 0, and minifies -//! elsewhere. +//! - every sampler minifies (its minification filter) where `L + q` of the level before the clamp +//! into the texture's levels (rounded and clamped into the sampler's clamp) is above 0, and +//! magnifies (its magnification filter) elsewhere. On a texture of more than one level that is +//! where the clamped `L + q` is not 0; a texture of one level, whose levels clamp every level to +//! 0, minifies at every level above 0 though it reads level 0. //! //! Every lane of the probes reads so: 2,230 levels each (every sixty-fourth from -1 to 5, the //! neighbourhoods of `L + 1/2` in steps of `1/4096`, every `1/1024` from 1 to 2, the `half` ties @@ -24,8 +27,19 @@ //! alike; through samplers clamping the level into `[0.75, 2.5]` and `[0.3, 2.7]`; and where a //! sampler minifies and magnifies with different filters (a 16x16 texture of distinct texels). //! Metal's compiler builds no kernel that samples with `min_lod_clamp` (its device compiler -//! stops), so a clamp beside a bias is not measured; nor is a texture of one level, where the -//! clamp into its levels would decide the filter of a sampler whose filters differ. +//! stops), so a clamp beside a bias is not measured. +//! +//! **A texture of one level** (an Apple M3 Max on macOS 27.0.1): a 16 x 4 `rgba8Unorm` texture of +//! one level sampled through runtime samplers without a mip filter whose filters differ +//! (minifying nearest and magnifying linearly, and the reverse), clamping the level into `[0, +//! FLT_MAX]`, a quarter of a texel past each texel's centre toward its right neighbour (60 +//! positions), at `level(x)` and at a kernel's `bias(x)` for `x` of -2, -0.5, 0, 1/64, 1/4, 1/2, 1, +//! 2 and 5: every sample at -2, -0.5 and 0 is the magnification filter's, and every sample at 1/64 +//! and above the minification filter's. So the choice is made before the clamp into the texture's +//! levels, which would have magnified at every level. A level between 0 and 1/64 (`q` of 0) on a +//! texture of one level is not measured. No sample this module's levels serve takes the choice: an +//! extended-range sample's constexpr sampler has one filter for both (`select`), and a runtime +//! sampler's word whose filters differ reads nearest (`extended`'s open gap). //! //! **A depth comparison** reads its level by the same rule through a runtime, an argument //! buffer's, and a constexpr sampler alike (2,048,400 comparisons at 1,707 levels through nearest @@ -39,8 +53,10 @@ //! sampler's `[minLod, maxLod]` (the same level clamp), at its own precision: a nearest mip filter //! reads `ceil(λ + 1/2) - 1` (rounding `L + 1/2` either way is the implementation's), a linear one //! blends `floor(λ)` and the next level by `λ`'s fraction to `mipmapPrecisionBits` (at least 6 on -//! the measured venues), and `λ <= 0` magnifies. A sample the device makes takes the device's -//! level (`PrecisionNote::DeviceSampling` on a device whose sampler is not Metal's). +//! the measured venues), and `λ <= 0` magnifies, `λ` before its clamp into the view's levels, as +//! Metal's level before the clamp into the texture's levels chooses. A sample the device makes +//! takes the device's level (`PrecisionNote::DeviceSampling` on a device whose sampler is not +//! Metal's). //! //! **A runtime or argument buffer's sampler** holds its clamp as `f32`s, not `half`s (Apple M4 on //! macOS 27.0.1: all 37,080 lanes of `level(x)` and a kernel's `bias(x)` through eighteen clamps,