rt test: an indirect execution through the words twin sizes its own shape (red)

An indirect command buffer's execution shape (indirect::Shape) holds its command layout and the
preprocess requirements vkGetGeneratedCommandsMemoryRequirementsEXT answers for the pipeline the
execution binds, and VUID-VkGeneratedCommandsInfoEXT-preprocessSize-11071 asks the execution's
preprocess size of the requirements of the matching inputs, the pipeline's among them. The shape
cache keys a shape on the content's id and the raster state, so an execution that runs a
content's words twin reuses the shape the plain pipeline of the same raster state sized.

The test makes a content whose fragment function reads a texture buffer (tb_word_fragment), for
indirect command buffers, takes its plain pipeline and its words twin at the default raster
state, and sizes a shape for each: it asks for two. Red here on a device with indirect command
buffers that holds a format as words (one shape); it skips, saying so, on a device without them.
This commit is contained in:
Anees Iqbal committed 2026-12-02 22:11:26 -08:00
1 parent a43933062e
commit 4f3bbdfa94
1 file changed
+65 -1
@@ -28,7 +28,9 @@
//!
//! A draw whose fragment function `tb_word_fragment` reads a texture buffer, of `R8Unorm` and of
//! `B5G6R5Unorm`, colours each pixel with the texel the CPU decodes, and runs the render content's
//! words twin exactly where the device holds the format as words.
//! words twin exactly where the device holds the format as words. On a device with indirect
//! command buffers, that content's plain pipeline and its twin each size an execution's shape of
//! their own.
//!
//! `llvm-as` assembles the fixture; without it the test skips visibly.
@@ -1003,4 +1005,66 @@ mod on_device {
}
});
}
/// An indirect command buffer's execution that runs a content's words twin sizes a shape of
/// its own: an execution's preprocess requirements are queried with the pipeline it binds
/// (`VUID-VkGeneratedCommandsInfoEXT-preprocessSize-11071`), and the twin is another pipeline
/// than the plain one under the same raster state.
#[test]
fn an_execution_through_the_twin_sizes_its_own_shape() {
use crate::indirect::CommandDraw;
use crate::render::Raster;
use crate::tests::draw::on_device::{descriptor, examples, library, state};
use ash::vk;
use metal2vulkan::pipeline::IndirectDrawLayout;
let (Some(examples), Some(words)) = (
examples(),
library(&engine_dir().join("tb_word_formats.ll")),
) else {
return;
};
let mut d = descriptor(&examples, "colored_fragment", PixelFormat::RGBA8Unorm);
d.fragment = Some(StageSource::Function(FunctionDescriptor::new(
words.function("tb_word_fragment").expect("the function"),
)));
d.support_indirect_command_buffers = true;
each_device("texture buffer words shapes", |name, _, device| {
let core = device.core();
let Some(indirect) = core.indirect.as_ref() else {
println!("texture buffer words shapes: {name}: no indirect command buffers");
return;
};
let state = state(name, &device, &d);
let compiled = &state.inner.compiled;
// A content has a words twin where the device holds some format as words.
if !compiled.binds_words(|_, _| true) {
println!("texture buffer words shapes: {name}: no words twin");
return;
}
let made = |words| {
let triangles = vk::PrimitiveTopology::TRIANGLE_LIST;
(compiled.pipeline(triangles, Raster::default(), words))
.unwrap_or_else(|error| panic!("{name}: {error}"))
};
let (plain, twin) = (made(false), made(true));
assert_ne!(plain, twin, "{name}: the twin is a pipeline of its own");
let layout = IndirectDrawLayout::new(0, 0).expect("a layout");
let before = indirect.held().1;
for pipeline in [plain, twin] {
(indirect.shape(
core,
(compiled, Raster::default(), pipeline),
(layout, CommandDraw::Plain),
1,
))
.unwrap_or_else(|error| panic!("{name}: {error}"));
}
let shapes = indirect.held().1 - before;
println!("texture buffer words shapes: {name}: plain and twin sized {shapes} shapes");
assert_eq!(
shapes, 2,
"{name}: a shape for the plain pipeline and one for the twin"
);
});
}
}