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.
This commit is contained in:
Anees Iqbal committed 2026-11-27 03:42:08 -08:00
1 parent 1a4310899a
commit c10d191b46
2 files changed
+61

No files matched your search

@@ -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;
@@ -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}");
});
}
}