From c10d191b46ae3d2488e494197ac65ac5155cf2c8 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 27 Nov 2026 03:31:09 -0800 Subject: [PATCH] Runtime tests: a render state carries DevicePointSize where its vertex function writes a size No runtime test asserted the point-size note on a render state: the old runtime's per-draw notice test went with it, and the translator's CPU tests check the note on compiled artifacts alone. The note is static, decided by the vertex function (a [[point_size]] output) and the device (its pointSizeRange's whole-pixel bound below Metal's 511) in the translator's stage I/O plan, never by a draw's primitive. The new device test asserts exactly that on every device of the cfg's kind: the state of rt6_point carries it where the device's bound is below 511, the state of rt6_full on no device. Verified: to run on lavapipe at the branch tip (a CPU job), reported to main with its job. --- crates/metal2vulkan-runtime/src/tests/mod.rs | 1 + .../src/tests/point_size_note.rs | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 crates/metal2vulkan-runtime/src/tests/point_size_note.rs diff --git a/crates/metal2vulkan-runtime/src/tests/mod.rs b/crates/metal2vulkan-runtime/src/tests/mod.rs index 6ad4627d2..f89a6d878 100644 --- a/crates/metal2vulkan-runtime/src/tests/mod.rs +++ b/crates/metal2vulkan-runtime/src/tests/mod.rs @@ -104,6 +104,7 @@ mod pixel_format_info; mod pixel_interlock; mod places; mod plane_parts; +mod point_size_note; mod pool_reach; mod present; mod private_arena; diff --git a/crates/metal2vulkan-runtime/src/tests/point_size_note.rs b/crates/metal2vulkan-runtime/src/tests/point_size_note.rs new file mode 100644 index 000000000..102a0f676 --- /dev/null +++ b/crates/metal2vulkan-runtime/src/tests/point_size_note.rs @@ -0,0 +1,60 @@ +//! `PrecisionNote::DevicePointSize` is a render state's static note, decided by its vertex +//! function and the device alone (the translator's stage I/O plan): a state whose vertex function +//! writes `[[point_size]]` carries it where the device's `pointSizeRange` ends below Metal's +//! largest point, 511 pixels (lavapipe's 256, ANV's 255), and not where it reaches it; a state +//! whose vertex function writes none carries it on no device. +//! +//! A device test, under a device cfg on every device of the cfg's kind. The functions are those of +//! the owned fixture `validation/fixtures/public/engine/rt6_render_state.ll`: `rt6_point`, a point +//! of 4 pixels that writes `[[point_size]]`, `rt6_full`, Metal's fullscreen triangle, and +//! `rt6_white`; `llvm-as` assembles them, and without it the test skips visibly. + +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +mod on_device { + use crate::tests::command::on_device::each_device; + use crate::tests::draw::on_device::{library, state}; + use crate::{ + ColorAttachmentDescriptor, FunctionDescriptor, PixelFormat, PrecisionNote, + RenderPipelineDescriptor, StageSource, + }; + use metal2vulkan_devtools::engine_dir; + + /// Metal's largest point, in pixels. + const METAL_LARGEST_POINT: u32 = 511; + + /// The state of `rt6_point` carries the note exactly where the device's largest point is below + /// Metal's, and the state of `rt6_full` on no device. + #[test] + fn every_device_notes_its_point_size_where_a_vertex_function_writes_one() { + let Some(library) = library(&engine_dir().join("rt6_render_state.ll")) else { + return; + }; + let descriptor = |vertex| { + let function = |name| { + StageSource::Function(FunctionDescriptor::new( + library.function(name).expect("the function"), + )) + }; + let mut d = RenderPipelineDescriptor::new(function(vertex)); + d.fragment = Some(function("rt6_white")); + d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm)); + d + }; + let (sized, plain) = (descriptor("rt6_point"), descriptor("rt6_full")); + each_device("point_size_note", |name, _, device| { + let largest = (device.core().translator.profile().limits()).max_point_size; + let noted = |d| { + (state(name, &device, d).precision_notes()) + .contains(&PrecisionNote::DevicePointSize) + }; + let below = largest < METAL_LARGEST_POINT; + assert_eq!( + noted(&sized), + below, + "{name}: a [[point_size]] on a device whose largest point is {largest}" + ); + assert!(!noted(&plain), "{name}: no [[point_size]]"); + println!("{name}: largest point {largest}, the [[point_size]] state noted: {below}"); + }); + } +}