diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 04fc0d88e..be5adbe02 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 = 2343; +pub const SEMANTICS_VERSION: u32 = 2344; /// 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/words.rs b/crates/metal2vulkan/src/lower/texture/words.rs index 2b701e17f..7581ebf36 100644 --- a/crates/metal2vulkan/src/lower/texture/words.rs +++ b/crates/metal2vulkan/src/lower/texture/words.rs @@ -1487,13 +1487,17 @@ fn small_float_bits( let normal = fb.binary(BinOp::ISub, a, rebias)?; let down = ku4(fb, m.map(|m| 23 - m))?; let normal = fb.binary(BinOp::ShiftRightLogical, normal, down)?; - // A denormal: the value times `2^(14 + m)`, an exact integer. - let af = fb.convert(ConvOp::Bitcast, a, fv)?; + // A denormal: the value times `2^(14 + m)`, an exact integer below `2^m`. A normal lane (an + // infinity and a NaN included) converts zero instead, since its product may be past `u32`, + // where `OpConvertFToU` is undefined; the select below drops the code it gives. + let smallest = ku4(fb, [113; 4])?; + let is_normal = fb.binary(BinOp::UGreaterThanEqual, e, smallest)?; + let none = ku4(fb, [0; 4])?; + let small = fb.select(is_normal, none, a)?; + let af = fb.convert(ConvOp::Bitcast, small, fv)?; let scale = kf4(fb, m.map(|m| 2f32.powi(14 + m as i32)))?; let den = fb.binary(BinOp::FMul, af, scale)?; let den = fb.convert(ConvOp::ConvertFToU, den, uv)?; - let smallest = ku4(fb, [113; 4])?; - let is_normal = fb.binary(BinOp::UGreaterThanEqual, e, smallest)?; let bits = fb.select(is_normal, normal, den)?; let fraction = ku4(fb, [0x007f_ffff; 4])?; let f = fb.binary(BinOp::BitwiseAnd, a, fraction)?;