From 3aec33fe24eb3ddd90a832caadcb0ce512ebf1af Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 06:35:58 -0800 Subject: [PATCH] translator tests: the old render key's pin over a committed AIR fixture, the same on every host the_old_render_descriptor_key_keeps_its_value pinned the old runtime's key of a descriptor whose stages came from stage_io.ll, which the host's llvm-as assembles. The key hashes the AIR bytes (Library::from_air's content hash), and llvm-as writes other bytes of the same .ll in each LLVM release: 23.1.5 (gem10, um870, um790), 23.1.4 (ms01) and 23.1.1 (msi) gave three bitcode digests of stage_io.ll (30091f56, b2f50f5e, 66a891b8; jobs m3-max-46350 to 46354). The golden table already keys its rows on the fixtures' source text for this reason. So the pinned value was the value of the host that pinned it: under SEMANTICS_VERSION 2172 msi gives de648091 (the pin of 328da5cc5e, which passes there at 328da5cc5e, job m3-max-46369) and um790 gave a5ca094a (m3-max-46272); under 2173 um790 gives 5d351787 (the pin of 243145d7b1, job m3-max-46407) and msi gave dcc45dbd (m3-max-46286). No input of the key moved between 328da5cc5e and 3cbf244329, and no old-path output did, hash-level: the golden table (a hash per module) is unchanged between them and passes at 328da5cc5e (m3-max-46369). The descriptor's stages now come from the committed fbl_fetch_dual.air (fbd_vertex, fbd_dual_float), whose bytes are the same on every host, and the test pins those bytes' digest too, so a regenerated fixture fails with its own message instead of as a key change. Verified: - m3-max-46419 at this tree on b0175c0234 (um790, llvm-as 23.1.5): clippy of the translator, all targets and features, warnings denied; the test and golden_hashes_match_the_table pass. - That build's test archive, run with no build on msi (23.1.1, m3-max-46440), ms01 (23.1.4, m3-max-46441) and um870 (23.1.5, m3-max-46442): both tests pass on each, so the pinned key is the same under the three llvm-as releases. - Between b0175c0234 and this commit's parent, development changed no translator source, profile or engine fixture (the harness workloads fixture and the signature table only). Other pinned values computed from a tool's output at test time: none found. The golden table keys on source text and hashes the translator's output; the forwarding test's spirv-as comparison assembles at a fixed target environment with preserved ids and ignores the generator word; the other 16-digit and longer literals in the tests are digests of Metal's recorded answers or of data, not of assembled bytes. --- .../src/pipeline/compile/tests.rs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/metal2vulkan/src/pipeline/compile/tests.rs b/crates/metal2vulkan/src/pipeline/compile/tests.rs index fc7d72628..1434b075b 100644 --- a/crates/metal2vulkan/src/pipeline/compile/tests.rs +++ b/crates/metal2vulkan/src/pipeline/compile/tests.rs @@ -1247,18 +1247,26 @@ fn one_entry_set_specializes_a_sweeps_stages_once() { /// The old runtime's render descriptor key keeps its value: one known descriptor's key, pinned. /// The old runtime keeps answers under it in its cache directory, so a change of value is a /// change to the old runtime. +/// +/// The key hashes the stages' AIR bytes, so the descriptor's functions come from a committed +/// `.air` fixture, the same bytes on every host. An `.ll` fixture is assembled by the host's +/// `llvm-as`, whose bitcode differs between LLVM releases (23.1.1, 23.1.4 and 23.1.5 each write +/// other bytes of `stage_io.ll`), which made the pinned value depend on the host that ran it. #[test] fn the_old_render_descriptor_key_keeps_its_value() { - let Some(bc) = fixture("stage_io") else { - return; - }; + let path = engine_dir().join("fbl_fetch_dual.air"); + let bc = std::fs::read(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display())); + let bytes: String = sha256(&bc).iter().map(|b| format!("{b:02x}")).collect(); + assert_eq!( + bytes, "c77a9c963c06df07997811c3b73ded8a1dfdb40a79ae300f7d285ac01f89cbdd", + "the fixture's bytes, which the key hashes, changed: pin the key the new bytes give" + ); let lib = Library::from_air(&bc).expect("library"); let mut d = RenderPipelineDescriptor::new(StageSource::Function(FunctionDescriptor::new( - lib.function("stage_io_vertex_position").expect("vertex"), + lib.function("fbd_vertex").expect("vertex"), ))); d.fragment = Some(StageSource::Function(FunctionDescriptor::new( - lib.function("stage_io_fragment_primitive") - .expect("fragment"), + lib.function("fbd_dual_float").expect("fragment"), ))); d.color_attachments[0] = Some(ColorAttachmentDescriptor::new( metal::PixelFormat::RGBA8Unorm, @@ -1266,7 +1274,7 @@ fn the_old_render_descriptor_key_keeps_its_value() { let key = device("moltenvk-m3").render_descriptor_key(&d); let hex: String = key.digest().iter().map(|b| format!("{b:02x}")).collect(); assert_eq!( - hex, "5d351787c268658e80d5c79e3ba0de1e8bf7985ef70b91cf64bc64e3f2c032c7", + hex, "98be3009cdaf2256d5fa6c113aaaffad2406885c9d89430eef8b6f3ef6db39fa", "the old runtime's key of the descriptor" ); }