diff --git a/crates/metal2vulkan/src/pipeline/artifact.rs b/crates/metal2vulkan/src/pipeline/artifact.rs index 836b0a6b5..5812b5da5 100644 --- a/crates/metal2vulkan/src/pipeline/artifact.rs +++ b/crates/metal2vulkan/src/pipeline/artifact.rs @@ -1633,13 +1633,17 @@ pub enum PrecisionNote { /// device's `OpQuantizeToF16` alone, on every device without `shaderFloat16`. An integer's /// `half` is not this rounding: it rounds by integer arithmetic, exactly, around NVIDIA's /// 615.71.09 keeping an integer conversion unrounded under the quantize. Vulkan leaves the - /// quantize's rounding mode to the device, and the SPIR-V specification lets it answer a zero - /// for a magnitude too small for a normal `half`. The recorded bound, against Metal's `half(float)`: a finite result within one unit in the last + /// quantize's rounding mode to the device, and the SPIR-V specification lets it answer either + /// zero for a magnitude too small for a normal `half`, a zero's own included. The recorded bound, against Metal's `half(float)`: a finite result within one unit in the last /// place of the `half`; a value from 65504 up to 65520 may be infinity where Metal's is 65504 /// (NVIDIA's 615.71.09 rounds `0x477FEFFF` to infinity); a value below the smallest normal /// `half` (`2^-14`) may round to a zero, of either sign, where Metal answers the half denormal, /// or `2^-14` from just below it (the quantize tests the value it rounds; NIR's - /// `fquantize2f16` flushes every one, SwiftShader's too); a NaN's encoding is the device's. + /// `fquantize2f16` flushes every one, SwiftShader's too); where the rounding's input is a + /// zero or too small for a normal `half`, the result may be either zero, so a negative zero + /// may come out positive (RADV's on Polaris does), which a program sees in a reciprocal's or + /// `atan2`'s sign and in the bits written to a `half` target or buffer; a NaN's encoding is + /// the device's. /// Validation derives no tolerance from it. NativeHalfQuantize, /// Native device maths: a `float` or `half` operation's NaN result is the device's, its sign diff --git a/docs/API.md b/docs/API.md index 5fec8337b..42e5da2ac 100644 --- a/docs/API.md +++ b/docs/API.md @@ -2434,7 +2434,13 @@ bound. `half` operation's, a function's, a conversion from `float`'s, a texel's) by the device's `OpQuantizeToF16` alone, on every device without `shaderFloat16`, its quantize measured or not: a value below the smallest normal `half` may round to a zero where Metal answers the half denormal - (or `2^-14`, from just below it). An integer's `half` rounds exactly instead. + (or `2^-14`, from just below it). Where the rounding's input is a zero or too small for a normal + `half`, the result may be either zero, so a negative zero may come out positive, as the SPIR-V + specification lets the quantize answer: a program sees it in a reciprocal's or `atan2`'s sign + and in the bits written to a `half` target or buffer. The form not taken, copying the input's + sign bit into the result by integer operations, would keep Metal's sign at about 4 instructions + per `half` rounding on every device without `shaderFloat16`. An integer's `half` rounds exactly + instead. - `metal2vulkan-degrade-native-nan-encoding` (precision). `PrecisionNote::NativeNanEncoding`: Native device maths: a `float` or `half` operation's NaN result is the device's, its sign and payload unselected, where Metal answers a NaN, on every device: a `float`