A new Private buffer's zeros (Buffer::clear_first) and its staged bytes,
and a Managed buffer's upload, wait for the device's next submission,
which makes them before its own commands. Buffer::vk_buffer handed the
VkBuffer out with that work still waiting. The consumer's frame cache
took vk_buffer() of a new Private buffer before any runtime submission,
wrote the buffer on its own VkQueue, and our next blit made the pending
zero fill first and read all zeros.
The hand-out now makes the work first, by an internal submission waited
for, as Texture::vk_image already does for its texture's move. It
submits nothing where no fill waits on that VkBuffer
(FirstMoves::fills_wait: a waiting fill, staged copy or upload whose
destination is the VkBuffer). Buffer::export_memory_fd settles the same
way, since another API may write the exported memory at once. A texture
handed out was already covered: its settle submits whenever its move
waits, and that submission takes every fill waiting, the zeros of the
buffer it lies in among them. The first-moves docs, vk_buffer's docs and
the runtime README say so.
Tests (tests/caller_queue_writes.rs, device tests). Each writes on a
queue of the caller's: the reserved queue, or a command queue's lent
VkQueue.
- a_new_private_buffer_handed_out_reads_the_caller_s_writes_not_its_zeros:
a Private Zero buffer with aligned byte 0x20, 3,110,400 bytes, is
handed out with its fill still waiting (asserted, so the path runs),
written by the caller's vkCmdCopyBuffer, then read by a runtime blit.
The negative control is the old hand-out, which only notes the
hand-out; it should read zeros.
- a_texture_over_a_new_private_buffer_handed_out_reads_the_caller_s_writes:
the same for an R8Unorm 3840x2160 plane in place at byte 0x20 over
such a buffer, written by the caller's vkCmdCopyBufferToImage in
GENERAL. The texture and the bytes under it both read the copy.
- a_shared_aligned_frame_written_on_the_caller_s_queue_reads_the_writes:
the shape of the consumer's report of a device loss on RADV. Six
rounds; each makes a Shared NV12 frame with aligned byte 0x20, fills
it through contents(), then writes both planes from the caller's
image with vkCmdCopyImageToBuffer. Each round reads the copy through
contents() and through a blit, and the device stays live.
Not yet verified; the 780M and lavapipe runs follow this commit.
(cherry picked from commit 28dcdcaed27183ebe375919944d2175850ef418b)