Files
metal2vulkan/crates
Anees Iqbal 9c7013f60b RUNTIME 2387: host RAM copies: a dispatch writes its own imports alone into a partially bound import array
What: the pages copy's owned kernel makes its first storage-buffer binding, the array of
PagesCopyModule::imports(device) imports, VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT where the
array holds more than one and the device enables descriptorBindingPartiallyBound (the runtime
enables it wherever the device has it: device/enables.rs, Vulkan 1.2 features). Each dispatch of a
copy then writes (pushes, or writes into its set) only its own imports, then the buffer's window
and the table: OwnedKernel::first_written accepts a set that writes 1 to the array's length of the
array's elements where the binding is partially bound, every element elsewhere, and buffer_place
places the rest after them. Without the feature the elements past the dispatch's imports hold its
first import again, as before. The kernel's making text carries the flag.

Why: since RUNTIME 2322 every pages-copy dispatch wrote the whole array: on a device of 32 push
descriptors (ANV, RADV, NVIDIA, lavapipe: 30 imports) a dispatch over one import pushed 32
storage-buffer descriptors where 3 serve, through push_set's heap path (past 16 writes) and the
driver's vkCmdPushDescriptorSet, at every copy dispatch (358 to 813 a consumer's boot). No table
entry names an element past the dispatch's imports, so no invocation accesses one.

Vulkan: VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT "specifies that descriptors in this binding
that are not dynamically used need not contain valid descriptors at the time the descriptors are
consumed"; a push descriptor set layout takes it
(VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-flags-03003 forbids such a layout only
UPDATE_AFTER_BIND, UPDATE_UNUSED_WHILE_PENDING and VARIABLE_DESCRIPTOR_COUNT), and
descriptorBindingPartiallyBound must be enabled for it.

Test: host_ram_copy_device's a_dispatch_over_one_import_writes_its_own_descriptors_alone: rows of
4-byte texels in one chunk, one dispatch, the gathered bytes right, and the storage-buffer
descriptors the owned kernel's set or push wrote (a test-only thread-local count,
owned_kernel::buffers_written) 3 where the array is partially bound, the array's length and 2
elsewhere (32 before this change on lavapipe).

Verified: m3-max-33702 (msi) at the lane tip 238fde9d64: clippy (runtime + validation, all targets,
all features) 0, rustdoc 0; lavapipe host_ram_copy_device 32/32 (m3-max-33686, the same tree before
its rebase), "an array of 30 imports, partially bound true: 3 storage-buffer descriptors written";
PHOENIX (RADV, carried m2v_gpu archive of 238fde9d64) host_ram_copy_device 32/32, 3 written
(m3-max-33733); negative control (the whole array written again) fails the new test with 32
(m3-max-33700). clippy m2v_gpu / m2v_cpu_icd in 33722.
2026-11-15 14:37:33 -08:00
..