diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index b68c0a5bf..531746e50 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -60,7 +60,7 @@ mod tests; /// unchanged version, and its bless records the version. Independent of the crate's version and of /// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no /// history. -pub const SEMANTICS_VERSION: u32 = 2018; +pub const SEMANTICS_VERSION: u32 = 2019; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another diff --git a/crates/metal2vulkan/src/lower/texture/mod.rs b/crates/metal2vulkan/src/lower/texture/mod.rs index 82974e939..e5836311c 100644 --- a/crates/metal2vulkan/src/lower/texture/mod.rs +++ b/crates/metal2vulkan/src/lower/texture/mod.rs @@ -1630,7 +1630,10 @@ pub enum OneTexel { /// none of the families (the slot's `UnmeasuredTexels` specialization), a 16-bit normalized grid /// (`BicubicTexels::WIDE16`: three steps of each round twice), and a sample of a 32-bit float /// texel (`BicubicTexels::LINEAR`: Metal rounds toward zero, saturating), tests of the bound -/// format the runtime announces at a draw or dispatch binding such a texture. A heap color +/// format the runtime announces at a draw or dispatch binding such a texture. Not a sample's of a +/// 32-bit float texel on a profile that takes `DriverDeviation::MetalHalfConversion` (the module +/// then requires its property): there the device's `half` of every `float` word a read, sample or +/// gather hands back is measured to be Metal's (`device::driver_facts`). A heap color /// texture's and a depth texture's access records it outright. pub(crate) fn half_texels( cx: &mut SelectCx<'_>, @@ -1657,8 +1660,22 @@ pub(crate) fn half_texels( [NoteTest::equal(NoteOn::Unmeasured(index), 1, 1)].into(), [NoteTest::differ(NoteOn::Bound(index), B::WIDE16, 0)].into(), ]; + // A sample of a 32-bit float texel, but on a profile that takes + // `DriverDeviation::MetalHalfConversion`, whose `half` of every `float` word a read, sample or + // gather hands back is measured to be Metal's (the module then requires its property). if sample { - when.push([NoteTest::differ(NoteOn::Bound(index), B::LINEAR, 0)].into()); + match cx + .profile + .takes_driver_deviation(DriverDeviation::MetalHalfConversion) + { + true => { + cx.families + .texture + .storage_properties + .insert(crate::device::requirements::VkProperty::MetalHalfConversion); + } + false => when.push([NoteTest::differ(NoteOn::Bound(index), B::LINEAR, 0)].into()), + } } cx.note_when(PrecisionNote::HalfTexelConversion, when, m)?; let slot = slot_of(cx, index)?.slot; diff --git a/crates/metal2vulkan/src/pipeline/artifact.rs b/crates/metal2vulkan/src/pipeline/artifact.rs index 6b69e2353..1b18da0b8 100644 --- a/crates/metal2vulkan/src/pipeline/artifact.rs +++ b/crates/metal2vulkan/src/pipeline/artifact.rs @@ -1046,7 +1046,10 @@ pub enum PrecisionNote { /// result, and its nearest even `half` is Metal's `half` but for the classes the note is /// recorded under, by the slot's bound format (`SpecKey::TexelFormat`): a 32-bit float /// texel's sample, which Metal rounds toward zero (within one `half` ulp, but past `±65504` the - /// infinity of its sign where Metal saturates to `±65504`); a 16-bit normalized texel, whose + /// infinity of its sign where Metal saturates to `±65504`), but on a profile that takes + /// [`DriverDeviation::MetalHalfConversion`](crate::error::DriverDeviation::MetalHalfConversion), + /// whose `half` of every `float` word a read, sample or gather hands back is measured to be + /// Metal's (the module then requires `VkProperty::MetalHalfConversion`); a 16-bit normalized texel, whose /// `float` steps `65455 / 65535`, `65519 / 65535` and `32759 / 32767` round twice (one `half` /// ulp); and a format whose conversion is not measured (unbounded). A heap element and a depth /// texture record it wherever they are accessed. A two-plane YCbCr texture on the grid `8192` diff --git a/docs/API.md b/docs/API.md index 6598cb23e..5e3aa67dc 100644 --- a/docs/API.md +++ b/docs/API.md @@ -3733,8 +3733,9 @@ bound. rounded to nearest even on every device: within one `half` ulp of Metal's, but a 32-bit float texel's sample past `±65504`, the infinity where Metal saturates. On MoltenVK, whose `float` texel is Metal's, announced at a draw or dispatch that binds a texture of a class whose Metal - `half` differs from it (a 32-bit float texel's sample, a 16-bit normalized texel, a format not - measured) and a two-plane YCbCr texture on the grid `8192` at a slot sampled through a runtime + `half` differs from it (a 32-bit float texel's sample, but where the profile takes + `DriverDeviation::MetalHalfConversion`, measured on the Apple M3 Max to answer Metal's `half` of + every `float` word; a 16-bit normalized texel; a format not measured) and a two-plane YCbCr texture on the grid `8192` at a slot sampled through a runtime sampler (a sample of one texel is the device's rounding of its step: toward zero on MoltenVK 1.4.2 over the Apple M3 Max, within one `half` ulp of Metal's ties-away rounding, measured over 8,409 channels; unmeasured on other Apple GPUs); a heap element or a depth texture wherever it