From 714e21400a3e37d6ba3838e571f7c84f888e334d Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 00:36:14 -0800 Subject: [PATCH] harness: texture_read, a texel read out to a buffer over 2048x2048 in 16x16 threadgroups Each thread of a 2048x2048 grid, in threadgroups of 16x16, reads its texel of an RGBA16Float texture and stores it as a float4 at y * 2048 + x: the harness's own texels_out kernel as a timed workload, 64 MiB stored, the reference the texels themselves (sixteenths, exact in half). Why: on Intel's Windows driver (101.2145) for the UHD 630 this shape took 2.05 times the old runtime's time when rt ran it in 16x16 workgroups through its device address (7614 against 3711 us), and 0.98 in the tiles the landed rule gives a kernel that does not observe its partition and is not image-only. No harness row held it, so nothing in the matrix would catch a change that put such kernels back in a declared 16x16 workgroup. The kernel reads its grid position alone, so it takes the tiles; the matrix's 1.03 budget now guards it on every leg. Verified: see the jobs named in the landing message (clippy and the harness suite, and the row under both runtimes on the UHD 630 and the RX 550 at this commit). --- crates/metal2vulkan-harness/src/authored.rs | 41 ++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-harness/src/authored.rs b/crates/metal2vulkan-harness/src/authored.rs index f67f2c3d7..d134d684a 100644 --- a/crates/metal2vulkan-harness/src/authored.rs +++ b/crates/metal2vulkan-harness/src/authored.rs @@ -21,7 +21,7 @@ pub struct Workload { } /// The authored workloads. -pub const WORKLOADS: [Workload; 22] = [ +pub const WORKLOADS: [Workload; 23] = [ Workload { name: "bandwidth", plan: bandwidth, @@ -110,6 +110,10 @@ pub const WORKLOADS: [Workload; 22] = [ name: "constant_private", plan: constant_private, }, + Workload { + name: "texture_read", + plan: texture_read, + }, ]; /// A creation workload: objects of one kind made and released in turn (`Session::create`). @@ -1131,3 +1135,38 @@ fn constexpr_sampling() -> Plan { None, ) } + +/// A texture read out to a buffer: each thread of a 2048x2048 grid, in threadgroups of 16x16, +/// reads its texel of an `RGBA16Float` texture and stores it as a `float4` at `y * 2048 + x` +/// (`texels_out`), 64 MiB stored. The kernel reads its position in the grid and nothing of its +/// threadgroup, so a runtime may run it in workgroups of any shape; on some drivers a store per +/// thread through a device address takes twice as long in 16x16 workgroups as in wide ones. +fn texture_read() -> Plan { + const SIDE: u32 = 2048; + let texels = sixteenths(17, SIDE); + let stored = texels.iter().map(|texel| texel.to_bits()).collect(); + Plan { + name: "texture_read".to_owned(), + library: Source::Authored, + buffers: vec![unset(16 * u64::from(SIDE) * u64::from(SIDE))], + textures: vec![TexturePlan::rgba16_float(SIDE, SIDE, Some(texels))], + dispatches: vec![Dispatch { + blits: Vec::new(), + function: "texels_out".to_owned(), + linked: Vec::new(), + constants: Vec::new(), + bindings: vec![texture(0, 0), buffer(0, 0), bytes(1, word_bytes(&[SIDE]))], + grid: texel_grid(SIDE), + }], + expect: vec![Expect { + buffer: 0, + values: Values::Words(stored), + }], + expect_textures: Vec::new(), + outputs: Vec::new(), + per_command_buffer: None, + per_encoder: None, + commit_to_complete: false, + scaled: None, + } +}