heap_textures: a kernel's write of an untracked heap's buffer, read through a texture there in one encoder

A lane for an image use over untracked bytes that a buffer wrote inside
one VkCommandBuffer, on a device where
DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer holds (the RTX
3090). The tracker's summaries leave untracked resources out, and
FoldOrder::byte_writes covers tracked ones only. Whether a write through an
untracked heap's buffer still splits a later image use in one encoder had
no device test.

The lane covers a Shared and a Private placement heap, both untracked,
each with a 64x64 RGBA8Unorm storage texture at offset 0 and a buffer of
its answered size there. A blit writes the texture's pattern. Then one
serial compute encoder runs scale_and_offset into the buffer (1e6 + i into
every word), a memory barrier of buffers and textures, and rows_read of
the texture. Every texel must hold a word of the write (top byte 0x49), and
none the pattern (alpha 0xCD). The write's dispatch names the buffer by its
binding, so where the fact holds the read is expected to split at aliases
(command_buffers_split_at_aliases > 0), and elsewhere none splits.

A write the dispatch's uses do not name (through an address or an argument
buffer, its buffer resident) is not covered. command_observing notes and
checks the uses alone, not the resident set, and no owned fixture stores
through a loaded pointer yet.

With e58ce1e02f: heap_textures: the untracked lane's write through an address, its buffer resident

The untracked-heap lane wrote the heap's buffer through a binding only. A
kernel that stores through the address its argument buffer holds, the
encoder making the buffer resident for writing (useResource:usage:),
writes the same bytes as the resident set's use: the plan lists the
resident buffer as a write of its whole range (bind::plan::slots::
used_uses), and the encoder notes the command's uses, resident ones
first, before the next command's image use meets them
(alias_split::AliasWrites). This lane checks that on a device where
DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer holds (the RTX
3090) the read through the texture still takes the write, in a new
VkCommandBuffer, and that elsewhere none splits.

The kernel is an owned fixture, examples/argument_stores.metal
(store_through_argument: base + i into word i of the buffer whose address
buffer(0) holds), compiled by scripts/regen-air-fixtures --dir examples
argument_stores (Metal 32023.922, LLVM 21.1.8).

The two forms share one body (untracked_write_then_texture_read); the
HEAPTEX untracked lines name the form.

Verified: cargo fmt; the regen script's own check (metal-as of the typed
text disassembles to the .ll, llvm-as 21 accepts it). Clippy and the
device runs follow.

Compiled in m3-max-31391 (msi: clippy plain and m2v_gpu, validation archive). Test-only.
This commit is contained in:
Anees Iqbal committed 2026-11-14 21:51:07 -08:00
1 parent 96a504a130
commit 86d50ef800
5 files changed
+357 -2

No files matched your search

@@ -5,6 +5,7 @@ llvm: 21 (pinned: llvm-dis writes each .ll, and llvm-as must accept it)
llvm-dis: Homebrew LLVM version 21.1.8
llvm-as: Homebrew LLVM version 21.1.8
# Fixtures compiled by another Metal toolchain (regen-air-fixtures.sh <name>...).
fixture argument_stores: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture fixed_indices: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture heap_draws: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture texel_rows: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
@@ -0,0 +1,70 @@
; Generated by scripts/regen-air-fixtures from argument_stores.metal (typed pointers; xcrun metal-as reassembles it). Do not edit.
; ModuleID = '-'
source_filename = "-"
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
target triple = "air64_v28-apple-macosx26.0.0"
%struct.Target = type { float addrspace(1)* }
; Function Attrs: mustprogress nofree nosync nounwind willreturn writeonly
define void @store_through_argument(%struct.Target addrspace(2)* nocapture noundef readonly align 8 dereferenceable(8) "air-buffer-no-alias" %0, float addrspace(2)* nocapture noundef readonly align 4 dereferenceable(4) "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #0 {
%4 = load float, float addrspace(2)* %1, align 4, !tbaa !23, !alias.scope !27, !noalias !30
%5 = tail call fast float @air.convert.f.f32.u.i32(i32 %2) #2
%6 = fadd fast float %5, %4
%7 = getelementptr inbounds %struct.Target, %struct.Target addrspace(2)* %0, i64 0, i32 0
%8 = load float addrspace(1)*, float addrspace(1)* addrspace(2)* %7, align 8, !tbaa !32, !alias.scope !30, !noalias !27
%9 = zext i32 %2 to i64
%10 = getelementptr inbounds float, float addrspace(1)* %8, i64 %9
store float %6, float addrspace(1)* %10, align 4, !tbaa !23
ret void
}
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #1
attributes #0 = { mustprogress nofree nosync nounwind willreturn writeonly "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" }
attributes #1 = { mustprogress nofree nosync nounwind readnone willreturn }
attributes #2 = { nounwind readnone willreturn }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!air.kernel = !{!9}
!air.compile_options = !{!17, !18, !19}
!llvm.ident = !{!20}
!air.version = !{!21}
!air.language_version = !{!22}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 7, !"frame-pointer", i32 2}
!3 = !{i32 7, !"air.max_device_buffers", i32 31}
!4 = !{i32 7, !"air.max_constant_buffers", i32 31}
!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31}
!6 = !{i32 7, !"air.max_textures", i32 128}
!7 = !{i32 7, !"air.max_read_write_textures", i32 8}
!8 = !{i32 7, !"air.max_samplers", i32 16}
!9 = !{void (%struct.Target addrspace(2)*, float addrspace(2)*, i32)* @store_through_argument, !10, !11}
!10 = !{}
!11 = !{!12, !15, !16}
!12 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !13, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"Target", !"air.arg_name", !"target"}
!13 = !{i32 0, i32 8, i32 0, !"float", !"words", !"air.indirect_argument", !14}
!14 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"float", !"air.arg_name", !"words"}
!15 = !{i32 1, !"air.buffer", !"air.buffer_size", i32 4, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"float", !"air.arg_name", !"base"}
!16 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"index"}
!17 = !{!"air.compile.denorms_disable"}
!18 = !{!"air.compile.fast_math_enable"}
!19 = !{!"air.compile.framebuffer_fetch_enable"}
!20 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
!21 = !{i32 2, i32 8, i32 0}
!22 = !{!"Metal", i32 4, i32 0, i32 0}
!23 = !{!24, !24, i64 0}
!24 = !{!"float", !25, i64 0}
!25 = !{!"omnipotent char", !26, i64 0}
!26 = !{!"Simple C++ TBAA"}
!27 = !{!28}
!28 = distinct !{!28, !29, !"air-alias-scope-arg(1)"}
!29 = distinct !{!29, !"air-alias-scopes(store_through_argument)"}
!30 = !{!31}
!31 = distinct !{!31, !29, !"air-alias-scope-arg(0)"}
!32 = !{!33, !34, i64 0}
!33 = !{!"_ZTS6Target", !34, i64 0}
!34 = !{!"any pointer", !25, i64 0}
@@ -0,0 +1,70 @@
; Generated by scripts/regen-air-fixtures from argument_stores.metal (llvm-dis of argument_stores.air). Do not edit.
; ModuleID = '<stdin>'
source_filename = "-"
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
target triple = "air64_v28-apple-macosx26.0.0"
%struct.Target = type { ptr addrspace(1) }
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
define void @store_through_argument(ptr addrspace(2) noundef readonly align 8 captures(none) dereferenceable(8) "air-buffer-no-alias" %0, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(4) "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #0 {
%4 = load float, ptr addrspace(2) %1, align 4, !tbaa !23, !alias.scope !27, !noalias !30
%5 = tail call fast float @air.convert.f.f32.u.i32(i32 %2) #2
%6 = fadd fast float %5, %4
%7 = getelementptr inbounds %struct.Target, ptr addrspace(2) %0, i64 0, i32 0
%8 = load ptr addrspace(1), ptr addrspace(2) %7, align 8, !tbaa !32, !alias.scope !30, !noalias !27
%9 = zext i32 %2 to i64
%10 = getelementptr inbounds float, ptr addrspace(1) %8, i64 %9
store float %6, ptr addrspace(1) %10, align 4, !tbaa !23
ret void
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #1
attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(write) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" }
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) }
attributes #2 = { nounwind willreturn memory(none) }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!air.kernel = !{!9}
!air.compile_options = !{!17, !18, !19}
!llvm.ident = !{!20}
!air.version = !{!21}
!air.language_version = !{!22}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 7, !"frame-pointer", i32 2}
!3 = !{i32 7, !"air.max_device_buffers", i32 31}
!4 = !{i32 7, !"air.max_constant_buffers", i32 31}
!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31}
!6 = !{i32 7, !"air.max_textures", i32 128}
!7 = !{i32 7, !"air.max_read_write_textures", i32 8}
!8 = !{i32 7, !"air.max_samplers", i32 16}
!9 = !{ptr @store_through_argument, !10, !11}
!10 = !{}
!11 = !{!12, !15, !16}
!12 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !13, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"Target", !"air.arg_name", !"target"}
!13 = !{i32 0, i32 8, i32 0, !"float", !"words", !"air.indirect_argument", !14}
!14 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"float", !"air.arg_name", !"words"}
!15 = !{i32 1, !"air.buffer", !"air.buffer_size", i32 4, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"float", !"air.arg_name", !"base"}
!16 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"index"}
!17 = !{!"air.compile.denorms_disable"}
!18 = !{!"air.compile.fast_math_enable"}
!19 = !{!"air.compile.framebuffer_fetch_enable"}
!20 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
!21 = !{i32 2, i32 8, i32 0}
!22 = !{!"Metal", i32 4, i32 0, i32 0}
!23 = !{!24, !24, i64 0}
!24 = !{!"float", !25, i64 0}
!25 = !{!"omnipotent char", !26, i64 0}
!26 = !{!"Simple C++ TBAA"}
!27 = !{!28}
!28 = distinct !{!28, !29, !"air-alias-scope-arg(1)"}
!29 = distinct !{!29, !"air-alias-scopes(store_through_argument)"}
!30 = !{!31}
!31 = distinct !{!31, !29, !"air-alias-scope-arg(0)"}
!32 = !{!33, !34, i64 0}
!33 = !{!"_ZTS6Target", !34, i64 0}
!34 = !{!"any pointer", !25, i64 0}
@@ -0,0 +1,19 @@
// Owned fixture: the kernel the metal2vulkan-validation crate's heap textures lane runs
// (src/runtime_lane/heap_textures.rs) to write a buffer that none of its bindings names. Written
// from scratch for it; `scripts/regen-air-fixtures/regen-air-fixtures.sh --dir examples
// argument_stores` compiles it. No translator sweep reads this directory.
#include <metal_stdlib>
using namespace metal;
// An argument buffer that holds the address of the buffer the kernel writes.
struct Target {
device float *words;
};
// `base + index` into word `index` of the buffer whose address `target` holds, which the
// encoder makes resident for writing (`useResource:usage:`).
kernel void store_through_argument(constant Target &target [[buffer(0)]],
constant float &base [[buffer(1)]],
uint index [[thread_position_in_grid]]) {
target.words[index] = base + float(index);
}
@@ -46,8 +46,8 @@ use metal2vulkan::device::{DriverFact, HeapCompressionPolicy};
use metal2vulkan::error::{Feature, LinearNeed, Needs};
use metal2vulkan::metal::format::{copies_only, footprint, is_depth_stencil, Footprint};
use metal2vulkan::metal::{
ColorWriteMask, IndirectCommandType, PixelFormat, PrimitiveType, RenderStages, ResourceUsage,
TextureType, TextureUsage,
BarrierScope, ColorWriteMask, IndirectCommandType, PixelFormat, PrimitiveType, RenderStages,
ResourceUsage, TextureType, TextureUsage,
};
use metal2vulkan::pipeline::{
ColorAttachmentDescriptor, ComputePipelineDescriptor, RenderPipelineDescriptor, StageSource,
@@ -880,6 +880,201 @@ fn a_buffer_write_shows_in_an_overlapping_texture() {
layer_reported_nothing_at_all(&messages);
}
/// A kernel's write of an untracked heap's buffer, then a kernel's read of a texture over the same
/// bytes, in one serial compute encoder, a memory barrier of buffers and textures between the two
/// dispatches (`memoryBarrierWithScope:`, which a serial encoder's order gives anyway, untracked
/// resources included: `tracker.rs`): every texel the read takes is the write's, in a `Shared` and
/// a `Private` placement heap of `HazardTrackingMode::Untracked`, a 64x64 `RGBA8Unorm` texture of
/// storage usage at offset 0 and a buffer of its answered size there. The write
/// (`scale_and_offset`, `1e6 + i` into every word) leaves no texel as the blit before it wrote it
/// (`texel_pattern`: alpha `0xCD`, where each written word's top byte is `0x49`), and the read
/// (`rows_read`) gives each texel's channels over 255.
///
/// The write's dispatch names the buffer by its binding, so where the device's driver misses, in
/// a use of an image, a write through a buffer over its memory recorded before it in the same
/// `VkCommandBuffer` (`DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer`), the read goes in
/// a new one (`WorkCounts::command_buffers_split_at_aliases`, at least one); elsewhere none splits.
/// `HEAPTEX untracked` lines print the counts. The same through an address is
/// [`a_kernel_s_write_through_an_address_into_an_untracked_heap_shows_in_its_encoder_s_read_of_a_texture_there`].
#[test]
fn a_kernel_s_write_of_an_untracked_heap_s_buffer_shows_in_its_encoder_s_read_of_a_texture_there() {
untracked_write_then_texture_read(Reached::Bound);
}
/// [`a_kernel_s_write_of_an_untracked_heap_s_buffer_shows_in_its_encoder_s_read_of_a_texture_there`]
/// with a write the dispatch's bindings do not name: `store_through_argument`
/// (`examples/argument_stores.metal`, `1e6 + i` into every word) reaches the heap's buffer through
/// the address its argument buffer holds, the encoder making the buffer resident for writing
/// (`useResource:usage:`), so the write is the resident set's. The read goes in a new
/// `VkCommandBuffer` where the driver misses such a write inside one, as it does after a bound
/// write; elsewhere none splits.
#[test]
fn a_kernel_s_write_through_an_address_into_an_untracked_heap_shows_in_its_encoder_s_read_of_a_texture_there(
) {
untracked_write_then_texture_read(Reached::Resident);
}
/// How the untracked heap lane's write reaches the heap's buffer.
#[derive(Clone, Copy, Debug)]
enum Reached {
/// Bound at the dispatch's buffer 1 (`scale_and_offset`): its uses name the buffer.
Bound,
/// Through the address the dispatch's argument buffer (buffer 0) holds
/// (`store_through_argument`), the buffer resident for writing: no binding names it.
Resident,
}
/// The untracked heap lane's write, reaching the heap's buffer as `reached` says, then its read
/// through the texture over the same bytes, in one encoder (the tests above).
fn untracked_write_then_texture_read(reached: Reached) {
const SIDE: u64 = 64;
let messages = Messages::default();
let cache = ScratchCache::new().unwrap();
{
let device = &validated_device(TEST_DEVICE, &messages, cache.path()).unwrap();
let splitting = (device.properties().driver_facts)
.contains(&DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer);
let state = |path: &str, name: &str| {
let bitcode = llvm_assemble(&fixtures_dir().join(path)).unwrap();
let library = device.new_library_with_air(&bitcode).unwrap();
let function = library.new_function_with_name(name).unwrap();
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
function.function_descriptor(),
));
device
.new_compute_pipeline_state(&descriptor, &PipelineOptions::default())
.unwrap()
};
let write = match reached {
Reached::Bound => state("examples/runtime_examples.ll", "scale_and_offset"),
Reached::Resident => state("examples/argument_stores.ll", "store_through_argument"),
};
let read = state("examples/texel_rows.ll", "rows_read");
let queue = device.new_command_queue().unwrap();
let split_before = device.work_counts().command_buffers_split_at_aliases;
let mut made = false;
for storage in [StorageMode::Shared, StorageMode::Private] {
let options = ResourceOptions::new(
storage,
CpuCacheMode::DefaultCache,
HazardTrackingMode::Untracked,
);
let heap = heap(device, HeapType::Placement, 1 << 20, options);
let mut descriptor = rgba8(SIDE, options);
descriptor.usage = TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE;
let what = format!("{reached:?} {storage:?} untracked {SIDE}x{SIDE}");
let texture = match heap.new_texture_at_offset(&descriptor, 0) {
Ok(texture) => texture,
Err(error) if tiling_refusal(&error).is_some() => {
eprintln!("HEAPTEX untracked {what}: refused {error:?}");
continue;
}
Err(error) => panic!("{what}: {error:?}"),
};
made = true;
let size = device
.heap_texture_size_and_align(&descriptor)
.unwrap()
.size;
let buffer = heap.new_buffer_at_offset(size, options, 0).unwrap();
let pattern = texel_pattern(SIDE);
let source = staged(device, &pattern);
let command_buffer = queue.command_buffer().unwrap();
let mut blit = command_buffer.blit_command_encoder().unwrap();
blit.copy_from_buffer_to_texture(
&source,
0,
SIDE * 4,
SIDE * SIDE * 4,
Size::new(SIDE, SIDE, 1),
&texture,
0,
0,
Origin::new(0, 0, 0),
BlitOption::None,
)
.unwrap();
blit.end_encoding().unwrap();
run(&command_buffer);
assert_eq!(texels(&queue, &texture, SIDE), pattern, "{what}");
let words = size / 4;
let inputs: Vec<u8> = (0..words).flat_map(|_| 1.0e6_f32.to_le_bytes()).collect();
let input = staged(device, &inputs);
let scale = staged(device, &1.0_f32.to_le_bytes());
let argument = staged(device, &buffer.gpu_address().0.to_le_bytes());
let out = device
.new_buffer(SIDE * SIDE * 16, ResourceOptions::shared())
.unwrap();
let command_buffer = queue.command_buffer().unwrap();
let mut encoder = command_buffer.compute_command_encoder().unwrap();
encoder.set_compute_pipeline_state(&write).unwrap();
match reached {
Reached::Bound => {
encoder.set_buffer(Some(&input), 0, 0).unwrap();
encoder.set_buffer(Some(&buffer), 0, 1).unwrap();
encoder.set_buffer(Some(&scale), 0, 2).unwrap();
}
Reached::Resident => {
encoder.set_buffer(Some(&argument), 0, 0).unwrap();
encoder.set_bytes(&1.0e6_f32.to_le_bytes(), 1).unwrap();
encoder
.use_resource(buffer.as_resource(), ResourceUsage::WRITE)
.unwrap();
}
}
encoder
.dispatch_threads(Size::new(words, 1, 1), Size::new(64, 1, 1))
.unwrap();
encoder.memory_barrier_with_scope(BarrierScope::BUFFERS | BarrierScope::TEXTURES);
encoder.set_compute_pipeline_state(&read).unwrap();
encoder.set_texture(Some(&texture), 0).unwrap();
encoder.set_buffer(Some(&out), 0, 0).unwrap();
encoder.set_bytes(&(SIDE as u32).to_le_bytes(), 1).unwrap();
encoder
.dispatch_threads(Size::new(SIDE, SIDE, 1), Size::new(8, 8, 1))
.unwrap();
encoder.end_encoding().unwrap();
run(&command_buffer);
let after = gpu_read(&queue, &out, 0..SIDE * SIDE * 16);
let read_texels: Vec<[u8; 4]> = (after.as_chunks::<16>().0.iter())
.map(|texel| {
let channel = |at: usize| {
let value = f32::from_le_bytes(texel[at..at + 4].try_into().unwrap());
(value * 255.0).round() as u8
};
[channel(0), channel(4), channel(8), channel(12)]
})
.collect();
let unchanged = (read_texels.iter())
.zip(pattern.as_chunks::<4>().0)
.filter(|(read, written)| read == written)
.count();
let words_of_the_write = (read_texels.iter())
.filter(|texel| texel[3] == 0x49)
.count();
eprintln!(
"HEAPTEX untracked {what}: {unchanged} of {} texels as the blit wrote them, {} \
holding a word of the kernel's write",
SIDE * SIDE,
words_of_the_write
);
assert_eq!(unchanged, 0, "{what}: texels the kernel's write left alone");
assert_eq!(
words_of_the_write,
(SIDE * SIDE) as usize,
"{what}: texels that hold no word of the kernel's write"
);
}
let split = device.work_counts().command_buffers_split_at_aliases - split_before;
eprintln!(
"HEAPTEX untracked {reached:?}: {split} command buffers split at aliases (the driver's \
image uses miss buffer writes inside one: {splitting})"
);
assert_eq!(split > 0, splitting && made);
}
layer_reported_nothing_at_all(&messages);
}
/// How a command uses a heap's texture after a blit encoder's write of the buffer over its bytes,
/// the two consecutive encoders of one command buffer
/// ([`blit_write_then_texture_use`]).