From 0dc0ccfa953d33bc7080733c9e27363dc2d06f0b Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 19 Nov 2026 04:22:19 -0800 Subject: [PATCH] fixtures: ab_tier2, our MSL for argument buffers tier 2's GPU-written, Private and pointer-indexed argument buffers Three kernels for the runtime's device test of what tier 2 adds beside writable textures (a8r_buffers' a8r_held holds those): ab_copy copies a texture member device to device, ab_read reads texel (0, 0) through an argument buffer's member, and ab_indexed reads through element g of an array of argument buffers that a pointer member reaches. The companions follow from scripts/regen-air-fixtures on the M3. --- .../fixtures/public/engine/ab_tier2.metal | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/ab_tier2.metal diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/ab_tier2.metal b/crates/metal2vulkan-validation/fixtures/public/engine/ab_tier2.metal new file mode 100644 index 000000000..ea8aee4b7 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/ab_tier2.metal @@ -0,0 +1,33 @@ +// Owned fixture: what Metal's argument buffers tier 2 adds over tier 1 beside writable textures +// (a8r_buffers' a8r_held holds those), one kernel a piece, for the runtime's device test +// tests/argument_tier.rs: +// - ab_copy: the GPU writes an argument buffer, copying a texture member from one argument buffer +// to another, device to device, as tier 2's mutable argument buffers allow; +// - ab_read: reads texel (0, 0) through an argument buffer's texture member, whether the CPU wrote +// the buffer, the GPU wrote it (ab_copy) or it is a Private buffer a blit filled; +// - ab_indexed: thread g reads texel (0, 0) of the texture member of element g of an array of +// argument buffers that a pointer member of the bound one reaches (pointer indexing, and an +// argument buffer that points at others). +#include +using namespace metal; + +struct Held { + texture2d t [[id(0)]]; +}; + +kernel void ab_copy(device const Held *from [[buffer(0)]], device Held *to [[buffer(1)]]) { + to->t = from->t; +} + +kernel void ab_read(device const Held &held [[buffer(0)]], device float4 *out [[buffer(1)]]) { + out[0] = held.t.read(uint2(0)); +} + +struct Table { + device const Held *held [[id(0)]]; +}; + +kernel void ab_indexed(device const Table &table [[buffer(0)]], device float4 *out [[buffer(1)]], + uint g [[thread_position_in_grid]]) { + out[g] = table.held[g].t.read(uint2(0)); +}