diff --git a/crates/metal2vulkan-conformance/src/replay.rs b/crates/metal2vulkan-conformance/src/replay.rs index ede2c8cd5..2d593a861 100644 --- a/crates/metal2vulkan-conformance/src/replay.rs +++ b/crates/metal2vulkan-conformance/src/replay.rs @@ -460,8 +460,9 @@ 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`), and its choice of the pixel a width-1 line covers -/// at a vertex two pixels' diamonds share (`device-line-ties`). +/// alpha-to-coverage (`device-alpha-coverage`), its choice of the pixel a width-1 line covers +/// at a vertex two pixels' diamonds share (`device-line-ties`), and its rasterizer's snap of a +/// line band's corner half a step off its subpixel grid (`device-subpixel-snap`). /// /// **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`, @@ -515,6 +516,7 @@ pub const NATIVE_NOTES: &[metal2vulkan_runtime::Degradation] = { D::DeviceRoundedResolve, D::DeviceAlphaCoverage, D::DeviceLineTies, + D::DeviceSubpixelSnap, ] }; diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 7ae9cab57..7393c3adb 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -2185,6 +2185,15 @@ degradations! { "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 whose lines, or a triangle's edges in fill mode `Lines`, the runtime's band draws + /// (a width other than 1 the device's own lines do not draw as Metal's) on a driver not + /// measured to snap a vertex half a step off its 1/256-pixel subpixel grid as Metal snaps + /// a line's endpoint ([`metal2vulkan::device::DriverFact::SubpixelSnapIsMetals`], + /// `render/line_width.rs`): the band's corners, the endpoints offset by a multiple of 1/32 + /// pixel, are snapped by the device's rasterizer, where Metal snaps the endpoints up first, + /// so the two differ only where an endpoint lies half a step off the grid. + DeviceSubpixelSnap = "device-subpixel-snap", Precision, + "a line's band whose endpoint lies half a 1/256-pixel step off the subpixel grid is snapped the way the device rounds, where Metal rounds the endpoint up, so a pixel whose centre lies within that half step of the band's edge can be drawn, or left out, 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 fb49cb175..8459fbc7a 100644 --- a/crates/metal2vulkan-runtime/src/render/line_width.rs +++ b/crates/metal2vulkan-runtime/src/render/line_width.rs @@ -67,7 +67,12 @@ //! either way, and a triangle rotated faces alike. The band's depth bias is the device's, of //! each of its triangles' own slope and depths, where Metal's is the triangle's: a draw of //! edges as the band under a slope factor, or a constant factor over a float depth, is announced -//! (`Degradation::WideEdgeDepthBias`). +//! (`Degradation::WideEdgeDepthBias`). The band's corners, its endpoints offset by a multiple of +//! 1/32 pixel, are snapped by the device's rasterizer, where Metal snaps the endpoints first: the +//! two agree but for an endpoint half a 1/256-pixel step off the grid, which Metal rounds up and +//! the device as it rounds, so a draw the band draws on a driver not measured to round it up +//! (`DriverFact::SubpixelSnapIsMetals`) is announced (`Degradation::DeviceSubpixelSnap`, at each +//! draw). //! - **Nearest**: the device's own lines at the width nearest Metal's they draw (`w'`, 1/16 at 0, //! clamped into `lineWidthRange` where it enables `wideLines`, else 1), where neither route above //! draws `w'`, announced (`Degradation::LinesAtNearestWidth`, with why): a mesh draw's lines and @@ -392,8 +397,9 @@ 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, 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`. + /// nearest width, the device's lines at width 1 on a driver whose ties are not measured to be + /// Metal's, and the band on a driver whose subpixel snap is not measured to be Metal's, where + /// `announce`. pub(super) fn line_route( &self, call: &'static str, @@ -445,10 +451,14 @@ impl ShapeInputs<'_> { 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 { + let facts = &self.device.properties().driver_facts; + if announce && width_one && !facts.contains(&DriverFact::LineTiesAreMetals) { announce_line_ties(self.device, call); } + let banded = matches!(route, LineRoute::Band { .. }); + if announce && banded && !facts.contains(&DriverFact::SubpixelSnapIsMetals) { + announce_subpixel_snap(self.device, call); + } route } } @@ -467,6 +477,21 @@ fn announce_line_ties(device: &crate::Device, call: &'static str) { }); } +/// Announce `call`'s draw of lines or edges as bands on a driver not measured to snap a vertex +/// half a step off its subpixel grid as Metal snaps a line's endpoint (the module docs). +fn announce_subpixel_snap(device: &crate::Device, call: &'static str) { + device.degrade(Degradation::DeviceSubpixelSnap, || { + ( + format!("{call}: a draw of lines or edges as bands"), + "the device's driver is not measured to snap a vertex half a step off its \ + 1/256-pixel subpixel grid as Metal snaps a line's endpoint \ + (DriverFact::SubpixelSnapIsMetals): the band's corners are snapped by the device's \ + rasterizer, Metal's endpoints up before they are offset" + .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 217d92f4a..d6a8300bf 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::{LINE_TIES, WIDE_LINES}; +use super::line_widths::{LINE_TIES, SUBPIXEL_SNAP, WIDE_LINES}; use super::linear_attachments::{CHOSEN_COPIES, LINEAR_COPIES}; use super::memoryless::MEMORYLESS_TEXEL_BUFFERS; use super::mesh_draws::EMULATED_MESH; @@ -527,6 +527,7 @@ fn every_kind_has_a_site_a_lane_test_takes() { &PROVOKING, &WIDE_LINES, &LINE_TIES, + &SUBPIXEL_SNAP, &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 701cbee90..9e5f2ae17 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/line_widths.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/line_widths.rs @@ -38,7 +38,12 @@ //! 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, and lavapipe, Mesa 26.2.4, leaves out its first pixel) is announced -//! (`device-line-ties`) and left unchecked, and only there. +//! (`device-line-ties`) and left unchecked, and only there. A draw the band draws on a driver not +//! measured to snap a vertex half a step off its 1/256-pixel subpixel grid as Metal snaps a line's +//! endpoint (`DriverFact::SubpixelSnapIsMetals`: the RTX 5080 Laptop GPU and lavapipe draw the +//! lines offset from rows of centres by `(r - 32) / 512` a row lower) is announced +//! (`device-subpixel-snap`) and, where a vertex lies half a step off the grid, left unchecked; +//! every other such case is compared as any other. //! 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: @@ -81,6 +86,11 @@ pub(super) const WIDE_LINES: [Degradation; 3] = [ /// (`DriverFact::LineTiesAreMetals`). pub(super) const LINE_TIES: [Degradation; 1] = [Degradation::DeviceLineTies]; +/// The kind a draw the band draws announces on a driver not measured to snap a vertex half a step +/// off its 1/256-pixel subpixel grid as Metal snaps a line's endpoint +/// (`DriverFact::SubpixelSnapIsMetals`). +pub(super) const SUBPIXEL_SNAP: [Degradation; 1] = [Degradation::DeviceSubpixelSnap]; + /// What a lane's draw of the device's lines at width 1 announces on `device`: [`LINE_TIES`] where /// its driver lacks `DriverFact::LineTiesAreMetals`, nothing where it has it. pub(super) fn line_ties(device: &Device) -> &'static [Degradation] { @@ -203,6 +213,9 @@ struct LineFacts { exact_policy: bool, /// The driver breaks a tie at a vertex two pixels' diamonds share as Metal does. ties: bool, + /// The driver snaps a vertex half a step off its subpixel grid as Metal snaps a line's + /// endpoint. + snaps: bool, } impl LineFacts { @@ -220,6 +233,7 @@ impl LineFacts { parallelograms: limits.non_strict_wide_lines_use_parallelogram, exact_policy: compile.policy().wide_lines == WideLinePolicy::Exact, ties: (device.properties().driver_facts).contains(&DriverFact::LineTiesAreMetals), + snaps: (device.properties().driver_facts).contains(&DriverFact::SubpixelSnapIsMetals), } } @@ -1332,14 +1346,17 @@ struct Found { /// 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, + /// Cases the band drew with a vertex half a step off the subpixel grid on a driver whose snap + /// is not measured to be Metal's, announced (`device-subpixel-snap`): left unchecked. + snaps: usize, /// The device's lines. facts: Option, } /// The notices among `messages`' since the last take: the `DeviceWideLines`, -/// `LinesAtNearestWidth`, `WideEdgeDepthBias` and `DeviceLineTies` ones, and the reasons of the -/// nearest-width ones. -fn announced_lines(messages: &Messages) -> ([usize; 4], Vec) { +/// `LinesAtNearestWidth`, `WideEdgeDepthBias`, `DeviceLineTies` and `DeviceSubpixelSnap` ones, and +/// the reasons of the nearest-width ones. +fn announced_lines(messages: &Messages) -> ([usize; 5], Vec) { let notices = messages.take_notices(); let notices: Vec<_> = notices .iter() @@ -1352,7 +1369,28 @@ fn announced_lines(messages: &Messages) -> ([usize; 4], Vec) { .map(|n| n.reason.clone()) .collect(); let [wide, nearest, biased] = WIDE_LINES.map(count); - ([wide, nearest, biased, count(LINE_TIES[0])], reasons) + let [ties, snaps] = [LINE_TIES[0], SUBPIXEL_SNAP[0]].map(count); + ([wide, nearest, biased, ties, snaps], reasons) +} + +/// Whether a vertex of `shot`'s draws lies half a 1/256-pixel step off the subpixel grid, in the +/// framebuffer of `shot.side` pixels a side: an odd multiple of 1/512 pixel, where the band's +/// corners, snapped by the device's rasterizer, can lie a step from Metal's. +fn half_step_vertex(shot: &Shot) -> bool { + let half_side = shot.side as f32 / 2.0; + let half_step = |p: f32| { + let steps = p * 512.0; + steps == steps.round() && (steps as i64).rem_euclid(2) == 1 + }; + (shot.encoders.iter().flatten()).any(|draw| { + draw.points.iter().any(|&[x, y]| { + let [x, y] = match draw.clip { + true => [(x + 1.0) * half_side, (1.0 - y) * half_side], + false => [x, y], + }; + half_step(x) || half_step(y) + }) + }) } /// The draws of each route between two work counts: the band's, the device's lines' at Metal's @@ -1405,7 +1443,9 @@ fn printed(drawn: &Drawn, shot: &Shot, check: Check, blocks: &[String]) -> Vec Found { let cache = ScratchCache::new().unwrap(); let messages = Messages::default(); @@ -1413,7 +1453,10 @@ 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().chain(LINE_TIES).collect(); + options.announce_each = (WIDE_LINES.into_iter()) + .chain(LINE_TIES) + .chain(SUBPIXEL_SNAP) + .collect(); }) .unwrap(); let facts = LineFacts::of(&device); @@ -1472,7 +1515,8 @@ fn run(policy: DevicePolicy) -> Found { bands += band; device_lines += own; nearest_lines += nearest; - let ([announced, announced_nearest, biased, ties], _) = announced_lines(&messages); + let ([announced, announced_nearest, biased, ties, snaps], _) = + announced_lines(&messages); assert_eq!( band + own + nearest, shot.wide_draws(), @@ -1503,6 +1547,19 @@ fn run(policy: DevicePolicy) -> Found { found.ties += 1; continue; } + // The band's draws are announced on a driver without the fact, and nowhere else; a + // case of a vertex half a step off the grid is left unchecked there, every other one + // is Metal's. + if snaps > 0 { + assert!( + band > 0 && !facts.snaps, + "{name}: {key}: a subpixel snap notice" + ); + if half_step_vertex(shot) { + found.snaps += 1; + continue; + } + } if announced > 0 { found.announced += 1; continue; @@ -1578,8 +1635,9 @@ fn run(policy: DevicePolicy) -> Found { }; first_last.push((first, last)); } + // Their endpoints lie on the subpixel grid, so a band's snap notice leaves them Metal's. match announced_lines(&messages).0 { - [_, _, _, ties] if ties > 0 => { + [_, _, _, ties, _] if ties > 0 => { assert!( !facts.ties, "{name}: width {width}: line ties announced with the fact" @@ -1587,8 +1645,8 @@ fn run(policy: DevicePolicy) -> Found { found.ties += 1; continue; } - [0, 0, 0, _] => {} - [_, 0, _, _] => { + [0, 0, 0, _, _] => {} + [_, 0, _, _, _] => { found.announced += 1; continue; } @@ -1604,12 +1662,23 @@ fn run(policy: DevicePolicy) -> Found { } found.cases = cases.len() + quantized.len(); assert_eq!( - found.matched + found.announced + found.biased + found.nearest + found.ties, + found.matched + + found.announced + + found.biased + + found.nearest + + found.ties + + found.snaps, found.cases, "{found:?}" ); - // The width-1 cases announce the driver's ties exactly where it lacks the fact. + // The width-1 cases announce the driver's ties exactly where it lacks the fact, and the + // band's half-step cases its snap, where the band draws them. assert_eq!(found.ties > 0, !facts.ties, "{found:?}"); + if facts.snaps || !tessellates { + assert_eq!(found.snaps, 0, "{found:?}"); + } else { + assert!(found.snaps > 0, "{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)) @@ -1656,7 +1725,7 @@ fn wide_lines_draw_metal_s_parallelograms() { if facts.tessellates && found.announced == 0 { assert_eq!( found.matched, - found.cases - found.biased - found.ties, + found.cases - found.biased - found.ties - found.snaps, "{found:?}" ); assert!(found.edges_matched > 0, "{found:?}"); @@ -1678,7 +1747,7 @@ fn wide_lines_draw_metal_s_parallelograms_under_exact_answers() { assert_eq!((found.announced, found.nearest), (0, 0), "{found:?}"); assert_eq!( found.matched, - found.cases - found.biased - found.ties, + found.cases - found.biased - found.ties - found.snaps, "{found:?}" ); assert_eq!(found.edges_matched + found.biased, found.edges, "{found:?}"); diff --git a/crates/metal2vulkan/src/device/driver_facts.rs b/crates/metal2vulkan/src/device/driver_facts.rs index 634a9a793..73fb4ef29 100644 --- a/crates/metal2vulkan/src/device/driver_facts.rs +++ b/crates/metal2vulkan/src/device/driver_facts.rs @@ -1514,6 +1514,15 @@ pub enum DriverFact { /// 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, + /// The driver's rasterizer snaps a vertex half a step off its 1/256-pixel subpixel grid as + /// Metal snaps a line's endpoint there: up. The runtime's band of a line or an edge + /// (`pipeline::link::band`) places its corners at the endpoint offset by a multiple of 1/32 + /// pixel and leaves their snap to the rasterizer, where Metal snaps the endpoint first and + /// then offsets it: the two agree on the grid, and at a half step only where the driver + /// rounds it up. Vulkan leaves the rounding to the implementation. On a driver without it + /// the runtime announces `device-subpixel-snap` at each draw whose lines or edges the band + /// draws (`render/line_width.rs`). + SubpixelSnapIsMetals, } impl DriverFact { @@ -1994,6 +2003,14 @@ const DYNAMIC_RESTART_WARNING: DriverDiagnostic = DriverDiagnostic { /// such a vertex (3.5, 1.0), which Metal covers, so it does not take the fact. Every other driver /// is unmeasured. /// +/// `SubpixelSnapIsMetals`, measured by `runtime_lane::line_widths` (Metal's maps of the probe's +/// lines at widths 0 and 1/16 offset from rows and columns of centres by `(r - 32) / 512` pixel, +/// half of them half a step off the grid, which the band draws): MoltenVK 1.4.2 on the M3 Max +/// under macOS 27.0.1, every map Metal's. NVIDIA's 615.71.09 on the RTX 5080 Laptop GPU and +/// lavapipe (llvmpipe on LLVM 23.1.1, Mesa 26.2.4) both draw the rows' map a row lower than +/// Metal's (rows 18 to 49 where Metal draws 17 to 48), as a half step rounded down gives, so +/// neither takes the fact. 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` @@ -2385,6 +2402,10 @@ pub(crate) const MEASURED: &[Measured] = &[ device: Some(APPLE9), ..moltenvk_on_apple(DriverFact::LineTiesAreMetals) }, + Measured { + device: Some(APPLE9), + ..moltenvk_on_apple(DriverFact::SubpixelSnapIsMetals) + }, ]; /// Intel's `vendorID`. diff --git a/crates/metal2vulkan/src/device/tests/driver_facts.rs b/crates/metal2vulkan/src/device/tests/driver_facts.rs index 045cef771..29d51a3dd 100644 --- a/crates/metal2vulkan/src/device/tests/driver_facts.rs +++ b/crates/metal2vulkan/src/device/tests/driver_facts.rs @@ -417,6 +417,7 @@ const HEAP_COLORS: DriverFact = DriverFact::ColorImagesLieAsMetalHeapTextures; const HEAP_MULTISAMPLE_COLORS: DriverFact = DriverFact::MultisampleColorImagesLieAsMetalHeapTextures; const LINE_TIES: DriverFact = DriverFact::LineTiesAreMetals; +const SUBPIXEL_SNAP: DriverFact = DriverFact::SubpixelSnapIsMetals; /// 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. @@ -553,6 +554,7 @@ fn the_committed_profiles_drivers_have_their_facts() { HEAP_COLORS, HEAP_MULTISAMPLE_COLORS, LINE_TIES, + SUBPIXEL_SNAP, ], ), ("nvidia-pascal-linux", vec![DENORMALS, PLANES]), diff --git a/crates/metal2vulkan/src/pipeline/link/band.rs b/crates/metal2vulkan/src/pipeline/link/band.rs index 8424c1ba3..372c3c914 100644 --- a/crates/metal2vulkan/src/pipeline/link/band.rs +++ b/crates/metal2vulkan/src/pipeline/link/band.rs @@ -33,7 +33,9 @@ //! `(sx, sy)` the draw pushes beside `h` (`PushField::LineBand`, the stage's own push range). The //! rasterizer snaps each corner to the device's subpixel grid, where Metal snaps the endpoints to //! 1/256 pixel and then offsets them: on a grid of 1/256 the two agree, `h` being a multiple of -//! 1/32 pixel. +//! 1/32 pixel, but for an endpoint half a step off the grid, which Metal rounds up and the +//! device's rasterizer as it rounds (`DriverFact::SubpixelSnapIsMetals`; the runtime announces +//! the band's draws on a driver without it). //! //! A line's corner `(u, v)` lies at endpoint `u` (0 the first, 1 the second), offset by `(2v - 1) //! h`, so the two triangles cover the parallelogram exactly and wind alike in every direction diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index e965e4a87..ed4054ff3 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -5123,6 +5123,7 @@ macro-member metal2vulkan-runtime::Degradation::DeviceRoundedResolve DeviceRound macro-member metal2vulkan-runtime::Degradation::DeviceSampleLevel DeviceSampleLevel = "device-sample-level"; macro-member metal2vulkan-runtime::Degradation::DeviceSampling DeviceSampling = "device-sampling"; macro-member metal2vulkan-runtime::Degradation::DeviceSignedZeroInfNan DeviceSignedZeroInfNan = "device-signed-zero-inf-nan"; +macro-member metal2vulkan-runtime::Degradation::DeviceSubpixelSnap DeviceSubpixelSnap = "device-subpixel-snap", Precision, macro-member metal2vulkan-runtime::Degradation::DeviceTexelConversion DeviceTexelConversion = "device-texel-conversion"; macro-member metal2vulkan-runtime::Degradation::DeviceTranscendentals DeviceTranscendentals = "device-transcendentals"; macro-member metal2vulkan-runtime::Degradation::DeviceVertexConversion DeviceVertexConversion = "device-vertex-conversion"; @@ -11427,6 +11428,7 @@ variant metal2vulkan-runtime::DriverFact::ShadowCopyBackDispatchFaster ShadowCop variant metal2vulkan-runtime::DriverFact::ShadowCopyInDispatchFaster ShadowCopyInDispatchFaster variant metal2vulkan-runtime::DriverFact::SignallingSubmitsStallEvery1024 SignallingSubmitsStallEvery1024 variant metal2vulkan-runtime::DriverFact::SubmissionsWithoutSignalsMerge SubmissionsWithoutSignalsMerge +variant metal2vulkan-runtime::DriverFact::SubpixelSnapIsMetals SubpixelSnapIsMetals variant metal2vulkan-runtime::DriverFact::TileStoreIsMetals TileStoreIsMetals variant metal2vulkan-runtime::DriverFact::TimestampPoolsAreCounterSampleBuffers TimestampPoolsAreCounterSampleBuffers variant metal2vulkan-runtime::DriverFact::TimestampsWaitForEveryQueue TimestampsWaitForEveryQueue @@ -12680,6 +12682,7 @@ variant metal2vulkan::device::DriverFact::ShadowCopyBackDispatchFaster ShadowCop variant metal2vulkan::device::DriverFact::ShadowCopyInDispatchFaster ShadowCopyInDispatchFaster variant metal2vulkan::device::DriverFact::SignallingSubmitsStallEvery1024 SignallingSubmitsStallEvery1024 variant metal2vulkan::device::DriverFact::SubmissionsWithoutSignalsMerge SubmissionsWithoutSignalsMerge +variant metal2vulkan::device::DriverFact::SubpixelSnapIsMetals SubpixelSnapIsMetals variant metal2vulkan::device::DriverFact::TileStoreIsMetals TileStoreIsMetals variant metal2vulkan::device::DriverFact::TimestampPoolsAreCounterSampleBuffers TimestampPoolsAreCounterSampleBuffers variant metal2vulkan::device::DriverFact::TimestampsWaitForEveryQueue TimestampsWaitForEveryQueue diff --git a/docs/API.md b/docs/API.md index 53e47ba32..0b50fae60 100644 --- a/docs/API.md +++ b/docs/API.md @@ -2951,6 +2951,19 @@ bound. 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-device-subpixel-snap` (precision). `DeviceSubpixelSnap`: A draw whose + lines, or a triangle's edges in fill mode `Lines`, the runtime's band draws (a width other than 1 + that the device's own lines do not draw as Metal's), on a driver without + `DriverFact::SubpixelSnapIsMetals` (measured: MoltenVK on the M3 Max). Metal snaps a line's + endpoints to 1/256 pixel, a half step rounded up, then offsets them by half the width; the band + offsets them and leaves its corners' snap to the device's rasterizer, whose rounding of a half + step Vulkan leaves to the implementation. The two agree but where an endpoint lies half a step off + the grid (on NVIDIA's 615.71.09 on the RTX 5080 Laptop GPU and on lavapipe, lines offset from + rows of centres by odd multiples of 1/512 pixel draw a row lower, as a half step rounded down + gives). Cost: a line's band whose + endpoint lies half a 1/256-pixel step off the subpixel grid is snapped the way the device rounds, + where Metal rounds the endpoint up, so a pixel whose centre lies within that half step of the + band's edge can be drawn, or left out, 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 63c48684b..6c2627bfc 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -888,6 +888,15 @@ driver's. Each is open work. of the line lane's strip, which starts on such a vertex, so it announces too; RADV and ANV unrun, so announced there. +- **A line band's endpoint half a subpixel step off the grid off the M3 Max** + (`runtime_lane::line_widths`, the lines offset from rows and columns of centres by + `(r - 32) / 512`): the band leaves its corners' snap to 1/256 pixel to the device's rasterizer, + where Metal snaps the endpoints first, a half step rounded up. NVIDIA's 615.71.09 on the RTX 5080 + Laptop GPU and lavapipe (Mesa 26.2.4) draw those lines a row lower than Metal's, as a half step + rounded down gives. Vulkan leaves that rounding to the implementation. Announced (`device-subpixel-snap`) at + each band draw on a driver without `DriverFact::SubpixelSnapIsMetals` (MoltenVK on the M3 Max has + 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 without `wideLines`), announced `lines-at-nearest-width`: a mesh draw's lines and edges and a