From df4d351048bdf0a1c8f6dbb9b3ac19ee68041fe9 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 16:21:55 -0800 Subject: [PATCH] Runtime tests: the mesh cost rows time a one-group draw of an object state too On the RX 7900 XTX (RADV, Mesa 26.2.6, job 86024) a one-group mesh draw through the launcher took 63,560 ns against a one-triangle vertex draw's 7,920 ns, 8.0 times; on the RTX 3090 it took 0.84 times. The row cannot tell whether that cost is the launcher's shape or any task stage on that driver. mesh_costs_print_per_card now also times a one-group draw of a state with an object function (mesh_draws_object, 1 object thread), whose task stage is the guest's function, not the launcher: printed as "object 1 group N ns" beside the launcher's row. Nothing asserts on time. Verified: see the job named in the handover. --- .../src/tests/mesh_state.rs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/mesh_state.rs b/crates/metal2vulkan-runtime/src/tests/mesh_state.rs index 2b457dcf0..666f388ea 100644 --- a/crates/metal2vulkan-runtime/src/tests/mesh_state.rs +++ b/crates/metal2vulkan-runtime/src/tests/mesh_state.rs @@ -664,7 +664,9 @@ mod on_device { /// time: a state without an object function draws through its launcher's one task workgroup, /// and each stage's workgroup is the state's maximum `M`, the draw's threadgroup within it. /// Rows: a 1-group mesh-only draw against a 1-triangle vertex draw on the same kind of pass - /// (the launcher's fixed cost), 65,535 groups of 4 threads at the state's `M` and at `M` 4 + /// (the launcher's fixed cost), a 1-group draw of a state with an object function, whose task + /// stage is the function's (the cost of any task stage beside the launcher's own), 65,535 + /// groups of 4 threads at the state's `M` and at `M` 4 /// (the idle invocations' cost), and the time per group between 1 and 65,535 groups. Run /// under `METAL2VULKAN_TEST_UNVALIDATED=1`, once per card: `--run-ignored only`. #[cfg(m2v_gpu)] @@ -694,6 +696,16 @@ mod on_device { println!("mesh_costs: {name}: no mesh set; nothing timed"); return; }; + // A state with an object function, whose task stage is the function's, not the + // launcher's. + let mut d = MeshPipelineDescriptor::new(function(&draws, "mesh_draws_mesh")); + d.object = Some(function(&draws, "mesh_draws_object")); + d.fragment = Some(function(&draws, "mesh_draws_fragment")); + d.max_total_threads_per_object_threadgroup = Some(1); + for color in d.color_attachments.iter_mut().take(2) { + *color = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA32Uint)); + } + let object_state = made(name, &device, &d, listed).expect("an object state"); let colors = [0, 1].map(|_| { target( &device, @@ -730,13 +742,18 @@ mod on_device { encoder.draw_primitives(PrimitiveType::Triangle, 0, 3, 1, 0) }); let one = median_gpu_nanos(name, &queue, &mesh_pass, mesh(&at_m, 1)); + let object_one = median_gpu_nanos(name, &queue, &mesh_pass, |encoder| { + encoder.set_render_pipeline_state(&object_state)?; + encoder.set_object_bytes(&[0; 16], 0)?; + encoder.draw_mesh_threadgroups([1; 3], [1; 3], [1; 3]) + }); let many = median_gpu_nanos(name, &queue, &mesh_pass, mesh(&at_m, 65_535)); let many_at_4 = median_gpu_nanos(name, &queue, &mesh_pass, mesh(&at_4, 65_535)); let m = at_m.max_total_threads_per_mesh_threadgroup(); let per_group = many.saturating_sub(one) as f64 / 65_534.0; println!( "mesh_costs: {name}: vertex 1 triangle {triangle} ns; mesh-only 1 group {one} ns; \ - 65535 groups of 4 threads at M {m}: {many} ns, at M {}: {many_at_4} ns \ + object 1 group {object_one} ns; 65535 groups of 4 threads at M {m}: {many} ns, at M {}: {many_at_4} ns \ (x{:.2}); {per_group:.2} ns a group at M {m}", at_4.max_total_threads_per_mesh_threadgroup(), many as f64 / many_at_4.max(1) as f64,