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)
This commit is contained in:
Anees Iqbal committed 2026-12-03 17:05:44 -08:00
1 parent a5624a650f
commit a838dfb8db
2 files changed
+26 -4

No files matched your search

@@ -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:?}"
);
}
@@ -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!(