rt test: every device draws a vertex function that reads its amplification count (red)
A guest's model viewer leaves its window blank because the runtime refused its post-process states as RenderPipelineKind::DrawInput: their vertex functions read [[amplification_count]], and draws() named no such fact as supplied. The fact is RuntimeFact::AmplificationCount, as the typed draw input cause on steelbrain/fix-rt-causes printed over the walk's refused states (job m3-max-79894, XTX/RADV). The owned fixture engine/vertex_amplification.ll's amp_vertex_store reads [[amplification_count]] and [[amplification_id]] and stores both; drawn with rasterization disabled in a state whose maxVertexAmplificationCount is 1, each vertex must write (1 << 16) | 1 to word vid * 8. Red here: the state's creation refuses it as DrawInput.
This commit is contained in:
1 parent
06d2d22bf7
commit
8ad387cc0f
1 file changed
+49
@@ -2039,6 +2039,55 @@ pub(crate) mod on_device {
|
||||
});
|
||||
}
|
||||
|
||||
/// A vertex function reads `[[amplification_count]]` (the owned fixture
|
||||
/// `engine/vertex_amplification.ll`'s `amp_vertex_store`, its state's rasterization
|
||||
/// disabled): the runtime makes no state whose `maxVertexAmplificationCount` is above 1, and
|
||||
/// its render encoder sets no count, so every draw's count is Metal's default 1, the
|
||||
/// `SpecKey::AmplificationCount` constant the state's creation fixes. Vertex `vid` writes the
|
||||
/// count and its amplification id plus one, `(1 << 16) | 1`, to word `vid * 8`, and no other
|
||||
/// word is written.
|
||||
#[test]
|
||||
fn every_device_draws_a_vertex_function_that_reads_its_amplification_count() {
|
||||
let Some(engine) = library(&engine_dir().join("vertex_amplification.ll")) else {
|
||||
return;
|
||||
};
|
||||
let mut d = RenderPipelineDescriptor::new(StageSource::Function(FunctionDescriptor::new(
|
||||
(engine.function("amp_vertex_store")).expect("the function"),
|
||||
)));
|
||||
d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
d.rasterization_enabled = false;
|
||||
each_device("draw_amplification_count", |name, _, device| {
|
||||
let state = state(name, &device, &d);
|
||||
let mut buffers = Buffers::new(&device);
|
||||
let color = target(
|
||||
&device,
|
||||
PixelFormat::RGBA8Unorm,
|
||||
TextureUsage::RENDER_TARGET,
|
||||
);
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let out = buffers.of(&device, &[0u8; 32 * 4]);
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.render_command_encoder(&pass(&color, None)))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let draw = |result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
draw(encoder.set_render_pipeline_state(&state));
|
||||
draw(encoder.set_vertex_buffer(Some(&out), 0, 0));
|
||||
draw(encoder.draw_primitives(PrimitiveType::Triangle, 0, 3, 1, 0));
|
||||
encoder.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
let contents = out.contents().expect("a Shared buffer");
|
||||
// SAFETY: the buffer holds 32 words, which the finished draw wrote and whose writes
|
||||
// reach the host.
|
||||
let words = unsafe { std::slice::from_raw_parts(contents.as_ptr().cast::<u32>(), 32) };
|
||||
let mut want = [0u32; 32];
|
||||
for vid in 0..3 {
|
||||
want[vid * 8] = (1 << 16) | 1;
|
||||
}
|
||||
assert_eq!(words, want, "{name}: the words");
|
||||
println!("{name}: a vertex function read its amplification count, 1");
|
||||
});
|
||||
}
|
||||
|
||||
/// Each pixel samples its own texel through the constexpr sampler at the consumer's index.
|
||||
#[test]
|
||||
fn every_device_samples_a_texture_through_a_constexpr_sampler_in_a_draw() {
|
||||
|
||||
Reference in new issue
Block a user