From 21d219b089eee91a1e7482d078aa2ec0724c567d Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 02:38:37 -0800 Subject: [PATCH] Runtime tests: every acquire of a Direct3D 11 plane read ahead of external_writes_done names the general layout every_device_reads_what_direct3d_11_drew_through_a_commit_ahead_of_external_writes_done (d68f165aae) now asserts what it printed: every acquire of a plane, the first included, names the general layout as its old layout (Work::acquired). Its byte checks stay. Why the structural check: no wrong picture was reproduced. On the UHD 630 the read committed ahead of the call matched picture 1 at 3072 of 3072 bytes at d68f165aae, the old code, whose acquires' old layouts were [undefined, undefined, general, general] (job m3-max-77834); at cd5d7df2f0 the same read matched 3072 of 3072 with [general, general, general, general] (job m3-max-77839). That driver kept the bytes through an acquire from the undefined layout, which Vulkan does not promise (section 12.5.1: "implying that the contents of the image subresource need not be preserved"), so the bytes cannot fail there and the old layouts are the failing proof. cd5d7df2f0 stays as the spec's form (sections 12.5.2, 12.10.1, Table 17). How it is verified: one job on the UHD 630 runs tests::d3d11 from two Windows cross-builds, the old code with this assertion (expected to fail on [0, 0, 1, 1]) and this commit (expected to pass); its job is reported with the lane's tip. --- crates/metal2vulkan-runtime/src/tests/d3d11.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/d3d11.rs b/crates/metal2vulkan-runtime/src/tests/d3d11.rs index 7083de5b2..61b08cf51 100644 --- a/crates/metal2vulkan-runtime/src/tests/d3d11.rs +++ b/crates/metal2vulkan-runtime/src/tests/d3d11.rs @@ -713,10 +713,14 @@ mod on_device { /// committed before `Surface::external_writes_done`: Direct3D 11 draws picture 1 and waits /// for its work, the planes are imported, and rt's read of them is committed and waited /// for with no `external_writes_done` before it; the consumer's call comes after it, and a - /// second read follows. Both reads are picture 1's exactly: what another API wrote before + /// second read follows. Both reads are picture 1's exactly, and every acquire, the first + /// included, names the general layout as its old layout: what another API wrote before /// the first acquire is kept whatever order the two calls arrived in. The first read's /// bytes that match picture 1 and that are zero, and each acquire's old layout - /// (`Work::acquired`, undefined 0, general 1), are printed. + /// (`Work::acquired`, undefined 0, general 1), are printed. The old layouts are the check + /// that holds on every driver: an acquire from the undefined layout need not keep the + /// bytes (section 12.5.1), and a driver may keep them anyway, as the UHD 630's did through + /// such an acquire (job m3-max-77834), so the bytes alone do not show the discard. #[test] fn every_device_reads_what_direct3d_11_drew_through_a_commit_ahead_of_external_writes_done() { @@ -758,6 +762,12 @@ mod on_device { after.0, None, "{name}: the read after external_writes_done is picture 1" ); + let general = vk::ImageLayout::GENERAL.as_raw(); + assert!( + !layouts.is_empty() && layouts.iter().all(|&layout| layout == general), + "{name}: every acquire of a plane, the first included, names the general \ + layout as its old layout: {layouts:?}" + ); }); }