From a838dfb8dbe8ea46f8b2b4857efb60af02b35414 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 14:07:26 -0800 Subject: [PATCH] Runtime tests: red, an indirect mesh draw of an object function is refused at the draw What: tests::mesh_draw::an_indirect_draw_of_an_object_function_is_refused_at_the_draw asks MeshCall::of for an indirect draw of a state with an object function and expects a Gap::Draw; the lavapipe draw test asks the encoder's draw_mesh_threadgroups_indirect of mesh_draws' object state and expects the same, before anything is recorded. Both fail at this commit: the draw records the object grid's indirect command from the GPU's counts, which is right only within the device's task limits. Why: the planner's step-4 ruling, red first: an indirect draw of an object pipeline is a typed refusal at the draw. The next commit makes it. Verified: JOBLINE (expected to fail here) --- .../metal2vulkan-runtime/src/tests/mesh_draw.rs | 15 ++++++++++++++- .../metal2vulkan-runtime/src/tests/mesh_state.rs | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/mesh_draw.rs b/crates/metal2vulkan-runtime/src/tests/mesh_draw.rs index 04ad36776..730e8b632 100644 --- a/crates/metal2vulkan-runtime/src/tests/mesh_draw.rs +++ b/crates/metal2vulkan-runtime/src/tests/mesh_draw.rs @@ -3,7 +3,7 @@ //! and an object grid's launch, whole within the task limits and in pieces past them, on the //! committed profiles' task grids. -use crate::error::{Error, Limit, Refusal, WorkGroupLimit}; +use crate::error::{Error, Gap, Limit, Refusal, WorkGroupLimit}; use crate::mesh_draw::{launch, records, Launch, MeshCall, MeshGrid, RECORD}; use crate::render::MeshThreads; use metal2vulkan::pipeline::{nonuniform_region_bytes, region_bytes, Stage}; @@ -253,3 +253,16 @@ fn an_object_grid_past_the_task_limits_runs_in_pieces() { assert_eq!(bytes[12..16], 65_535u32.to_le_bytes()); assert_eq!(bytes[16..20], 64u32.to_le_bytes()); } + +/// An indirect draw of a state with an object function is refused at the draw, before anything is +/// recorded: its object grid is the GPU's, and one past the device's task limits runs in pieces +/// whose count only the host's counts decide. +#[test] +fn an_indirect_draw_of_an_object_function_is_refused_at_the_draw() { + let object = threads([1024, 1024], [1024, 1024]); + let drawn = MeshCall::of(&object, MeshGrid::Indirect, [4, 1, 1], [4, 2, 1]); + assert!( + matches!(drawn, Err(Error::Unsupported(Gap::Draw { .. }))), + "{drawn:?}" + ); +} diff --git a/crates/metal2vulkan-runtime/src/tests/mesh_state.rs b/crates/metal2vulkan-runtime/src/tests/mesh_state.rs index d882c81ca..259bdc278 100644 --- a/crates/metal2vulkan-runtime/src/tests/mesh_state.rs +++ b/crates/metal2vulkan-runtime/src/tests/mesh_state.rs @@ -28,7 +28,7 @@ mod on_device { descriptor, examples, library, pass, read, run, state, target, Buffers, SIDE, }; use crate::{ - ClearColor, ColorAttachmentDescriptor, Device, Error, FunctionDescriptor, LoadAction, + ClearColor, ColorAttachmentDescriptor, Device, Error, FunctionDescriptor, Gap, LoadAction, MeshPipelineDescriptor, PixelFormat, PrimitiveType, Refusal, RenderPassDescriptor, RenderPipelineState, StageSource, Texture, TextureUsage, }; @@ -410,8 +410,8 @@ mod on_device { println!("mesh_draw: {case} {draw:?}: {} pixels drawn", want.len()); } // Refused before anything is recorded: a threadgroup of no threads, one past - // Metal's maximum (1024 for a function that states none), and a mesh draw of a - // vertex function's state. + // Metal's maximum (1024 for a function that states none), an indirect draw of a + // state with an object function, and a mesh draw of a vertex function's state. let colors = [0, 1].map(|_| { target( &device, @@ -424,6 +424,15 @@ mod on_device { .unwrap_or_else(|error| panic!("{case}: {error}")); (encoder.set_render_pipeline_state(&mesh_state)) .unwrap_or_else(|error| panic!("{case}: {error}")); + if object.is_some() { + let arguments = buffers.of(&device, &[1; 64]); + let drawn = + encoder.draw_mesh_threadgroups_indirect(&arguments, 0, [1; 3], [1; 3]); + assert!( + matches!(drawn, Err(Error::Unsupported(Gap::Draw { .. }))), + "{case}: an indirect draw with an object function: {drawn:?}" + ); + } for mesh_size in [[0, 1, 1], [1025, 1, 1], [32, 32, 2]] { let drawn = encoder.draw_mesh_threadgroups([1; 3], [1; 3], mesh_size); assert!(