video lane: the plane placement probe also runs over Shared and Private buffers of the runtime's

A consumer may land decoded pictures in a buffer of the runtime's own and make its plane
textures over that. The probe now makes a Shared and a Private buffer and prints for each its
gpuAddress, its contents' offset into a page and the device's linear texture alignment of each
plane format, then where each plane texture lies (an image over the buffer's memory where no
shadow was counted).

Verified: cargo fmt; run on the 780M and the Iris Xe by the jobs that follow.
(cherry picked from commit 42d0566041fe3babb3a034c2780ec8896c9d7dbd)
This commit is contained in:
Anees Iqbal committed 2026-11-08 06:29:48 -08:00
1 parent 2225dac857
commit 26db05e481
1 file changed
+41 -1
@@ -772,7 +772,9 @@ fn parts(device: &Device, forms: &[Form], reads: metal2vulkan::device::YCbCrInPl
/// consumer's guest makes them: CoreVideo's 8-bit `420v` planes (`R8Unorm` 3840x2160 and `RG8Unorm`
/// 1920x1080, rows 3840 bytes apart) and 10-bit `x420` planes (`R16Unorm` and `RG16Unorm`, rows
/// 7680 apart), each at 0, 32 (CoreVideo's), 64, 128 and 256 bytes into its page, sampled alone
/// (`ShaderRead`) and written too (`ShaderRead | ShaderWrite`), over anonymous pages and, on Linux,
/// (`ShaderRead`) and written too (`ShaderRead | ShaderWrite`), over `Shared` and `Private` buffers
/// of the runtime's own (each with its address, its contents' offset into a page and the device's
/// linear texture alignments), anonymous pages and, on Linux,
/// a `memfd`'s pages with a dma-buf source and a guest RAM's (`HostRam` over a `memfd`, its source
/// asked for chunks as long as `udmabuf` takes, as the consumer's is), two buffers over it: the
/// placement the runtime answers before the making, and what the making took. Then the words of
@@ -783,6 +785,41 @@ fn video_plane_placements() {
let cache = ScratchCache::new().unwrap();
let messages = Messages::default();
let device = consumer_device(&messages, &cache);
for (options, what) in [
(
ResourceOptions::shared(),
"a Shared buffer of the runtime's",
),
(
ResourceOptions::private(),
"a Private buffer of the runtime's",
),
] {
let buffer = device.new_buffer(LEN as u64, options).unwrap();
let linear: Vec<String> = [
PixelFormat::R8Unorm,
PixelFormat::RG8Unorm,
PixelFormat::R16Unorm,
PixelFormat::RG16Unorm,
]
.into_iter()
.map(|pf| {
let alignment = device
.minimum_linear_texture_alignment_for_pixel_format(pf)
.unwrap();
format!("{pf:?} {alignment}")
})
.collect();
println!(
"VIDEO-PLACEMENT on {}: {what}: gpuAddress {:#x}, contents {:?}, linear texture \
alignments [{}]",
device.name(),
buffer.gpu_address().0,
buffer.contents().map(|at| at.as_ptr() as usize % 4096),
linear.join(", "),
);
probe_planes(&device, what, &buffer);
}
let anonymous = Surface::new(Pages::Anonymous, None, 0);
probe_planes(&device, "anonymous pages", &anonymous.buffer(&device));
drop(anonymous);
@@ -888,6 +925,9 @@ fn probe_planes(device: &Device, what: &str, buffer: &Buffer) {
Ok(_) if after.host_textures_in_place > before.host_textures_in_place => {
"in place".to_owned()
}
Ok(_) if after.shadowed_textures == before.shadowed_textures => {
"an image over the buffer's memory".to_owned()
}
Ok(_) => format!(
"a shadow ({} refused for the pitch)",
after.host_texture_shadows_refused_pitch