Colour clears and fills take either code on every device but where a measured row says Metal's
The orchestrator's decision: Vulkan lets a clear of a normalized channel store either of the two
codes closest to its scaled value ("returns one of the two ... closest ... Implementations should
round to nearest"), so every device takes that rule, not only the three devices measured to take
the farther code (DriverFact::ColorClearTakesEitherCode's rows: NVIDIA's on the RTX 5080 Laptop
GPU, ANV on the Iris Xe of RPL-P, RADV on the Radeon RX 550). The one exception stays the measured
DriverFact::ColorClearIsMetals row: MoltenVK on the Apple9 GPUs, whose load operation of an
attachment the render area covers clears as Metal's.
Runtime: clear_value::rounds_apart and fill_value::device_apart lose their `either` argument; a
normalized channel's clear or plain fill is in question wherever its scaled `float` is off a whole
code (the rule the three rows took), which subsumes the old margin of 1/1024 around a midpoint
(and the packed 16-bit formats' wider one). render_pass.rs and blit_fill.rs read no fact for it;
the load operation's exception under ColorClearIsMetals is unchanged. The fresh pattern of a
signed normalized format (code -1) is written by copies of its bytes, not a clear: no `float`
scales onto it (-1/127 is -0.99999999627 codes), so its clear is in question under the rule
(texture/heap_tiled.rs fresh_pattern; the fresh-pattern test allows its 1-byte texel).
Translator: DriverFact::ColorClearTakesEitherCode, its three rows and AMD_RX_550 (only they used
it) are removed; the facts table test and api_signatures.tsv follow. ColorClearIsMetals' doc
and PrecisionNote::DeviceColorConversion's state the spec's rule.
Validation: buffer_texture_blits' IOSurface planes expect the clear's notice on every device but
where the load operation clears as Metal's (degrade_notices::clear_in_question, the former
tie_cleared, now stated for any value off a whole code). color_fills prints how many plain fills
announced device-color-conversion (COLOR-FILLS-ANNOUNCED).
Docs: docs/API.md's device-color-conversion entry is the spec's statement plus the measured
devices and the one exception.
Verified: cargo fmt. Runs follow through potluck.
(cherry picked from commit 9a844f5c5f5ce1499664f77eceb66fccf2dfd9f7)
This commit is contained in:
1 parent
39773d40f2
commit
876cfd1402
18 files changed
+180
-264
No files matched your search
@@ -556,9 +556,7 @@ fn placement(
|
||||
/// texel than Metal's fill packs ([`device_apart`], `device-color-conversion`), and where it
|
||||
/// converts a half or small-float NaN as the device likes ([`device_nan`], `device-nan-encoding`).
|
||||
fn degrade_fill_conversion(device: &Device, pf: PixelFormat, color: [f64; 4]) {
|
||||
let either = (device.properties().driver_facts)
|
||||
.contains(&metal2vulkan::device::DriverFact::ColorClearTakesEitherCode);
|
||||
if device_apart(pf, color, either) {
|
||||
if device_apart(pf, color) {
|
||||
device.degrade(Degradation::DeviceColorConversion, || {
|
||||
(
|
||||
format!("a color fill of a {pf:?} texture to {color:?}"),
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
//! round to nearest ("Implementations should round to nearest"), and leaves a float format's
|
||||
//! rounding and an sRGB encode's precision to the device. So the device's texel can stand a code
|
||||
//! from Metal's where the rounding is in question ([`rounds_apart`], announced
|
||||
//! `device-color-conversion`): a normalized channel's value scaled within [`TIE`] of a midpoint
|
||||
//! between two codes (a packed 16-bit channel's within the error of Metal's step through `half`),
|
||||
//! or anywhere off a whole code on a driver measured to take either code
|
||||
//! (`DriverFact::ColorClearTakesEitherCode`),
|
||||
//! an sRGB channel's value inside `(0, 1)`, a half or small float's value it does not hold
|
||||
//! exactly, and a shared exponent's texel it does not; and a `Depth16Unorm` depth scaled at or
|
||||
//! `device-color-conversion`): a normalized channel's value scaled anywhere off a whole code, on
|
||||
//! every device (the RTX 5080 Laptop GPU, ANV on the Iris Xe of RPL-P and RADV on the Radeon RX
|
||||
//! 550 are measured to store the farther code off a midpoint; docs/API.md's
|
||||
//! `device-color-conversion` entry), an sRGB channel's value inside `(0, 1)`, a half or small
|
||||
//! float's value it does not hold exactly, and a shared exponent's texel it does not; and a
|
||||
//! `Depth16Unorm` depth scaled at or
|
||||
//! within [`TIE`] of a midpoint or above it, which Metal's clear truncates and a device rounding
|
||||
//! to nearest takes to the code above ([`depth16_rounded`], announced `unorm-depth-rounding`). Vulkan states no conversion of a NaN to a normalized code, or to
|
||||
//! `RGB9E5Float`, which holds none: such a channel clears as 0, as Metal's does. A `half` or
|
||||
@@ -273,24 +273,18 @@ fn native(channel: Channel, x: f64) -> f32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// How near a midpoint between two codes a normalized channel's scaled clear value lies where a
|
||||
/// How near a midpoint between two codes a `Depth16Unorm` clear's scaled depth lies where a
|
||||
/// device rounding to nearest, as Vulkan asks, may round it either way: a tie, or a value its
|
||||
/// arithmetic may take across one.
|
||||
/// arithmetic may take across one ([`depth16_rounded`]).
|
||||
const TIE: f64 = 1.0 / 1024.0;
|
||||
|
||||
/// Whether `r`, a value scaled to codes, lies within `margin` of a midpoint between two codes.
|
||||
fn near_tie(r: f64, margin: f64) -> bool {
|
||||
(r - r.floor() - 0.5).abs() <= margin
|
||||
}
|
||||
|
||||
/// Whether the device's conversion of [`color`]'s clear value of `color` for an attachment of
|
||||
/// `pf` may store another texel than Metal's clear (the module docs): a channel whose rounding is
|
||||
/// in question, a normalized one's anywhere off a whole code where the device takes either nearest
|
||||
/// code (`either`, `DriverFact::ColorClearTakesEitherCode`). False for a clear the device converts
|
||||
/// nothing of (an integer, extended-range or YCbCr format's, or a format with no clear rule), and
|
||||
/// for a NaN, whose half or small float the device converts as it likes
|
||||
/// (`nan_clear::degrade_nan_clears`).
|
||||
pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bool {
|
||||
/// in question, a normalized one's anywhere off a whole code, where Vulkan lets the device store
|
||||
/// either of the two codes closest to it. False for a clear the device converts nothing of (an
|
||||
/// integer, extended-range or YCbCr format's, or a format with no clear rule), and for a NaN,
|
||||
/// whose half or small float the device converts as it likes (`nan_clear::degrade_nan_clears`).
|
||||
pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4]) -> bool {
|
||||
if ExtendedRange::of(pf).is_some() || ycbcr_renders(pf) {
|
||||
return false;
|
||||
}
|
||||
@@ -298,10 +292,13 @@ pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bo
|
||||
return false;
|
||||
};
|
||||
let values: [f32; 4] = std::array::from_fn(|i| native(channels[i], color[i]));
|
||||
let scaled = |v: f32, lo: f32, max: u64| f64::from(v.clamp(lo, 1.0)) * max as f64;
|
||||
// In question near a midpoint, or anywhere off a whole code where the device takes either
|
||||
// nearest code.
|
||||
let apart = |r: f64, margin: f64| near_tie(r, margin) || (either && r != r.round());
|
||||
// In question anywhere off a whole code, where the device may store either code nearest it.
|
||||
// A packed 16-bit channel's whole code is Metal's too: its step through `half` moves the
|
||||
// scaled value by at most its code range times 2^-11, under half a code.
|
||||
let apart = |v: f32, lo: f32, max: u64| {
|
||||
let r = f64::from(v.clamp(lo, 1.0)) * max as f64;
|
||||
r != r.round()
|
||||
};
|
||||
channels
|
||||
.iter()
|
||||
.zip(values)
|
||||
@@ -311,14 +308,8 @@ pub(super) fn rounds_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bo
|
||||
| Channel::Uint(_)
|
||||
| Channel::Sint(_)
|
||||
| Channel::Float => false,
|
||||
Channel::Unorm(bits) => apart(scaled(v, 0.0, (1 << bits) - 1), TIE),
|
||||
// Metal steps through `half`, which moves the scaled value by up to its code range
|
||||
// times 2^-11.
|
||||
Channel::HalfUnorm(bits) => {
|
||||
let max = (1u64 << bits) - 1;
|
||||
apart(scaled(v, 0.0, max), TIE + max as f64 / 2048.0)
|
||||
}
|
||||
Channel::Snorm(bits) => apart(scaled(v, -1.0, (1 << (bits - 1)) - 1), TIE),
|
||||
Channel::Unorm(bits) | Channel::HalfUnorm(bits) => apart(v, 0.0, (1 << bits) - 1),
|
||||
Channel::Snorm(bits) => apart(v, -1.0, (1 << (bits - 1)) - 1),
|
||||
Channel::Srgb => v > 0.0 && v < 1.0,
|
||||
Channel::Half => !v.is_nan() && f16_to_f32(f32_to_f16(v)) != v,
|
||||
Channel::Ufloat(mantissa) => {
|
||||
@@ -1135,26 +1126,25 @@ pub(crate) mod tests {
|
||||
assert!(color(P::Depth32Float, [0.0; 4], ClearRoute::ThroughHalf).is_none());
|
||||
}
|
||||
|
||||
/// A clear whose rounding is in question is the one announced: a normalized value at a tie, an
|
||||
/// sRGB value inside its range, a value a half, small float or shared exponent does not hold;
|
||||
/// On a driver that takes either code nearest a normalized channel's scaled value
|
||||
/// (`DriverFact::ColorClearTakesEitherCode`) a clear is in question wherever such a channel's
|
||||
/// scaled value is off a whole code, as the RTX 5080 Laptop GPU's clears stored (`R16Unorm`'s
|
||||
/// 0.001 is 65.535 codes, which it stored as 65, Metal 66), a scaled `float` a hair off a
|
||||
/// whole code included (it may go either way); elsewhere only near a midpoint. A whole code,
|
||||
/// and a channel of another kind, is in question as before on both.
|
||||
/// On every device a clear is in question wherever a normalized channel's scaled value is off
|
||||
/// a whole code, where Vulkan lets the device store either of the two codes closest to it, as
|
||||
/// the RTX 5080 Laptop GPU's clears stored (`R16Unorm`'s 0.001 is 65.535 codes, which it
|
||||
/// stored as 65, Metal 66), a scaled `float` a hair off a whole code included (it may go
|
||||
/// either way: `RGBA8Unorm`'s 0.2 is 51.0000008 codes). A whole code, and a channel of another
|
||||
/// kind, is in question as for any other clear.
|
||||
#[test]
|
||||
fn a_driver_taking_either_code_has_every_clear_off_a_code_in_question() {
|
||||
fn every_clear_off_a_whole_code_is_in_question() {
|
||||
let off = [
|
||||
(P::R16Unorm, [0.001, 0.0, 0.0, 0.0]),
|
||||
(P::RGBA8Unorm, [0.25, 0.0, 0.0, 1.0]),
|
||||
(P::RGBA8Unorm, [0.2, 0.0, 0.0, 1.0]),
|
||||
(P::RG8Unorm, [0.0, 0.904, 0.0, 0.0]),
|
||||
(P::R8Snorm, [-0.3, 0.0, 0.0, 0.0]),
|
||||
(P::B5G6R5Unorm, [0.7529, 0.0, 0.0, 0.0]),
|
||||
(P::RGBA8Unorm, [0.5, 0.0, 0.0, 1.0]),
|
||||
];
|
||||
for (pf, c) in off {
|
||||
assert!(rounds_apart(pf, c, true), "{pf:?} {c:?}");
|
||||
assert!(!rounds_apart(pf, c, false), "{pf:?} {c:?}");
|
||||
assert!(rounds_apart(pf, c), "{pf:?} {c:?}");
|
||||
}
|
||||
let whole = [
|
||||
(P::RGBA8Unorm, [0.0, 1.0, 0.0, 1.0]),
|
||||
@@ -1163,12 +1153,14 @@ pub(crate) mod tests {
|
||||
(P::R32Float, [0.1, 0.0, 0.0, 0.0]),
|
||||
];
|
||||
for (pf, c) in whole {
|
||||
assert!(!rounds_apart(pf, c, true), "{pf:?} {c:?}");
|
||||
assert!(!rounds_apart(pf, c), "{pf:?} {c:?}");
|
||||
}
|
||||
assert!(rounds_apart(P::RGBA8Unorm, [0.5, 0.0, 0.0, 1.0], true));
|
||||
}
|
||||
|
||||
/// not a code, a value past the range, a value the format holds, a 32-bit float or an integer.
|
||||
/// A clear whose rounding is in question is the one announced: a normalized value off a whole
|
||||
/// code (a tie, or a value's `float` a hair off a code), an sRGB value inside its range, a
|
||||
/// value a half, small float or shared exponent does not hold; not a whole code, a value past
|
||||
/// the range, a value the format holds, a 32-bit float or an integer.
|
||||
#[test]
|
||||
fn a_clear_whose_rounding_is_in_question_is_the_one_announced() {
|
||||
let apart = [
|
||||
@@ -1184,18 +1176,17 @@ pub(crate) mod tests {
|
||||
(P::RGB9E5Float, [1.0, 2f64.powi(-9), 0.0, 0.0]),
|
||||
(P::RGB9E5Float, [70000.0, 0.0, 0.0, 0.0]),
|
||||
(P::B5G6R5Unorm, [15.5 / 31.0, 0.0, 0.0, 0.0]),
|
||||
(P::RGBA8Unorm, [0.0, 1.0, 0.25, 0.75]),
|
||||
(P::RGBA8Unorm, [128.0 / 255.0, 0.0, 0.0, 0.0]),
|
||||
(P::RGBA8Snorm, [-1.0 / 127.0, 0.0, 0.0, 0.0]),
|
||||
];
|
||||
for (pf, c) in apart {
|
||||
assert!(rounds_apart(pf, c, false), "{pf:?} {c:?}");
|
||||
assert!(rounds_apart(pf, c), "{pf:?} {c:?}");
|
||||
}
|
||||
let held = [
|
||||
(P::RGBA8Unorm, [0.0, 1.0, 0.25, 0.75]),
|
||||
(P::RGBA8Unorm, [0.0, 1.0, 0.0, 1.0]),
|
||||
(P::RGBA8Unorm, [1.5, -0.5, f64::NAN, f64::INFINITY]),
|
||||
(
|
||||
P::RGBA8Unorm,
|
||||
[128.0 / 255.0, 1.0 / 255.0, 254.0 / 255.0, 0.2],
|
||||
),
|
||||
(P::RGBA8Snorm, [-1.0 / 127.0, -1.5, 0.0, 1.0]),
|
||||
(P::RGBA8Snorm, [-1.0, -1.5, 0.0, 1.0]),
|
||||
(P::RGBA8UnormSRGB, [0.0, 1.0, -0.5, 1.0]),
|
||||
(P::R16Float, [0.5, 0.0, 0.0, 0.0]),
|
||||
(P::RGBA16Float, [-2.0, 65504.0, f64::NAN, f64::INFINITY]),
|
||||
@@ -1208,14 +1199,15 @@ pub(crate) mod tests {
|
||||
(P::BGRA10XR, [0.1, 0.2, 0.3, 0.4]),
|
||||
];
|
||||
for (pf, c) in held {
|
||||
assert!(!rounds_apart(pf, c, false), "{pf:?} {c:?}");
|
||||
assert!(!rounds_apart(pf, c), "{pf:?} {c:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Where no rounding is in question, a device that rounds to nearest, as Vulkan asks, stores
|
||||
/// Metal's code whatever it does at a tie: every normalized and packed 16-bit format, over
|
||||
/// every value of 1/1024 steps from -0.25 to 1.25 in each channel; and the clear of an sRGB,
|
||||
/// half, small-float or shared-exponent value the format holds is Metal's texel.
|
||||
/// Where no rounding is in question, a normalized channel's value on a whole code, the device
|
||||
/// stores Metal's code: every normalized and packed 16-bit format, over every value of 1/1024
|
||||
/// steps from -0.25 to 1.25 in each channel that lies on one (0 and 1, and those clamped to
|
||||
/// them); and the clear of an sRGB, half, small-float or shared-exponent value the format
|
||||
/// holds is Metal's texel.
|
||||
#[test]
|
||||
fn where_no_rounding_is_in_question_the_nearest_code_is_metal_s() {
|
||||
for pf in [
|
||||
@@ -1236,7 +1228,7 @@ pub(crate) mod tests {
|
||||
for (i, &channel) in channels.iter().enumerate() {
|
||||
let mut one = [0.0; 4];
|
||||
one[i] = c[i];
|
||||
if rounds_apart(pf, one, false) {
|
||||
if rounds_apart(pf, one) {
|
||||
continue;
|
||||
}
|
||||
let v = native(channel, c[i]);
|
||||
@@ -1262,7 +1254,7 @@ pub(crate) mod tests {
|
||||
(P::RG11B10Float, [1.0, 0.5, 2.0, 0.0]),
|
||||
(P::RGB9E5Float, [1.0, 0.5, 2.0, 0.0]),
|
||||
] {
|
||||
assert!(!rounds_apart(pf, c, false), "{pf:?} {c:?}");
|
||||
assert!(!rounds_apart(pf, c), "{pf:?} {c:?}");
|
||||
// SAFETY (union read): a float format's clear is `float32`.
|
||||
let value = unsafe { color(pf, c, ClearRoute::ThroughHalf).unwrap().float32 };
|
||||
assert_eq!(
|
||||
@@ -1306,7 +1298,7 @@ pub(crate) mod tests {
|
||||
for (i, (x, b)) in f.iter().zip(bytes).enumerate() {
|
||||
let mut one = [0.0; 4];
|
||||
one[(i + 3) % 4] = clear[(i + 3) % 4];
|
||||
if rounds_apart(P::ARGB8Unorm, one, false) {
|
||||
if rounds_apart(P::ARGB8Unorm, one) {
|
||||
continue;
|
||||
}
|
||||
let code = (f64::from(x.clamp(0.0, 1.0)) * 255.0).round();
|
||||
@@ -1314,7 +1306,7 @@ pub(crate) mod tests {
|
||||
compared += 1;
|
||||
}
|
||||
}
|
||||
assert!(compared >= 20, "{compared} bytes compared");
|
||||
assert!(compared >= 12, "{compared} bytes compared");
|
||||
}
|
||||
|
||||
/// A depth clears as a `float`, which the device converts; a `Depth16Unorm` clear a device
|
||||
|
||||
@@ -411,29 +411,14 @@ pub(super) fn device_converts(pf: PixelFormat) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// How near a midpoint between two codes a normalized channel's scaled color may lie where the
|
||||
/// device, which Vulkan asks to round to nearest (it may store either nearest code), may store the
|
||||
/// other code than Metal's fill: a
|
||||
/// tie (which the fill rounds up, half away from zero signed), or a value the device's arithmetic
|
||||
/// may take across one, as for a clear (`clear_value.rs`).
|
||||
const TIE: f64 = 1.0 / 1024.0;
|
||||
|
||||
/// Whether `r`, a value scaled to codes, lies within `margin` of a midpoint between two codes.
|
||||
fn near_tie(r: f64, margin: f64) -> bool {
|
||||
(r - r.floor() - 0.5).abs() <= margin
|
||||
}
|
||||
|
||||
/// Whether the device's clear of `color` for a texture of `pf` ([`device_converts`]) may store
|
||||
/// another texel than Metal's fill packs (the module docs), announced `device-color-conversion`:
|
||||
/// a normalized channel's value scaled within [`TIE`] of a midpoint between two codes (widened by
|
||||
/// the fill's rounding of the product to `float`, and for a packed 16-bit format by a step
|
||||
/// through `half`, which a device's clear may take as Metal's own clear does), or anywhere off a
|
||||
/// whole code where the device takes either of the two nearest codes (`either`,
|
||||
/// `DriverFact::ColorClearTakesEitherCode`), an sRGB channel's
|
||||
/// value inside `(0, 1)` (the fill takes the code whose decoded value is nearest, the device
|
||||
/// encodes), and a half's, small float's or shared exponent's value it does not hold exactly. A
|
||||
/// NaN is [`device_nan`]'s, or stores 0 on both.
|
||||
pub(super) fn device_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bool {
|
||||
/// a normalized channel's value scaled anywhere off a whole code, where Vulkan lets the device
|
||||
/// store either of the two codes closest to it (a tie among them, which the fill rounds up, half
|
||||
/// away from zero signed), an sRGB channel's value inside `(0, 1)` (the fill takes the code whose
|
||||
/// decoded value is nearest, the device encodes), and a half's, small float's or shared
|
||||
/// exponent's value it does not hold exactly. A NaN is [`device_nan`]'s, or stores 0 on both.
|
||||
pub(super) fn device_apart(pf: PixelFormat, color: [f64; 4]) -> bool {
|
||||
use Conversion as C;
|
||||
if pf == PixelFormat::RGB9E5Float {
|
||||
return !shared_exact(color);
|
||||
@@ -441,9 +426,6 @@ pub(super) fn device_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bo
|
||||
let Some(fields) = fields(pf) else {
|
||||
return false;
|
||||
};
|
||||
// A packed 16-bit format: B5G6R5, A1BGR5, BGR5A1, ABGR4 and BGRA4.
|
||||
let packed16 =
|
||||
fields.len() >= 3 && fields.iter().map(|f| f.conversion.width()).sum::<u32>() == 16;
|
||||
fields.iter().any(|f| {
|
||||
let v = color[f.channel] as f32;
|
||||
if v.is_nan() {
|
||||
@@ -455,12 +437,8 @@ pub(super) fn device_apart(pf: PixelFormat, color: [f64; 4], either: bool) -> bo
|
||||
C::Unorm(_) => (0.0, largest(bits) as f64),
|
||||
_ => (-1.0, largest(bits - 1) as f64),
|
||||
};
|
||||
let margin = match packed16 {
|
||||
true => TIE + m / 2048.0,
|
||||
false => TIE + m / f64::from(1u32 << 24),
|
||||
};
|
||||
let r = f64::from(v.clamp(low, 1.0)) * m;
|
||||
near_tie(r, margin) || (either && r != r.round())
|
||||
r != r.round()
|
||||
}
|
||||
C::Srgb => v > 0.0 && v < 1.0,
|
||||
C::Half => {
|
||||
|
||||
@@ -1631,11 +1631,9 @@ pub(super) fn layout(
|
||||
// The device converts a float clear its own way, which can stand a code from Metal's
|
||||
// where the rounding is in question (`clear_value::rounds_apart`), announced once the
|
||||
// render area is known (below); a word attachment's clear is Metal's codes.
|
||||
let either =
|
||||
(device.properties().driver_facts).contains(&DriverFact::ColorClearTakesEitherCode);
|
||||
let withheld_clear = (color.load_action == LoadAction::Clear
|
||||
&& word.is_none()
|
||||
&& clear_value::rounds_apart(texture.pixel_format(), channels, either))
|
||||
&& clear_value::rounds_apart(texture.pixel_format(), channels))
|
||||
.then_some(channels);
|
||||
let straight_clear = ExtendedRange::of(texture.pixel_format()).and_then(|_| {
|
||||
clear_value::color(texture.pixel_format(), channels, ClearRoute::Straight)
|
||||
|
||||
@@ -314,32 +314,30 @@ fn every_measured_fill_texel_is_metal_s() {
|
||||
assert!(wrong.is_empty(), "fills unlike Metal's: {wrong:?}");
|
||||
}
|
||||
|
||||
/// Unsigned normalized: a 4- or 8-bit channel rounds the exact product half up, any other width
|
||||
/// the product's `float` (the probe's thresholds).
|
||||
/// On a driver that takes either code nearest a normalized channel's scaled value
|
||||
/// (`DriverFact::ColorClearTakesEitherCode`), a plain fill is announced wherever such a channel's
|
||||
/// scaled color is off a whole code, as the RTX 5080 Laptop GPU's clears stored; elsewhere only
|
||||
/// near a midpoint. A whole code, and a float channel, is not announced on either.
|
||||
/// On every device a plain fill is announced wherever a normalized channel's scaled color is off a
|
||||
/// whole code, where Vulkan lets the device's clear store either of the two codes closest to it,
|
||||
/// as the RTX 5080 Laptop GPU's clears stored. A whole code, and a float channel, is not.
|
||||
#[test]
|
||||
fn a_driver_taking_either_code_announces_every_fill_off_a_code() {
|
||||
fn every_fill_off_a_whole_code_is_announced() {
|
||||
for (pf, color) in [
|
||||
(P::R16Unorm, [0.001, 0.0, 0.0, 0.0]),
|
||||
(P::RG8Unorm, [0.0, 0.904, 0.0, 0.0]),
|
||||
(P::R8Snorm, [0.649_799_282_935_052, 0.0, 0.0, 0.0]),
|
||||
(P::B5G6R5Unorm, [0.0, 0.0, 0.752_941_176_470_588_2, 0.0]),
|
||||
] {
|
||||
assert!(device_apart(pf, color, true), "{pf:?} {color:?}");
|
||||
assert!(!device_apart(pf, color, false), "{pf:?} {color:?}");
|
||||
assert!(device_apart(pf, color), "{pf:?} {color:?}");
|
||||
}
|
||||
for (pf, color) in [
|
||||
(P::RGBA8Unorm, [0.0, 1.0, 0.0, 1.0]),
|
||||
(P::R8Snorm, [-1.0, 0.0, 0.0, 0.0]),
|
||||
(P::R32Float, [0.1, 0.0, 0.0, 0.0]),
|
||||
] {
|
||||
assert!(!device_apart(pf, color, true), "{pf:?} {color:?}");
|
||||
assert!(!device_apart(pf, color), "{pf:?} {color:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Unsigned normalized: a 4- or 8-bit channel rounds the exact product half up, any other width
|
||||
/// the product's `float` (the probe's thresholds).
|
||||
#[test]
|
||||
fn unorm_rounds_its_product_by_width() {
|
||||
// 0.5/65535's `float` times 65535 rounds to 0.5 in `float`, which rounds up; a clear stores 0.
|
||||
@@ -1042,10 +1040,10 @@ fn the_m3_packs_these_formats_and_no_other() {
|
||||
|
||||
/// A plain fill is the device's clear of the color only where the format's fill converts a
|
||||
/// `float` (`device_converts`), and the clear is announced where the device's conversion may store
|
||||
/// another texel than Metal's fill packs (`device_apart`: a normalized tie, which the fill rounds
|
||||
/// half up, a packed 16-bit channel within the step through `half` of one, an sRGB value inside
|
||||
/// `(0, 1)`, a value a half, small float or shared exponent does not hold), or a NaN it converts
|
||||
/// as it likes (`device_nan`).
|
||||
/// another texel than Metal's fill packs (`device_apart`: a normalized value off a whole code, a
|
||||
/// tie among them, which the fill rounds half up, an sRGB value inside `(0, 1)`, a value a half,
|
||||
/// small float or shared exponent does not hold), or a NaN it converts as it likes
|
||||
/// (`device_nan`).
|
||||
#[test]
|
||||
fn the_device_s_clear_is_announced_where_its_conversion_is_in_question() {
|
||||
for pf in [
|
||||
@@ -1075,19 +1073,19 @@ fn the_device_s_clear_is_announced_where_its_conversion_is_in_question() {
|
||||
let one = |x: f64| [x, 0.0, 0.0, 1.0];
|
||||
let apart = [
|
||||
(P::RGBA8Unorm, one(0.5), true),
|
||||
(P::RGBA8Unorm, one(0.25), false),
|
||||
(P::RGBA8Unorm, one(0.25), true),
|
||||
(P::RGBA8Unorm, one(1.0), false),
|
||||
(P::RGBA8Unorm, one(f64::NAN), false),
|
||||
// Off a tie by a hundredth of a code: a tie for a packed 16-bit channel, whose clear may
|
||||
// step through `half`, and not for an 8-bit one.
|
||||
(P::RGBA8Unorm, one(127.51 / 255.0), false),
|
||||
// Off a tie by a hundredth of a code, off a whole code all the same.
|
||||
(P::RGBA8Unorm, one(127.51 / 255.0), true),
|
||||
(P::B5G6R5Unorm, one(15.51 / 31.0), true),
|
||||
(P::R16Unorm, one(0.5 / 65535.0), true),
|
||||
(P::RG8Snorm, one(-0.5 / 127.0), true),
|
||||
(P::RG8Snorm, one(-1.0), false),
|
||||
(P::RGBA8UnormSRGB, one(0.5), true),
|
||||
(P::RGBA8UnormSRGB, [0.0, 1.0, 0.0, 0.5], true),
|
||||
(P::RGBA8UnormSRGB, [0.0, 1.0, 0.0, 0.25], false),
|
||||
(P::RGBA8UnormSRGB, [0.0, 1.0, 0.0, 0.25], true),
|
||||
(P::RGBA8UnormSRGB, [0.0, 1.0, 0.0, 1.0], false),
|
||||
(P::RGBA16Float, one(0.1), true),
|
||||
(P::RGBA16Float, one(0.5), false),
|
||||
(P::RGBA16Float, one(1e6), true),
|
||||
@@ -1100,7 +1098,7 @@ fn the_device_s_clear_is_announced_where_its_conversion_is_in_question() {
|
||||
(P::RGB9E5Float, [1e6, 0.0, 0.0, 0.0], true),
|
||||
];
|
||||
for (pf, color, want) in apart {
|
||||
assert_eq!(device_apart(pf, color, false), want, "{pf:?} {color:?}");
|
||||
assert_eq!(device_apart(pf, color), want, "{pf:?} {color:?}");
|
||||
}
|
||||
for (pf, want) in [
|
||||
(P::RGBA16Float, true),
|
||||
|
||||
@@ -1326,8 +1326,9 @@ fn multisample_samples_lie_where_metal_draws_them() {
|
||||
|
||||
/// Each clear color `fresh_pattern` gives converts to its texel on every device: no rounding of
|
||||
/// it is in question (`clear_value::rounds_apart`), and Metal's conversion
|
||||
/// (`clear_value::tests::texel_bytes`) writes the pattern. Every pattern is of a whole number of bytes a texel, and every format with a pattern
|
||||
/// but a clear color is one whose pattern holds a NaN or an extended-range code.
|
||||
/// (`clear_value::tests::texel_bytes`) writes the pattern. Every format with a pattern but no
|
||||
/// clear color is one whose pattern holds a NaN, an extended-range code or a signed normalized
|
||||
/// code -1, which no clear color scales onto a whole code.
|
||||
#[test]
|
||||
fn fresh_patterns_clear_colors_write_their_texels() {
|
||||
let mut cleared = 0;
|
||||
@@ -1340,15 +1341,15 @@ fn fresh_patterns_clear_colors_write_their_texels() {
|
||||
let bytes = crate::clear_value::tests::texel_bytes(pf, color);
|
||||
assert_eq!(bytes.as_deref(), Some(texel), "{pf:?}: {color:?}");
|
||||
assert!(
|
||||
!crate::clear_value::rounds_apart(pf, color, false),
|
||||
!crate::clear_value::rounds_apart(pf, color),
|
||||
"{pf:?}: {color:?}"
|
||||
);
|
||||
cleared += 1;
|
||||
}
|
||||
Some(FreshPattern::Color { texel, color: None }) => {
|
||||
assert!(
|
||||
[2, 4, 8, 16].contains(&texel.len()),
|
||||
"{pf:?}: a NaN or extended-range pattern of {} bytes",
|
||||
[1, 2, 4, 8, 16].contains(&texel.len()),
|
||||
"{pf:?}: a NaN, extended-range or signed normalized pattern of {} bytes",
|
||||
texel.len()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -636,26 +636,28 @@ pub(crate) fn metal_keeps_uncompressed(colour: bool, usage: TextureUsage) -> boo
|
||||
pub(crate) fn fresh_pattern(pf: PixelFormat) -> Option<FreshPattern> {
|
||||
use FreshPattern::{Color, DepthStencil};
|
||||
use PixelFormat as P;
|
||||
// A clear color whose conversion writes the texel exactly (`clear_value::texel_bytes`).
|
||||
// A clear color whose conversion writes the texel exactly (`clear_value::texel_bytes`), no
|
||||
// rounding of it in question (`clear_value::rounds_apart`). A signed normalized pattern's
|
||||
// code -1 takes none: no `float` scales onto it (`-1/127` is -0.99999999627 codes, which
|
||||
// Vulkan lets a clear store as 0), so copies of its bytes write it.
|
||||
const MAGENTA: Option<[f64; 4]> = Some([1.0, 0.0, 1.0, 1.0]);
|
||||
const YELLOW: Option<[f64; 4]> = Some([1.0, 1.0, 0.0, 1.0]);
|
||||
const ONES: Option<[f64; 4]> = Some([4294967295.0, 0.0, 4294967295.0, 4294967295.0]);
|
||||
const MINUS_ONE: Option<[f64; 4]> = Some([-1.0, 0.0, -1.0, -1.0]);
|
||||
const SNORM8: Option<[f64; 4]> = Some([-1.0 / 127.0, 0.0, -1.0 / 127.0, -1.0 / 127.0]);
|
||||
const SNORM16: Option<[f64; 4]> = Some([-1.0 / 32767.0, 0.0, -1.0 / 32767.0, -1.0 / 32767.0]);
|
||||
const SNORM: Option<[f64; 4]> = None;
|
||||
const SHARED: Option<[f64; 4]> = Some([65408.0, 0.0, 65408.0, 1.0]);
|
||||
let color = |texel: &'static [u8], color: Option<[f64; 4]>| Some(Color { texel, color });
|
||||
match pf {
|
||||
P::A8Unorm | P::R8Unorm | P::R8UnormSRGB => color(&[0xff], MAGENTA),
|
||||
P::R8Snorm => color(&[0xff], SNORM8),
|
||||
P::R8Snorm => color(&[0xff], SNORM),
|
||||
P::R8Uint => color(&[0xff], ONES),
|
||||
P::R8Sint => color(&[0xff], MINUS_ONE),
|
||||
P::RG8Unorm | P::RG8UnormSRGB => color(&[0xff, 0x00], MAGENTA),
|
||||
P::RG8Snorm => color(&[0xff, 0x00], SNORM8),
|
||||
P::RG8Snorm => color(&[0xff, 0x00], SNORM),
|
||||
P::RG8Uint => color(&[0xff, 0x00], ONES),
|
||||
P::RG8Sint => color(&[0xff, 0x00], MINUS_ONE),
|
||||
P::R16Unorm => color(&[0xff, 0xff], MAGENTA),
|
||||
P::R16Snorm => color(&[0xff, 0xff], SNORM16),
|
||||
P::R16Snorm => color(&[0xff, 0xff], SNORM),
|
||||
P::R16Uint => color(&[0xff, 0xff], ONES),
|
||||
P::R16Sint => color(&[0xff, 0xff], MINUS_ONE),
|
||||
P::R16Float => color(&[0xff, 0xff], None),
|
||||
@@ -666,7 +668,7 @@ pub(crate) fn fresh_pattern(pf: PixelFormat) -> Option<FreshPattern> {
|
||||
P::RGBA8Unorm | P::RGBA8UnormSRGB | P::BGRA8Unorm | P::BGRA8UnormSRGB => {
|
||||
color(&[0xff, 0x00, 0xff, 0xff], MAGENTA)
|
||||
}
|
||||
P::RGBA8Snorm => color(&[0xff, 0x00, 0xff, 0xff], SNORM8),
|
||||
P::RGBA8Snorm => color(&[0xff, 0x00, 0xff, 0xff], SNORM),
|
||||
P::RGBA8Uint => color(&[0xff, 0x00, 0xff, 0xff], ONES),
|
||||
P::RGBA8Sint => color(&[0xff, 0x00, 0xff, 0xff], MINUS_ONE),
|
||||
P::RGB10A2Unorm | P::BGR10A2Unorm => color(&[0xff, 0x03, 0xf0, 0xff], MAGENTA),
|
||||
@@ -675,7 +677,7 @@ pub(crate) fn fresh_pattern(pf: PixelFormat) -> Option<FreshPattern> {
|
||||
P::RG11B10Float => color(&[0xe0, 0x07, 0x00, 0xfc], None),
|
||||
P::RGB9E5Float => color(&[0xff, 0x01, 0xfc, 0xff], SHARED),
|
||||
P::RG16Unorm => color(&[0xff, 0xff, 0x00, 0x00], MAGENTA),
|
||||
P::RG16Snorm => color(&[0xff, 0xff, 0x00, 0x00], SNORM16),
|
||||
P::RG16Snorm => color(&[0xff, 0xff, 0x00, 0x00], SNORM),
|
||||
P::RG16Uint => color(&[0xff, 0xff, 0x00, 0x00], ONES),
|
||||
P::RG16Sint => color(&[0xff, 0xff, 0x00, 0x00], MINUS_ONE),
|
||||
P::RG16Float => color(&[0xff, 0xff, 0x00, 0x00], None),
|
||||
@@ -683,7 +685,7 @@ pub(crate) fn fresh_pattern(pf: PixelFormat) -> Option<FreshPattern> {
|
||||
P::R32Sint => color(&[0xff; 4], MINUS_ONE),
|
||||
P::R32Float => color(&[0xff; 4], None),
|
||||
P::RGBA16Unorm => color(&[0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff], MAGENTA),
|
||||
P::RGBA16Snorm => color(&[0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff], SNORM16),
|
||||
P::RGBA16Snorm => color(&[0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff], SNORM),
|
||||
P::RGBA16Uint => color(&[0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff], ONES),
|
||||
P::RGBA16Sint => color(&[0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff], MINUS_ONE),
|
||||
P::RGBA16Float => color(&[0xff, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff], None),
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
//! between rows. The overlapping cases, which a model alone would not prove, also match the rows
|
||||
//! the probe recorded on the M4 and the M3 Max.
|
||||
|
||||
use super::degrade_notices::{assert_made_once, forced, shared_in_system_memory};
|
||||
use super::degrade_notices::{
|
||||
assert_made_once, clear_in_question, forced, shared_in_system_memory,
|
||||
};
|
||||
use super::host_memory::{no_copy, not_importable, Mapping};
|
||||
use super::{
|
||||
buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages,
|
||||
@@ -936,8 +938,8 @@ pub(super) const NARROW_ROWS: [Degradation; 1] = [Degradation::NarrowSurfaceRows
|
||||
/// without planes at 4 bytes a row (Metal asserts) and of rows that overlap on the GPU. The
|
||||
/// device announces `NarrowSurfaceRows` once, for the planes under 16 bytes a row, and where they
|
||||
/// force it a plane's shadow ([`linear_rows_differ`]), the `Shared` buffers' system memory, and
|
||||
/// the planes' clear's conversion on a driver whose clears take either nearest code
|
||||
/// (`DriverFact::ColorClearTakesEitherCode`).
|
||||
/// the planes' clear's conversion but where the load operation clears as Metal's
|
||||
/// (`degrade_notices::clear_in_question`).
|
||||
#[test]
|
||||
fn iosurface_planes_lie_where_metal_puts_them() {
|
||||
let messages = Messages::default();
|
||||
@@ -1014,17 +1016,16 @@ fn iosurface_planes_lie_where_metal_puts_them() {
|
||||
.iter()
|
||||
.any(|&(pf, texel, _, bpr)| linear_rows_differ(&device, pf, [4, 4], texel, bpr));
|
||||
// The planes' clear to (0.2, 0.4, 0.6, 0.8), each scaled `float` a hair off a whole code,
|
||||
// where the device's clear may store either code nearest it.
|
||||
let either = (device.properties().driver_facts)
|
||||
.contains(&metal2vulkan::device::DriverFact::ColorClearTakesEitherCode);
|
||||
let first = forced(&[
|
||||
// where the device's clear may store either code nearest it, by its load operation of
|
||||
// the whole plane.
|
||||
let mut first = forced(&[
|
||||
(Degradation::ShadowedTexture, shadowed),
|
||||
(
|
||||
Degradation::SharedInSystemMemory,
|
||||
shared_in_system_memory(&device),
|
||||
),
|
||||
(Degradation::DeviceColorConversion, either),
|
||||
]);
|
||||
first.extend(clear_in_question(&device, true));
|
||||
assert_made_once(&messages, &NARROW_ROWS, &first);
|
||||
}
|
||||
layer_reported_nothing_at_all(&messages);
|
||||
|
||||
@@ -66,7 +66,7 @@ const CLEAR: [f64; 4] = [0.5, 0.0, 0.0, 1.0];
|
||||
/// The codes an 8-bit unorm channel's clear to `value` may store on a device whose clear is
|
||||
/// Metal's conversion (`metals`, `DriverFact::ColorClearIsMetals`) or not: Metal's, but at a half
|
||||
/// step on any other device either nearest code, which Vulkan leaves to the device (announced
|
||||
/// `device-color-conversion`: `degrade_notices::tie_cleared`).
|
||||
/// `device-color-conversion`: `degrade_notices::clear_in_question`).
|
||||
fn clear_codes(value: f64, metals: bool) -> Vec<u8> {
|
||||
let scaled = value.clamp(0.0, 1.0) * 255.0;
|
||||
let metal = scaled.round_ties_even() as u8;
|
||||
|
||||
@@ -511,7 +511,8 @@ fn color_fills_write_metal_s_texels() {
|
||||
/// own image, which makes no image, [`filled_whole`]); the device's clear may store another code
|
||||
/// in each (MoltenVK's of a 1 x 1 image and of a larger one), both held to Metal's alike. An
|
||||
/// `RGBA8Unorm_sRGB` fill announces `device-color-conversion` (its color channels inside
|
||||
/// `(0, 1)`), which the host's packing never does: the device's clear ran.
|
||||
/// `(0, 1)`), which the host's packing never does: the device's clear ran. How many fills
|
||||
/// announced `device-color-conversion` is printed (`COLOR-FILLS-ANNOUNCED`).
|
||||
#[test]
|
||||
fn plain_color_fills_are_the_device_s_clear() {
|
||||
let (messages, _cache, lane) = super::resolves::lane_with(|options| {
|
||||
@@ -530,6 +531,7 @@ fn plain_color_fills_are_the_device_s_clear() {
|
||||
.collect();
|
||||
let mut wrong = Vec::new();
|
||||
let mut srgb_converted = false;
|
||||
let (mut fills, mut announced) = (0usize, 0usize);
|
||||
for (raw, texel, _, _) in METAL {
|
||||
let pf = PixelFormat::try_from(raw).unwrap();
|
||||
let Some(metal) = filled(&lane, (pf, texel), &colors, Some(pf), |_| {}) else {
|
||||
@@ -559,6 +561,8 @@ fn plain_color_fills_are_the_device_s_clear() {
|
||||
for (i, (got, want)) in plain.chunks(bytes).zip(metal.chunks(bytes)).enumerate() {
|
||||
let converted = notes[i].contains(&Degradation::DeviceColorConversion);
|
||||
let nan = notes[i].contains(&Degradation::DeviceNanEncoding);
|
||||
fills += 1;
|
||||
announced += usize::from(converted);
|
||||
srgb_converted |= pf == PixelFormat::RGBA8UnormSRGB && converted;
|
||||
if got == want {
|
||||
continue;
|
||||
@@ -588,6 +592,10 @@ fn plain_color_fills_are_the_device_s_clear() {
|
||||
}
|
||||
}
|
||||
}
|
||||
println!(
|
||||
"COLOR-FILLS-ANNOUNCED {name}: {announced} of {fills} plain fills announced \
|
||||
device-color-conversion"
|
||||
);
|
||||
for line in &wrong {
|
||||
println!("COLOR-FILLS-DIFFERS {name}: {line}");
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
use super::degrade_notices::shared_in_system_memory;
|
||||
use super::degrade_notices::{
|
||||
assert_made_once, forced, made_render_kinds, resolve_kind, tie_cleared,
|
||||
assert_made_once, clear_in_question, forced, made_render_kinds, resolve_kind,
|
||||
};
|
||||
use super::resolves::{lane, quiet, Lane, MSAA, ONE};
|
||||
use crate::air_library::AirLibrary;
|
||||
@@ -455,7 +455,7 @@ fn a_state_color_draws_into_the_pass_color_at_its_place_in_the_record() {
|
||||
assert_eq!(left1, [0; 32], "color 1 on {name}");
|
||||
assert_eq!(rest0, rest1, "the clear on {name}");
|
||||
// Every pass clears to `CLEAR`, whose red 0.5 is a tie in an 8-bit channel.
|
||||
first.extend(tie_cleared(&lane.device, true));
|
||||
first.extend(clear_in_question(&lane.device, true));
|
||||
let notices = assert_made_once(&messages, &[], &first);
|
||||
assert!(!notices.contains_key(&KEPT_COLORS[0]), "on {name}");
|
||||
eprintln!("colors at their places in the record on {name}: Metal's bytes");
|
||||
@@ -493,7 +493,7 @@ fn an_uncovered_color_is_kept_where_metal_s_code_reads_the_attachment() {
|
||||
first.extend(made(&lane, &solid, (Fragment::Solid, &[RGBA8]), writes, 1));
|
||||
}
|
||||
// Every pass clears to `CLEAR`, whose red 0.5 is a tie in an 8-bit channel.
|
||||
first.extend(tie_cleared(&lane.device, true));
|
||||
first.extend(clear_in_question(&lane.device, true));
|
||||
let notices = assert_made_once(&messages, &[], &first);
|
||||
assert!(!notices.contains_key(&KEPT_COLORS[0]), "exact on {name}");
|
||||
kept(OVER);
|
||||
|
||||
@@ -2286,13 +2286,15 @@ pub(super) fn expected_once(
|
||||
}
|
||||
|
||||
/// The note a device announces at its first clear of a color attachment to a value at a rounding
|
||||
/// question, which the device converts its own way (`device-color-conversion`): such as 0.5 in an
|
||||
/// 8-bit unorm channel, 127.5 codes, a tie, or any value strictly between 0 and 1 in an sRGB
|
||||
/// one, whose encode Vulkan leaves to the device. A lane whose pipelines record the note has it
|
||||
/// already (`made_render_kinds`); MoltenVK's record none. Not where every such clear is by the load
|
||||
/// question, which the device converts its own way (`device-color-conversion`): any value whose
|
||||
/// scaled `float` lies off a whole code of a normalized channel, of which Vulkan lets the device
|
||||
/// store either of the two closest codes (0.5 in an 8-bit unorm channel, 127.5 codes, a tie; 0.2,
|
||||
/// 51.0000008 codes), or any value strictly between 0 and 1 in an sRGB one, whose encode Vulkan
|
||||
/// leaves to the device. A lane whose pipelines record the note has it already
|
||||
/// (`made_render_kinds`); MoltenVK's record none. Not where every such clear is by the load
|
||||
/// operation of an attachment its pass's render area covers (`covered`) on a driver whose load
|
||||
/// operation clears as Metal's does (`DriverFact::ColorClearIsMetals`).
|
||||
pub(super) fn tie_cleared(device: &Device, covered: bool) -> BTreeSet<Degradation> {
|
||||
pub(super) fn clear_in_question(device: &Device, covered: bool) -> BTreeSet<Degradation> {
|
||||
let metals = device
|
||||
.properties()
|
||||
.driver_facts
|
||||
|
||||
@@ -40,7 +40,7 @@ use super::clear_reach::{
|
||||
lane, lane_with, quiet, Draw, Lane, Shape, AREA, DRAWN, OLD, PLAIN, SIDE,
|
||||
};
|
||||
use super::degrade_notices::{
|
||||
assert_made_once, forced, resolve_kind, shared_in_system_memory, tie_cleared,
|
||||
assert_made_once, clear_in_question, forced, resolve_kind, shared_in_system_memory,
|
||||
};
|
||||
use super::{buffer_with, Messages, WAIT};
|
||||
use metal2vulkan::device::{DontCareColorPolicy, DriverFact, VkExtension};
|
||||
@@ -433,7 +433,7 @@ fn dont_care_stores_keep_the_texels_where_the_driver_stores_them_as_metal_s() {
|
||||
true,
|
||||
);
|
||||
// `color_clear_draw_small_area` clears over a render area smaller than its attachment.
|
||||
first.extend(tie_cleared(&lane.device, false));
|
||||
first.extend(clear_in_question(&lane.device, false));
|
||||
announces(&messages, "the kept passes", !metals(&lane), &first);
|
||||
// The default policy stores the colors as the driver stores them: no pass took a backing.
|
||||
assert_eq!(kept_texels(&lane), 0, "the passes through a backing");
|
||||
@@ -483,7 +483,7 @@ fn dont_care_stores_a_driver_may_store_otherwise_are_announced() {
|
||||
Degradation::RenderPassSplit,
|
||||
scope == BarrierScope::BUFFERS,
|
||||
)]));
|
||||
first.extend(tie_cleared(&lane.device, true));
|
||||
first.extend(clear_in_question(&lane.device, true));
|
||||
announces(&messages, case, true, &first);
|
||||
assert_eq!(
|
||||
kept_texels(&lane),
|
||||
@@ -516,7 +516,7 @@ fn dont_care_stores_a_driver_may_store_otherwise_are_announced() {
|
||||
}
|
||||
);
|
||||
let mut first = made(&lane, &[], &[RGBA8], true);
|
||||
first.extend(tie_cleared(&lane.device, true));
|
||||
first.extend(clear_in_question(&lane.device, true));
|
||||
announces(&messages, case, true, &first);
|
||||
quiet(lane, &messages);
|
||||
}
|
||||
@@ -553,7 +553,7 @@ fn dont_care_stores_a_driver_may_store_otherwise_are_announced() {
|
||||
}
|
||||
);
|
||||
let mut first = made(&lane, &[(&[RGBA8], (None, None), 4)], &[RGBA8], true);
|
||||
first.extend(tie_cleared(&lane.device, true));
|
||||
first.extend(clear_in_question(&lane.device, true));
|
||||
announces(&messages, case, true, &first);
|
||||
} else {
|
||||
eprintln!("{case} on {}: no sample locations", lane.device.name());
|
||||
@@ -650,7 +650,7 @@ fn exact_answers_keep_a_dont_care_color_s_earlier_texels_on_every_driver() {
|
||||
// `color_clear_draw_small_area` clears over a render area smaller than its attachment.
|
||||
let mut first = made(&lane, &[(&[RGBA8], (None, None), 1)], &[], true);
|
||||
first.insert(Degradation::RenderPassSplit);
|
||||
first.extend(tie_cleared(&lane.device, false));
|
||||
first.extend(clear_in_question(&lane.device, false));
|
||||
announces(&messages, "the kept colors", false, &first);
|
||||
quiet(lane, &messages);
|
||||
// The 4x colors, on a device of their own (the notice is once per device).
|
||||
@@ -690,7 +690,7 @@ fn exact_answers_keep_a_dont_care_color_s_earlier_texels_on_every_driver() {
|
||||
true,
|
||||
);
|
||||
// The 4x colors' clears cover their attachments.
|
||||
first.extend(tie_cleared(&lane.device, true));
|
||||
first.extend(clear_in_question(&lane.device, true));
|
||||
announces(&messages, "the kept 4x colors", !metals(&lane), &first);
|
||||
quiet(lane, &messages);
|
||||
}
|
||||
@@ -719,7 +719,7 @@ fn a_hidden_depth_announces_no_dont_care_store() {
|
||||
"hidden_depth: the draw passes the hidden depth of 1.0"
|
||||
);
|
||||
let mut first = made(&lane, &[(&[RGBA8], (None, None), 1)], &[], true);
|
||||
first.extend(tie_cleared(&lane.device, true));
|
||||
first.extend(clear_in_question(&lane.device, true));
|
||||
announces(&messages, "hidden_depth", false, &first);
|
||||
quiet(lane, &messages);
|
||||
}
|
||||
|
||||
@@ -742,10 +742,6 @@ pub(crate) const AMD_RADEON_780M: u32 = 0x15bf;
|
||||
/// The `deviceID` of the Radeon RX 7900 XTX (Navi 31) its rows were measured on, under RADV.
|
||||
pub(crate) const AMD_RX_7900_XTX: u32 = 0x744c;
|
||||
|
||||
/// The `deviceID` of the Radeon RX 550 (Polaris 12, Lexa Pro) its rows were measured on, under
|
||||
/// RADV.
|
||||
const AMD_RX_550: u32 = 0x699f;
|
||||
|
||||
/// The `deviceID` of the Intel UHD Graphics 770 of Raptor Lake-S (the committed capture
|
||||
/// `intel-uhd770-rpls-anv`).
|
||||
pub(crate) const INTEL_UHD_770_RPL_S: u32 = 0xa780;
|
||||
@@ -972,55 +968,25 @@ pub enum DriverFact {
|
||||
/// formats has on Apple's GPUs), so its average is Metal's resolve by construction. The
|
||||
/// runtime announces no `device-rounded-resolve` for such an attachment on a driver with it.
|
||||
ColorResolveAverageIsMetals,
|
||||
/// A render pass's `CLEAR` load operation of a colour attachment its render area covers
|
||||
/// stores the texel Metal's own `Clear` load action stores for the clear colour: MoltenVK
|
||||
/// hands the operation to Metal as the attachment's load action wherever the render area
|
||||
/// covers the attachment, the clear value's floats as Metal's clear colour, and Metal's
|
||||
/// conversion of a clear colour takes its `float` first. Vulkan leaves a clear's tie, its sRGB
|
||||
/// encode and a float's rounding to the device, so elsewhere a clear whose rounding is in
|
||||
/// question is announced (`device-color-conversion`, `render_pass.rs`); on a driver with it
|
||||
/// the runtime announces none for a clear by the load operation of an attachment the pass's
|
||||
/// render area covers, and announces it for the same clear made otherwise (before the pass,
|
||||
/// of an attachment the pass's first instance leaves out). Measured by
|
||||
/// A render pass's `CLEAR` load operation of a colour attachment its render area covers stores
|
||||
/// the texel Metal's own `Clear` load action stores for the clear colour: MoltenVK hands the
|
||||
/// operation to Metal as the attachment's load action wherever the render area covers the
|
||||
/// attachment, the clear value's floats as Metal's clear colour, and Metal's conversion of a
|
||||
/// clear colour takes its `float` first. Vulkan lets a clear store either of the two codes
|
||||
/// closest to a normalized channel's scaled value and leaves its sRGB encode and a float's
|
||||
/// rounding to the device, so elsewhere a clear whose rounding is in question (a normalized
|
||||
/// channel's value off a whole code among them) is announced (`device-color-conversion`,
|
||||
/// `render_pass.rs`); on a driver with it the runtime announces none for a clear by the load
|
||||
/// operation of an attachment the pass's render area covers, and announces it for the same
|
||||
/// clear made otherwise (before the pass, of an attachment the pass's first instance leaves
|
||||
/// out). Measured by
|
||||
/// `runtime_lane::renders::clears_are_the_device_s_conversion_of_the_clear_value`, which on
|
||||
/// such a driver also holds that the note stays unannounced: MoltenVK 1.4.2 on the M3 Max
|
||||
/// under macOS 27.0.1, each of the 71 colour clears Metal was measured with (ties of 8-bit,
|
||||
/// 10-bit and 16-bit unorm and snorm channels, sRGB channels, the packed 16-bit formats, half
|
||||
/// and small floats, shared exponents and NaNs among them) into a 1x1 attachment, its 11
|
||||
/// depth and 4 stencil clears beside them: all 86 texels Metal's bytes, none a code apart.
|
||||
/// such a driver also holds that the note stays unannounced: MoltenVK 1.4.2 on the M3 Max under
|
||||
/// macOS 27.0.1, each of the 71 colour clears Metal was measured with (ties of 8-bit, 10-bit
|
||||
/// and 16-bit unorm and snorm channels, sRGB channels, the packed 16-bit formats, half and
|
||||
/// small floats, shared exponents and NaNs among them) into a 1x1 attachment, its 11 depth and
|
||||
/// 4 stencil clears beside them: all 86 texels Metal's bytes, none a code apart.
|
||||
ColorClearIsMetals,
|
||||
/// A colour clear's normalized channel (a render pass's `CLEAR` load operation's, and
|
||||
/// `vkCmdClearColorImage`'s) stores either of the two codes nearest its scaled value, not
|
||||
/// always the nearest, as Vulkan allows ("returns one of the two unsigned binary integer values
|
||||
/// with exactly b bits which are closest to the floating-point value r. Implementations should
|
||||
/// round to nearest", Conversion from Floating-Point to Normalized Fixed-Point). On a driver
|
||||
/// with it the runtime announces `device-color-conversion` for a clear or a plain colour fill
|
||||
/// of a normalized channel whose scaled value is not a whole code, not only for one near a
|
||||
/// midpoint between two. Measured by
|
||||
/// `runtime_lane::color_fills::plain_color_fills_are_the_device_s_clear` (`vkCmdClearColorImage`
|
||||
/// of 762 colours into each of 70 formats) on the RTX 5080 Laptop GPU at 0b556ddfd6
|
||||
/// (2026-11-04): 352 fills stored 382 normalized channels a code from Metal's, each one of the
|
||||
/// two codes nearest the scaled value. The 8- and 16-bit unorm and snorm channels went toward
|
||||
/// zero (`R16Unorm`'s 0.001, 65.535 codes, stored 65; `R8Snorm`'s -0.5, -63.5, stored -63), the
|
||||
/// packed 16-bit and 10-bit channels and an sRGB format's alpha at times to the code above the
|
||||
/// nearest (`B5G6R5Unorm`'s 0.7529 red, 23.34 codes, stored 24). The load operation's tie of an
|
||||
/// 8-bit channel (127.5 codes) stores 127 there (`runtime_lane::clear_reach`, `sample_fills`).
|
||||
/// The same lane on ANV on the Iris Xe of RPL-P (`deviceID` 0xa7a0) at 6cb37f2c86
|
||||
/// (2026-11-08): beside ties stored either way (3,827 texels of 38 formats and placements), its
|
||||
/// fills of `RGB10A2Unorm` and `BGR10A2Unorm` stored the 10-bit channel of 0.8793 (899.51
|
||||
/// codes) as 899 where Metal stores 900, off a midpoint, into a texel of a level and a whole
|
||||
/// 1 x 1 slice alike. There the code a load operation's clear stores depends on the image: 0.1
|
||||
/// in an 8-bit unorm channel (25.5 codes) stores `0x1a` in a private optimal image and `0x19` in
|
||||
/// a linear image in place over host pages, or in a shadow listing an unsigned-integer view
|
||||
/// format (`runtime_lane::pitched_surfaces`, `no_copy_textures`). The same lane on RADV on the
|
||||
/// Radeon RX 550 (Polaris 12, `deviceID` 0x699f), Mesa 26.2.6, at 90c9936538 (2026-11-08):
|
||||
/// 93 fills of 11 8- and 10-bit unorm and snorm formats, in a texel of a level and a whole
|
||||
/// 1 x 1 slice alike, stored a channel's code below the nearest, its scaled value up to 0.37
|
||||
/// of a code past the midpoint (`RGB10A2Unorm`'s 0.549235, 561.87 codes, stored 561). Every
|
||||
/// channel of those fills is the colour first cut to a `half` toward zero, then rounded to
|
||||
/// nearest (0.549235 cuts to 0.548828, 561.45 codes), as its `R16Float` clears store it
|
||||
/// (0.001 as `0x1418`, where Metal stores `0x1419`).
|
||||
ColorClearTakesEitherCode,
|
||||
/// An optimal colour image may keep its compression state apart from the memory it is bound
|
||||
/// to, so a write through a buffer or another image over its bytes can leave its texels as
|
||||
/// they were. Vulkan leaves an optimal image's texels undefined after such a write; Metal's
|
||||
@@ -2098,20 +2064,6 @@ pub(crate) const MEASURED: &[Measured<DriverFact>] = &[
|
||||
device: Some(APPLE9),
|
||||
..moltenvk_on_apple(DriverFact::ColorClearIsMetals)
|
||||
},
|
||||
nvidia_on(
|
||||
DriverFact::ColorClearTakesEitherCode,
|
||||
NVIDIA_RTX_5080_LAPTOP,
|
||||
),
|
||||
mesa_on(
|
||||
DriverFact::ColorClearTakesEitherCode,
|
||||
DriverId::INTEL_OPEN_SOURCE_MESA,
|
||||
(INTEL_VENDOR_ID, INTEL_IRIS_XE_RPL_P),
|
||||
),
|
||||
mesa_on(
|
||||
DriverFact::ColorClearTakesEitherCode,
|
||||
DriverId::MESA_RADV,
|
||||
(AMD_VENDOR_ID, AMD_RX_550),
|
||||
),
|
||||
Measured {
|
||||
fact: DriverFact::CompressedImagesHideAliasedWrites,
|
||||
driver: DriverId::INTEL_OPEN_SOURCE_MESA,
|
||||
|
||||
@@ -381,7 +381,6 @@ const FRAGDEPTH: DriverFact = DriverFact::FragmentDepthStoresUnchanged;
|
||||
const APART: DriverFact = DriverFact::DepthStencilImagesLieApart;
|
||||
const AVERAGE: DriverFact = DriverFact::ColorResolveAverageIsMetals;
|
||||
const CLEAR: DriverFact = DriverFact::ColorClearIsMetals;
|
||||
const EITHER_CODE: DriverFact = DriverFact::ColorClearTakesEitherCode;
|
||||
const HIDE: DriverFact = DriverFact::CompressedImagesHideAliasedWrites;
|
||||
const HOST: DriverFact = DriverFact::HostTransferImagesKeepTheirBytes;
|
||||
const OPTIMIZED: DriverFact = DriverFact::DepthStencilImagesStayGpuOptimized;
|
||||
@@ -468,7 +467,6 @@ fn the_committed_profiles_drivers_have_their_facts() {
|
||||
(
|
||||
"intel-irisxe-rplp-anv",
|
||||
vec![
|
||||
EITHER_CODE,
|
||||
HIDE,
|
||||
HOST,
|
||||
FETCH,
|
||||
@@ -536,17 +534,7 @@ fn the_committed_profiles_drivers_have_their_facts() {
|
||||
(
|
||||
"nvidia-rtx5080-laptop",
|
||||
vec![
|
||||
ZERO,
|
||||
DENORMALS,
|
||||
EITHER_CODE,
|
||||
FETCH,
|
||||
SPLIT,
|
||||
PLANES,
|
||||
BC6H,
|
||||
BC7,
|
||||
ROWS,
|
||||
STALL,
|
||||
STALL_1024,
|
||||
ZERO, DENORMALS, FETCH, SPLIT, PLANES, BC6H, BC7, ROWS, STALL, STALL_1024,
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1245,21 +1245,22 @@ pub enum PrecisionNote {
|
||||
/// take the other code near a tie.
|
||||
///
|
||||
/// Also (the runtime announces it): a render pass clears a normalized, sRGB, packed 16-bit,
|
||||
/// half or small-float color attachment to a color whose conversion is in question. The
|
||||
/// device converts the clear color, which Vulkan asks it to round to nearest, leaving a tie,
|
||||
/// an sRGB encode and a float's rounding to it, where Metal's clear rounds each channel to
|
||||
/// nearest, a tie to even (a packed 16-bit channel through `half`) and truncates a small
|
||||
/// float's and a shared exponent's mantissas. A normalized channel lies within 1/1024 of a
|
||||
/// midpoint between two codes there, and stores one of the two. Not for a clear by the load
|
||||
/// operation of an attachment the pass's render area covers on a driver whose load operation
|
||||
/// clears as Metal's `Clear` load action does (`DriverFact::ColorClearIsMetals`: MoltenVK on
|
||||
/// the Apple9 GPUs under macOS 27, measured on the M3 Max).
|
||||
/// half or small-float color attachment to a color whose conversion is in question. The device
|
||||
/// converts the clear color, which Vulkan lets store either of the two codes closest to a
|
||||
/// normalized channel's scaled value (asking for the nearest), leaving an sRGB encode and a
|
||||
/// float's rounding to it, where Metal's clear rounds each channel to nearest, a tie to even (a
|
||||
/// packed 16-bit channel through `half`) and truncates a small float's and a shared exponent's
|
||||
/// mantissas. A normalized channel lies off a whole code there, and stores one of the two
|
||||
/// closest. Not for a clear by the load operation of an attachment the pass's render area
|
||||
/// covers on a driver whose load operation clears as Metal's `Clear` load action does
|
||||
/// (`DriverFact::ColorClearIsMetals`: MoltenVK on the Apple9 GPUs under macOS 27, measured on
|
||||
/// the M3 Max).
|
||||
///
|
||||
/// Also (the runtime announces it): a plain color fill (`fillTexture…color:` without
|
||||
/// `pixelFormat:`) of a texture of such a format the device renders, which the device's clear
|
||||
/// of the color writes, to a color whose conversion is in question against Metal's fill
|
||||
/// packing, which rounds a normalized tie half up and takes the sRGB code whose decoded value
|
||||
/// is nearest (a packed 16-bit channel's margin widened by a step through `half`).
|
||||
/// is nearest.
|
||||
///
|
||||
/// Validation derives no tolerance and no explanation from it: a difference stays a
|
||||
/// mismatch for review.
|
||||
|
||||
@@ -11751,7 +11751,6 @@ variant metal2vulkan-runtime::DriverFact::BlendlessColorAttachmentsWarn Blendles
|
||||
variant metal2vulkan-runtime::DriverFact::ChannelBlockDecodeIsMetals ChannelBlockDecodeIsMetals
|
||||
variant metal2vulkan-runtime::DriverFact::ColorBlockDecodeIsMetals ColorBlockDecodeIsMetals
|
||||
variant metal2vulkan-runtime::DriverFact::ColorClearIsMetals ColorClearIsMetals
|
||||
variant metal2vulkan-runtime::DriverFact::ColorClearTakesEitherCode ColorClearTakesEitherCode
|
||||
variant metal2vulkan-runtime::DriverFact::ColorImagesLieAsMetalHeapTextures ColorImagesLieAsMetalHeapTextures
|
||||
variant metal2vulkan-runtime::DriverFact::ColorResolveAverageIsMetals ColorResolveAverageIsMetals
|
||||
variant metal2vulkan-runtime::DriverFact::CompressedImagesHideAliasedWrites CompressedImagesHideAliasedWrites
|
||||
@@ -13047,7 +13046,6 @@ variant metal2vulkan::device::DriverFact::BlendlessColorAttachmentsWarn Blendles
|
||||
variant metal2vulkan::device::DriverFact::ChannelBlockDecodeIsMetals ChannelBlockDecodeIsMetals
|
||||
variant metal2vulkan::device::DriverFact::ColorBlockDecodeIsMetals ColorBlockDecodeIsMetals
|
||||
variant metal2vulkan::device::DriverFact::ColorClearIsMetals ColorClearIsMetals
|
||||
variant metal2vulkan::device::DriverFact::ColorClearTakesEitherCode ColorClearTakesEitherCode
|
||||
variant metal2vulkan::device::DriverFact::ColorImagesLieAsMetalHeapTextures ColorImagesLieAsMetalHeapTextures
|
||||
variant metal2vulkan::device::DriverFact::ColorResolveAverageIsMetals ColorResolveAverageIsMetals
|
||||
variant metal2vulkan::device::DriverFact::CompressedImagesHideAliasedWrites CompressedImagesHideAliasedWrites
|
||||
|
||||
|
Can't render this file because it is too large.
|
+17
-18
@@ -3780,29 +3780,28 @@ bound.
|
||||
the source. Another device
|
||||
is not bounded past one code (an NVIDIA RTX 5080 Laptop GPU's blend into an 8-bit sRGB attachment
|
||||
stored up to 11 codes from Metal's).
|
||||
Also a render pass's clear of a normalized, sRGB,
|
||||
packed 16-bit, half or small-float color attachment to a color whose conversion is in question
|
||||
(a normalized channel within 1/1024 of a midpoint between two codes, or anywhere off a whole code
|
||||
on a driver that takes either code nearest it, `DriverFact::ColorClearTakesEitherCode`: NVIDIA's
|
||||
on the RTX 5080 Laptop GPU, whose 8- and 16-bit channels' clears went toward zero, ANV on the
|
||||
Iris Xe of RPL-P, whose clear's code also depends on the image (a private optimal image's and one
|
||||
in place over host pages can stand a code apart), and RADV on the Radeon RX 550 (Polaris 12),
|
||||
whose 8- and 10-bit channels' clears take the colour cut to a `half` toward zero); an sRGB channel
|
||||
inside its range, a value the format does not hold exactly): the device converts the clear color,
|
||||
where Metal's clear rounds each channel to nearest, a tie to even, and truncates a small float's
|
||||
and a shared exponent's mantissas. Vulkan lets the device store either of the two codes nearest a
|
||||
normalized channel's scaled value, asking for the nearest. Not for a clear by the load operation of an attachment the pass's
|
||||
render area covers on a driver whose load operation clears as Metal's `Clear` load action does
|
||||
Also a render pass's clear of a normalized, sRGB, packed 16-bit, half or small-float color
|
||||
attachment to a color whose conversion is in question (a normalized channel's scaled value off a
|
||||
whole code, an sRGB channel inside its range, a value the format does not hold exactly): the
|
||||
device converts the clear color, where Metal's clear rounds each channel to nearest, a tie to
|
||||
even, and truncates a small float's and a shared exponent's mantissas. Vulkan lets the device
|
||||
store either of the two codes closest to a normalized channel's scaled value, asking for the
|
||||
nearest, and devices are measured to take the farther one off a midpoint: NVIDIA's on the RTX 5080
|
||||
Laptop GPU, whose 8- and 16-bit channels' clears went toward zero (`R16Unorm`'s 0.001, 65.535
|
||||
codes, stored 65), ANV on the Iris Xe of RPL-P, whose clear's code also depends on the image (a
|
||||
private optimal image's and one in place over host pages can stand a code apart), and RADV on the
|
||||
Radeon RX 550 (Polaris 12), whose 8- and 10-bit channels' clears take the colour cut to a `half`
|
||||
toward zero (`runtime_lane::color_fills`). So the rule is the spec's on every device, with one
|
||||
measured exception: not for a clear by the load operation of an attachment the pass's render area
|
||||
covers on a driver whose load operation clears as Metal's `Clear` load action does
|
||||
(`DriverFact::ColorClearIsMetals`: MoltenVK on the Apple9 GPUs under macOS 27, measured on the M3
|
||||
Max); a clear made before the pass, of an attachment its first instance leaves out, is announced
|
||||
there too. Also a plain color fill (`BlitCommandEncoder::fill_texture_color` without a pixel
|
||||
format) of a texture of such a format the device renders, which the device's clear of the color
|
||||
writes, to a color whose conversion is in question against Metal's fill packing (a normalized
|
||||
channel within 1/1024 of a midpoint between two codes, more for a packed 16-bit channel, or
|
||||
anywhere off a whole code on a driver with `DriverFact::ColorClearTakesEitherCode`; an sRGB
|
||||
channel inside its range, a value a half, small float or shared exponent does not hold exactly):
|
||||
Metal's fill rounds a tie half up and takes an sRGB channel's code whose decoded value is
|
||||
nearest.
|
||||
channel's scaled value off a whole code, an sRGB channel inside its range, a value a half, small
|
||||
float or shared exponent does not hold exactly): Metal's fill rounds a tie half up and takes an
|
||||
sRGB channel's code whose decoded value is nearest.
|
||||
- `metal2vulkan-degrade-device-interpolation` (precision). `PrecisionNote::DeviceInterpolation`: A
|
||||
fragment function reads a varying the device interpolates (`center_perspective`, `centroid`,
|
||||
`sample` or `no_perspective`, not `flat`) on a device not measured to interpolate as Metal does
|
||||
|
||||
Reference in new issue
Block a user