From d9e3324d4e9222b04fa84e30e232219e94af23fd Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 5 Nov 2026 03:06:20 -0800 Subject: [PATCH] Announce device-line-ties where a driver breaks a width-1 line's diamond-vertex tie unmeasured line_widths' wide_lines_draw_metal_s_parallelograms (and its exact-answers twin) failed on the RTX 5080 Laptop GPU at "LANE strip 1": the three-vertex strip at width 1, drawn in Bresenham's mode, put its diagonal a row higher than Metal's (row 9 columns 3-4 where Metal draws row 9 column 3 and row 10 columns 4-5, and so on, its last pixel at row 14 left out). The diagonal runs through vertices two pixels' diamonds share; Metal covers the lower pixel, and Vulkan's diamond is open, so the tie is the driver's with no Vulkan control over it. FAST-PATHS' known gap "One line texel at a diamond vertex on the RTX 5080" already said so for the conformance case primitive-type-restart-indices, but the runtime announced nothing: a near-equivalent drawn silently. - DriverFact::LineTiesAreMetals (appended): the driver's width-1 lines, as the runtime draws them, cover Metal's pixel at such a tie. Rows: MoltenVK on the M3 Max (APPLE9; its lines are Metal's own, the lane's maps pass there) and lavapipe (the conformance case: no texel differs on llvmpipe, LLVM 23.1.1, Mesa 26.2.4). Every other driver is unmeasured, so NVIDIA, RADV and ANV announce. - Degradation::DeviceLineTies ("device-line-ties", precision): announced by line_route at each draw the device's lines draw at width 1 (a plain-width draw of lines or edges, or the nearest width where that is 1) on a driver without the fact. Its catalogue entry in docs/API.md, FAST-PATHS' known gap (now "announced"), and the conformance suite's NATIVE_NOTES (the device's own answer) take it. - The lane announces it per draw, leaves such a case unchecked as it does the other announced routes, and holds it to the fact: never announced where the driver has it, announced in some case where it does not. degrade_notices lists LINE_TIES as its site. - driver_facts' profile test now expects the fact on the three lavapipe profiles and moltenvk-m3. Note sets: MoltenVK on the M3 Max and lavapipe take the fact, so neither announces anything new. api_signatures.tsv gains the three items (blessed); docs/REFUSALS.md regenerates unchanged. Not covered (left as it was): a pipeline whose multisample state keeps Bresenham's mode off (alpha to coverage, alpha to one, sample shading) draws the device's default mode, which the fact does not measure. The runtime's notice and line_width.rs are runtime pin inputs, so RUNTIME_VERSION and the pin are the orchestrator's to move. Verified: cargo fmt; scripts/api-signatures --check after --bless; refusal_surface.py. Build, clippy, the unit tests and the 5080 and M3 lane runs are pending (the lane fixes batch). (cherry picked from commit 75bb1413eacbf5ef3e1a3abed7ec97eff4b1c42d) --- crates/metal2vulkan-conformance/src/replay.rs | 4 +- .../metal2vulkan-runtime/src/degradation.rs | 11 +++ .../src/render/line_width.rs | 37 +++++++- .../src/runtime_lane/degrade_notices.rs | 3 +- .../src/runtime_lane/line_widths.rs | 85 ++++++++++++++----- .../metal2vulkan/src/device/driver_facts.rs | 26 ++++++ .../src/device/tests/driver_facts.rs | 14 ++- crates/metal2vulkan/tests/api_signatures.tsv | 3 + docs/API.md | 10 +++ docs/FAST-PATHS.md | 4 +- 10 files changed, 168 insertions(+), 29 deletions(-) diff --git a/crates/metal2vulkan-conformance/src/replay.rs b/crates/metal2vulkan-conformance/src/replay.rs index 030ad7299..ede2c8cd5 100644 --- a/crates/metal2vulkan-conformance/src/replay.rs +++ b/crates/metal2vulkan-conformance/src/replay.rs @@ -460,7 +460,8 @@ pub fn set_past_layout_notice() -> crate::allowance::Allowance { /// each step to `half`); /// - **resolves**: `device-rounded-resolve`; /// - **coverage**: the device's own conversion of a fragment's alpha to its coverage under -/// alpha-to-coverage (`device-alpha-coverage`). +/// alpha-to-coverage (`device-alpha-coverage`), and its choice of the pixel a width-1 line covers +/// at a vertex two pixels' diamonds share (`device-line-ties`). /// /// **What is not here**, and stays each case's to declare: a note of what the device **lacks** /// (`device-signed-zero-inf-nan`, `device-anisotropic-filter`, `device-point-size`, @@ -513,6 +514,7 @@ pub const NATIVE_NOTES: &[metal2vulkan_runtime::Degradation] = { D::ExtendedRangeFloatBlendSource, D::DeviceRoundedResolve, D::DeviceAlphaCoverage, + D::DeviceLineTies, ] }; diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 2966edb34..7ae9cab57 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -2174,6 +2174,17 @@ degradations! { "the edges' fragments are biased by another depth than Metal's, along the edges as \ their slope along them differs from the triangle's, and near a vertex of a smaller \ depth exponent than the triangle's largest by a smaller unit"; + /// A draw whose lines, or a triangle's edges in fill mode `Lines`, the device's own lines + /// draw at width 1 (Metal's default width, or the nearest width a device without + /// `wideLines` draws) on a driver not measured to break a tie at a vertex two pixels' + /// diamonds share as Metal does + /// ([`metal2vulkan::device::DriverFact::LineTiesAreMetals`], `render/line_width.rs`): a + /// line through such a vertex exits neither pixel's diamond, which Vulkan's rule leaves + /// open, so the driver chooses the pixel it covers, where Metal covers the lower one. + DeviceLineTies = "device-line-ties", Precision, + "a line through a vertex two pixels' diamonds share covers the pixel the device \ + chooses, where Metal covers the lower one, so such a pixel, and the rest of a line \ + that runs along such vertices, can lie a row or a column from Metal's"; /// A draw of lines, or an emulated mesh draw of lines, under Apple's last provoking vertex /// (`setProvokingVertexMode:` 1), of a pipeline state that reads it (a flat input, or a /// slice or viewport its vertex function selects), on a device without diff --git a/crates/metal2vulkan-runtime/src/render/line_width.rs b/crates/metal2vulkan-runtime/src/render/line_width.rs index 52d50e6c3..fb49cb175 100644 --- a/crates/metal2vulkan-runtime/src/render/line_width.rs +++ b/crates/metal2vulkan-runtime/src/render/line_width.rs @@ -9,7 +9,11 @@ //! - Metal draws `w' = floor(16 w) / 16`, clamped to `[0, 16]`: a negative width, `-0` and NaN //! draw as 0, and 16 and above, infinity among them, as 16 ([`LineWidth::of`]). //! - At `w' = 1` a line is Metal's ordinary line, the half-open diamond-exit rule (the runtime's -//! Bresenham lines). At every other `w'`, below 1 too, it is the parallelogram Vulkan's +//! Bresenham lines), which covers the lower of two pixels whose diamonds share a vertex the line +//! runs through. Vulkan's diamond is open, so that tie is the driver's: a draw the device's lines +//! draw at width 1 on a driver not measured to break it as Metal does +//! (`DriverFact::LineTiesAreMetals`) is announced (`Degradation::DeviceLineTies`, at each +//! draw). At every other `w'`, below 1 too, it is the parallelogram Vulkan's //! non-strict wide lines may be: its major axis the larger of the segment's framebuffer extents, //! x on a tie; its two minor-axis edges through the endpoints, each `w'` long and centred on //! its endpoint; its other two edges parallel to the segment; the ends not extended; a pixel @@ -102,7 +106,7 @@ use crate::degradation::Degradation; use crate::error::Error; use crate::pipeline::{FixedState, GraphicsState as DrawingState}; use metal2vulkan::bind::{DrawCall, RewriteProgram}; -use metal2vulkan::device::{DeviceProfile, VkFeature, WideLinePolicy}; +use metal2vulkan::device::{DeviceProfile, DriverFact, VkFeature, WideLinePolicy}; use metal2vulkan::error::Feature; use metal2vulkan::metal::state::DepthBias; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TriangleFillMode}; @@ -387,8 +391,9 @@ fn route( impl ShapeInputs<'_> { /// The route `call`'s draw of `pipeline` as `assembly` draws its lines by at the encoder's /// width (the module docs), of a draw that may draw a primitive where `primitives` - /// ([`draws_primitives`]); announcing a device line that differs from Metal's, and one at - /// the nearest width, where `announce`. + /// ([`draws_primitives`]); announcing a device line that differs from Metal's, one at the + /// nearest width, and the device's lines at width 1 on a driver whose ties are not measured to + /// be Metal's, where `announce`. pub(super) fn line_route( &self, call: &'static str, @@ -434,10 +439,34 @@ impl ShapeInputs<'_> { } _ => {} } + // The device's lines at width 1: Metal's plain lines, or the nearest width that is 1. + let width_one = match route { + LineRoute::Plain => drawn != Drawn::Nothing, + LineRoute::Nearest { width, .. } => width == 1.0, + LineRoute::Device { .. } | LineRoute::Band { .. } => false, + }; + let ties = (self.device.properties().driver_facts).contains(&DriverFact::LineTiesAreMetals); + if announce && width_one && !ties { + announce_line_ties(self.device, call); + } route } } +/// Announce `call`'s draw of the device's lines at width 1 on a driver not measured to break a +/// tie at a vertex two pixels' diamonds share as Metal does (the module docs). +fn announce_line_ties(device: &crate::Device, call: &'static str) { + device.degrade(Degradation::DeviceLineTies, || { + ( + format!("{call}: a draw of lines at width 1"), + "the device's driver is not measured to break a tie at a vertex two pixels' \ + diamonds share as Metal does (DriverFact::LineTiesAreMetals): Metal covers the lower \ + pixel, and Vulkan's open diamond leaves the choice to the driver" + .to_owned(), + ) + }); +} + /// Announce `call`'s draw of lines `w` pixels wide by the device's own lines, which differ from /// Metal's parallelogram there (the module docs). fn announce_device_lines(device: &crate::Device, call: &'static str, w: f32) { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index 6bc9e0350..217d92f4a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -187,7 +187,7 @@ use super::indirect_dispatches::INDIRECT_DISPATCHES; use super::indirect_executions::{NIL_OFFSETS, RELEASED_STATES}; use super::indirect_host_steps::HOST_STEPS; use super::kept_buffer_bytes::KEPT_BYTES; -use super::line_widths::WIDE_LINES; +use super::line_widths::{LINE_TIES, WIDE_LINES}; use super::linear_attachments::{CHOSEN_COPIES, LINEAR_COPIES}; use super::memoryless::MEMORYLESS_TEXEL_BUFFERS; use super::mesh_draws::EMULATED_MESH; @@ -526,6 +526,7 @@ fn every_kind_has_a_site_a_lane_test_takes() { &EMULATED_MESH, &PROVOKING, &WIDE_LINES, + &LINE_TIES, &CAPPED_ANISOTROPY, &NOT_MIPMAPPED_ANISOTROPY, &IN_PLACE, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/line_widths.rs b/crates/metal2vulkan-validation/src/runtime_lane/line_widths.rs index a1fe88087..05d33c948 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/line_widths.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/line_widths.rs @@ -34,7 +34,11 @@ //! (lines and edges without `tessellationShader` the device's lines do not draw, and those of a //! pipeline state whose band the translator refuses) runs the device's lines at the nearest width //! they draw, announced (`lines-at-nearest-width`) and counted at each draw; where that width is 1 -//! it is compared with Metal's map of the same geometry at width 1. Nothing is refused. A draw of +//! it is compared with Metal's map of the same geometry at width 1. A draw the device's lines draw +//! at width 1 on a driver not measured to break a tie at a vertex two pixels' diamonds share as +//! Metal does (`DriverFact::LineTiesAreMetals`: the RTX 5080 Laptop GPU draws the lane's strip's +//! diagonal a row higher) is announced (`device-line-ties`) and left unchecked, and only there. +//! Nothing is refused. A draw of //! no complete primitive (the consumer's triangles of 1 and 2 vertices, by vertices and by //! indices, under the last provoking vertex) draws nothing and takes no route. Not covered: //! Metal's width-1 lines on 4 samples (the probe's `msaa` width 1 and diagonal cases) where the @@ -45,7 +49,7 @@ use super::{ }; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; -use metal2vulkan::device::{DevicePolicy, VkFeature, WideLinePolicy}; +use metal2vulkan::device::{DevicePolicy, DriverFact, VkFeature, WideLinePolicy}; use metal2vulkan::metal::state::DepthStencilDescriptor; use metal2vulkan::metal::{BlendFactor, CompareFunction, CullMode, IndexType, TriangleFillMode}; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureType, TextureUsage, Winding}; @@ -71,6 +75,11 @@ pub(super) const WIDE_LINES: [Degradation; 3] = [ Degradation::WideEdgeDepthBias, ]; +/// The kind a draw the device's lines draw at width 1 announces on a driver not measured to break +/// a tie at a vertex two pixels' diamonds share as Metal does +/// (`DriverFact::LineTiesAreMetals`). +pub(super) const LINE_TIES: [Degradation; 1] = [Degradation::DeviceLineTies]; + /// Metal's maps the lane does not draw: its width-1 lines on 4 samples, which the device's lines /// draw as the runtime's every line, and its filled triangles' depth bias, the device's own. const NOT_DRAWN: [&str; 5] = [ @@ -182,6 +191,8 @@ struct LineFacts { strict: bool, parallelograms: bool, exact_policy: bool, + /// The driver breaks a tie at a vertex two pixels' diamonds share as Metal does. + ties: bool, } impl LineFacts { @@ -198,6 +209,7 @@ impl LineFacts { strict: limits.strict_lines, parallelograms: limits.non_strict_wide_lines_use_parallelogram, exact_policy: compile.policy().wide_lines == WideLinePolicy::Exact, + ties: (device.properties().driver_facts).contains(&DriverFact::LineTiesAreMetals), } } @@ -1307,13 +1319,17 @@ struct Found { /// Of them, the cases drawn at width 1 as Metal drew the same geometry at width 1, pixel for /// pixel. nearest_matched: usize, + /// Cases the device's lines drew at width 1 on a driver whose ties are not measured to be + /// Metal's, announced (`device-line-ties`): left unchecked. + ties: usize, /// The device's lines. facts: Option, } /// The notices among `messages`' since the last take: the `DeviceWideLines`, -/// `LinesAtNearestWidth` and `WideEdgeDepthBias` ones, and the reasons of the nearest-width ones. -fn announced_lines(messages: &Messages) -> ([usize; 3], Vec) { +/// `LinesAtNearestWidth`, `WideEdgeDepthBias` and `DeviceLineTies` ones, and the reasons of the +/// nearest-width ones. +fn announced_lines(messages: &Messages) -> ([usize; 4], Vec) { let notices = messages.take_notices(); let notices: Vec<_> = notices .iter() @@ -1325,7 +1341,8 @@ fn announced_lines(messages: &Messages) -> ([usize; 3], Vec) { .filter(|n| n.degradation == Degradation::LinesAtNearestWidth) .map(|n| n.reason.clone()) .collect(); - (WIDE_LINES.map(count), reasons) + let [wide, nearest, biased] = WIDE_LINES.map(count); + ([wide, nearest, biased, count(LINE_TIES[0])], reasons) } /// The draws of each route between two work counts: the band's, the device's lines' at Metal's @@ -1375,9 +1392,10 @@ fn printed(drawn: &Drawn, shot: &Shot, check: Check, blocks: &[String]) -> Vec Found { let cache = ScratchCache::new().unwrap(); let messages = Messages::default(); @@ -1385,7 +1403,7 @@ fn run(policy: DevicePolicy) -> Found { { let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| { options.policy = policy; - options.announce_each = WIDE_LINES.into_iter().collect(); + options.announce_each = WIDE_LINES.into_iter().chain(LINE_TIES).collect(); }) .unwrap(); let facts = LineFacts::of(&device); @@ -1444,7 +1462,7 @@ fn run(policy: DevicePolicy) -> Found { bands += band; device_lines += own; nearest_lines += nearest; - let ([announced, announced_nearest, biased], _) = announced_lines(&messages); + let ([announced, announced_nearest, biased, ties], _) = announced_lines(&messages); assert_eq!( band + own + nearest, shot.wide_draws(), @@ -1465,6 +1483,16 @@ fn run(policy: DevicePolicy) -> Found { "{name}: {key}: back-facing fragments" ); } + // Width-1 device lines whose ties the driver breaks are announced on a driver + // without the fact, and nowhere else. + if ties > 0 { + assert!( + !facts.ties, + "{name}: {key}: line ties announced with the fact" + ); + found.ties += 1; + continue; + } if announced > 0 { found.announced += 1; continue; @@ -1541,8 +1569,16 @@ fn run(policy: DevicePolicy) -> Found { first_last.push((first, last)); } match announced_lines(&messages).0 { - [0, 0, 0] => {} - [_, 0, _] => { + [_, _, _, ties] if ties > 0 => { + assert!( + !facts.ties, + "{name}: width {width}: line ties announced with the fact" + ); + found.ties += 1; + continue; + } + [0, 0, 0, _] => {} + [_, 0, _, _] => { found.announced += 1; continue; } @@ -1558,10 +1594,12 @@ fn run(policy: DevicePolicy) -> Found { } found.cases = cases.len() + quantized.len(); assert_eq!( - found.matched + found.announced + found.biased + found.nearest, + found.matched + found.announced + found.biased + found.nearest + found.ties, found.cases, "{found:?}" ); + // The width-1 cases announce the driver's ties exactly where it lacks the fact. + assert_eq!(found.ties > 0, !facts.ties, "{found:?}"); // Every measured map was drawn, but those the lane leaves to other lanes. let undrawn: Vec<&str> = (blocks.keys()) .filter(|key| !accounted.contains(*key)) @@ -1606,7 +1644,11 @@ fn wide_lines_draw_metal_s_parallelograms() { assert_eq!(found.nearest, 0, "{found:?}"); } if facts.tessellates && found.announced == 0 { - assert_eq!(found.matched, found.cases - found.biased, "{found:?}"); + assert_eq!( + found.matched, + found.cases - found.biased - found.ties, + "{found:?}" + ); assert!(found.edges_matched > 0, "{found:?}"); assert_eq!(found.edges_matched + found.biased, found.edges, "{found:?}"); } @@ -1624,7 +1666,11 @@ fn wide_lines_draw_metal_s_parallelograms_under_exact_answers() { let facts = found.facts.unwrap(); if facts.tessellates { assert_eq!((found.announced, found.nearest), (0, 0), "{found:?}"); - assert_eq!(found.matched, found.cases - found.biased, "{found:?}"); + assert_eq!( + found.matched, + found.cases - found.biased - found.ties, + "{found:?}" + ); assert_eq!(found.edges_matched + found.biased, found.edges, "{found:?}"); } } @@ -1687,7 +1733,7 @@ fn without_tessellation_lines_draw_at_the_nearest_width() { .draw(&shot) .unwrap_or_else(|e| panic!("{name}: width {width}: {e}")); let [band, own, nearest] = routed(&before, &lane.device.work_counts()); - let ([_, announced, _], _) = announced_lines(&messages); + let ([_, announced, _, _], _) = announced_lines(&messages); assert_eq!(band, 0, "{name}: a band without tessellationShader"); let drawable = facts.draws(width); let (expected_own, expected_nearest) = if width == 1.0 { @@ -1754,7 +1800,8 @@ fn a_draw_of_no_complete_primitive_draws_nothing() { "{name}: {shot:?}: drew" ); assert_eq!(routes, [0, 0, 0], "{name}: {shot:?}: a route of the width"); - assert_eq!(announced_lines(&messages).0, [0; 3], "{name}: {shot:?}"); + let [wide, nearest, biased, _] = announced_lines(&messages).0; + assert_eq!([wide, nearest, biased], [0; 3], "{name}: {shot:?}"); } } } @@ -1802,7 +1849,7 @@ fn edges_draw_as_bands_or_at_the_nearest_width() { let before = lane.device.work_counts(); let drawn = lane.draw(&shot).unwrap_or_else(|e| panic!("{what}: {e}")); let routes = routed(&before, &lane.device.work_counts()); - let ([differs, nearest, biased], _) = announced_lines(&messages); + let ([differs, nearest, biased, _], _) = announced_lines(&messages); assert_eq!(biased, 0, "{what}"); // The width drawn, where it is Metal's map's. let drawn_at = match (facts.device_route(width), tessellated) { @@ -1868,7 +1915,7 @@ fn a_refused_band_draws_at_the_nearest_width() { .draw(&shot) .unwrap_or_else(|e| panic!("{what}: refused: {e}")); let routes = routed(&before, &lane.device.work_counts()); - let ([_, announced, _], reasons) = announced_lines(&messages); + let ([_, announced, _, _], reasons) = announced_lines(&messages); assert_eq!((routes, announced), ([0, 0, 1], 1), "{what}"); assert!( drawn.ids.chunks(4).any(|t| t[3] != 0), diff --git a/crates/metal2vulkan/src/device/driver_facts.rs b/crates/metal2vulkan/src/device/driver_facts.rs index 510faecc5..861fc8e69 100644 --- a/crates/metal2vulkan/src/device/driver_facts.rs +++ b/crates/metal2vulkan/src/device/driver_facts.rs @@ -1506,6 +1506,14 @@ pub enum DriverFact { /// where Metal's layout is not the image's (a texture Metal keeps losslessly compressed, /// `heap-texture-lossless-layout`; a layout not measured). MultisampleColorImagesLieAsMetalHeapTextures, + /// The driver's lines of width 1, as the runtime draws them (Bresenham's mode, + /// `VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT`, where the pipeline's multisample state allows + /// it), cover the pixel Metal's do where a line runs through a vertex shared by two pixels' + /// diamonds: Metal covers the lower one. Vulkan's diamond is open, so a line that only touches + /// such a vertex exits neither diamond and the tie is the driver's, with no Vulkan control + /// over it. On a driver without it the runtime announces `device-line-ties` at each draw whose + /// lines or edges the device's lines draw at width 1 (`render/line_width.rs`). + LineTiesAreMetals, } impl DriverFact { @@ -1976,6 +1984,14 @@ const DYNAMIC_RESTART_WARNING: DriverDiagnostic = DriverDiagnostic { /// per sample or blitted, every sample there). It decides a notice, not an answer, so the M4 is /// not measured. Every other driver is unmeasured. /// +/// `LineTiesAreMetals`, measured by `runtime_lane::line_widths` (Metal's maps of the probe's +/// width-1 lines and strips, pixel for pixel) and the conformance case +/// `primitive-type-restart-indices` (a line through the shared vertex (3.5, 1.0)): MoltenVK 1.4.2 +/// on the M3 Max under macOS 27.0.1, whose lines are Metal's own, and lavapipe (llvmpipe on LLVM +/// 23.1.1, Mesa 26.2.4), which covers the lower pixel there as Metal does. NVIDIA's 615.71.09 on +/// the RTX 5080 Laptop GPU covers the upper one (the case's two texels, and the lane's +/// three-vertex strip at width 1, its diagonal a row higher). Every other driver is unmeasured. +/// /// MoltenVK 1.4.2 on the M3 Max under macOS 27.0.1 (2026-10-21, the runtime lanes in release /// builds under `--cfg m2v_gpu`, each fact taken): /// - Measured by the lane that measured its 1.4.1 row, which passed: `DepthImageKeepsDenormals` @@ -2363,6 +2379,16 @@ pub(crate) const MEASURED: &[Measured] = &[ device: Some(APPLE9), ..moltenvk_on_apple(DriverFact::MultisampleColorImagesLieAsMetalHeapTextures) }, + Measured { + device: Some(APPLE9), + ..moltenvk_on_apple(DriverFact::LineTiesAreMetals) + }, + Measured { + fact: DriverFact::LineTiesAreMetals, + driver: DriverId::MESA_LLVMPIPE, + vendor: None, + device: None, + }, ]; /// Intel's `vendorID`. diff --git a/crates/metal2vulkan/src/device/tests/driver_facts.rs b/crates/metal2vulkan/src/device/tests/driver_facts.rs index a1b495d73..344744413 100644 --- a/crates/metal2vulkan/src/device/tests/driver_facts.rs +++ b/crates/metal2vulkan/src/device/tests/driver_facts.rs @@ -416,6 +416,7 @@ const BLENDLESS: DriverFact = DriverFact::BlendlessColorAttachmentsWarn; const HEAP_COLORS: DriverFact = DriverFact::ColorImagesLieAsMetalHeapTextures; const HEAP_MULTISAMPLE_COLORS: DriverFact = DriverFact::MultisampleColorImagesLieAsMetalHeapTextures; +const LINE_TIES: DriverFact = DriverFact::LineTiesAreMetals; /// Each committed profile's driver has the runtime's driver facts its rows name, on its vendor and /// GPU, at its release as at any other. @@ -469,11 +470,15 @@ fn the_committed_profiles_drivers_have_their_facts() { ("amd-rdna3-radv", vec![ZERO]), ( "gate-lavapipe", - vec![DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H, MERGES, FOLLOWS], + vec![ + DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H, MERGES, FOLLOWS, LINE_TIES, + ], ), ( "gate-lavapipe-x86_64", - vec![DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H, MERGES, FOLLOWS], + vec![ + DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H, MERGES, FOLLOWS, LINE_TIES, + ], ), ( "intel-arl-anv", @@ -521,7 +526,9 @@ fn the_committed_profiles_drivers_have_their_facts() { ), ( "lavapipe", - vec![DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H, MERGES, FOLLOWS], + vec![ + DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H, MERGES, FOLLOWS, LINE_TIES, + ], ), ( "moltenvk-m3", @@ -551,6 +558,7 @@ fn the_committed_profiles_drivers_have_their_facts() { TILE_STORE, HEAP_COLORS, HEAP_MULTISAMPLE_COLORS, + LINE_TIES, ], ), ("nvidia-pascal-linux", vec![DENORMALS, PLANES]), diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index c3d659af6..e965e4a87 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -5113,6 +5113,7 @@ macro-member metal2vulkan-runtime::Degradation::DeviceDenormals DeviceDenormals macro-member metal2vulkan-runtime::Degradation::DeviceFilteredMipmaps DeviceFilteredMipmaps = "device-filtered-mipmaps", Precision, macro-member metal2vulkan-runtime::Degradation::DeviceInterpolation DeviceInterpolation = "device-interpolation"; macro-member metal2vulkan-runtime::Degradation::DeviceInterpolationOffset DeviceInterpolationOffset = "device-interpolation-offset"; +macro-member metal2vulkan-runtime::Degradation::DeviceLineTies DeviceLineTies = "device-line-ties", Precision, macro-member metal2vulkan-runtime::Degradation::DeviceMemoryOverflow DeviceMemoryOverflow = "device-memory-overflow", Performance, macro-member metal2vulkan-runtime::Degradation::DeviceNanEncoding DeviceNanEncoding = "device-nan-encoding"; macro-member metal2vulkan-runtime::Degradation::DevicePackConversion DevicePackConversion = "device-pack-conversion"; @@ -11411,6 +11412,7 @@ variant metal2vulkan-runtime::DriverFact::FragmentDepthStoresUnchanged FragmentD variant metal2vulkan-runtime::DriverFact::HostTransferImagesKeepTheirBytes HostTransferImagesKeepTheirBytes variant metal2vulkan-runtime::DriverFact::InterlockOrdersDraws InterlockOrdersDraws variant metal2vulkan-runtime::DriverFact::InterlockedPassSplitNoSlower InterlockedPassSplitNoSlower +variant metal2vulkan-runtime::DriverFact::LineTiesAreMetals LineTiesAreMetals variant metal2vulkan-runtime::DriverFact::MultisampleColorImagesLieAsMetalHeapTextures MultisampleColorImagesLieAsMetalHeapTextures variant metal2vulkan-runtime::DriverFact::MultisampledDepthFasterOutOfGeneral MultisampledDepthFasterOutOfGeneral variant metal2vulkan-runtime::DriverFact::PointerImportsFollowTheirAddress PointerImportsFollowTheirAddress @@ -12663,6 +12665,7 @@ variant metal2vulkan::device::DriverFact::FragmentDepthStoresUnchanged FragmentD variant metal2vulkan::device::DriverFact::HostTransferImagesKeepTheirBytes HostTransferImagesKeepTheirBytes variant metal2vulkan::device::DriverFact::InterlockOrdersDraws InterlockOrdersDraws variant metal2vulkan::device::DriverFact::InterlockedPassSplitNoSlower InterlockedPassSplitNoSlower +variant metal2vulkan::device::DriverFact::LineTiesAreMetals LineTiesAreMetals variant metal2vulkan::device::DriverFact::MultisampleColorImagesLieAsMetalHeapTextures MultisampleColorImagesLieAsMetalHeapTextures variant metal2vulkan::device::DriverFact::MultisampledDepthFasterOutOfGeneral MultisampledDepthFasterOutOfGeneral variant metal2vulkan::device::DriverFact::PointerImportsFollowTheirAddress PointerImportsFollowTheirAddress diff --git a/docs/API.md b/docs/API.md index b9e2f0d6c..47b0cd87b 100644 --- a/docs/API.md +++ b/docs/API.md @@ -2940,6 +2940,16 @@ bound. not announced. Cost: the edges' fragments are biased by another depth than Metal's, along the edges as their slope along them differs from the triangle's, and near a vertex of a smaller depth exponent than the triangle's largest by a smaller unit. +- `metal2vulkan-degrade-device-line-ties` (precision). `DeviceLineTies`: A draw whose lines, or a + triangle's edges in fill mode `Lines`, the device's own lines draw at width 1 (Metal's default + width, or the nearest width a device without `wideLines` draws), on a driver without + `DriverFact::LineTiesAreMetals` (measured: MoltenVK on the M3 Max, lavapipe). Metal rasterizes a + line by the diamond-exit rule and covers the lower of two pixels whose diamonds share a vertex + the line runs through; Vulkan's diamond is open, so neither pixel is required there and the + driver chooses (NVIDIA's 615.71.09 on the RTX 5080 Laptop GPU covers the upper one). Cost: a line + through a vertex two pixels' diamonds share covers the pixel the device chooses, where Metal + covers the lower one, so such a pixel, and the rest of a line that runs along such vertices, can + lie a row or a column from Metal's. - `metal2vulkan-degrade-provoking-vertex-lines` (precision). `ProvokingVertexLines`: A draw of lines, or an emulated mesh draw of lines, under Apple's last provoking vertex (`setProvokingVertexMode:` 1), of a pipeline state that reads it (a flat input, or a slice or diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 839a02b07..e5509384a 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -882,7 +882,9 @@ driver's. Each is open work. it: Metal draws the lower one and this driver draws the upper one. Vulkan's Bresenham diamond is open (`|p - x| + |q - y| < 0.5`), so a line that only touches a vertex exits no diamond and neither pixel is required; both choices conform and there is no Vulkan control over the tie, so - this is the driver's and not ours. RADV and ANV unrun. + this is the driver's and not ours. Announced (`device-line-ties`) at each draw the device's lines + draw at width 1 on a driver without `DriverFact::LineTiesAreMetals` (MoltenVK on the M3 Max and + lavapipe have it); RADV and ANV unrun, so announced there. - **Lines under Apple's `setLineWidth:` at a width other than 1 that neither route draws as Metal** (`render/line_width.rs`). Drawn by the device's own lines at the nearest width they draw (1 pixel