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,