atagen

monolith

public
Star0
Watch0

Commit 92060e8f176e

tarball

atagen <boss@atagen.co>2026-10-19 07:56 UTC

1 file changed+11-0
render-vk: make readback copies visible to the host

read_back waited on the fence and then read the mapped buffer with no TRANSFER_WRITE to HOST_READ barrier, so the spec did not guarantee the CPU saw the copied pixels.
Modified file: crates/render-vk/src/renderer/mod.rs+11 additions
@@ -705,6 +705,17 @@ impl VulkanRenderer {
705705 let mut barriers = Barriers::default();
706706 barriers.release(family, &source, vk::ImageLayout::TRANSFER_SRC_OPTIMAL);
707707 barriers.record(d, cmd);
708+ let to_host = [vk::BufferMemoryBarrier2::default()
709+ .src_stage_mask(vk::PipelineStageFlags2::TRANSFER)
710+ .src_access_mask(vk::AccessFlags2::TRANSFER_WRITE)
711+ .dst_stage_mask(vk::PipelineStageFlags2::HOST)
712+ .dst_access_mask(vk::AccessFlags2::HOST_READ)
713+ .buffer(buffer)
714+ .size(vk::WHOLE_SIZE)];
715+ d.cmd_pipeline_barrier2(
716+ cmd,
717+ &vk::DependencyInfo::default().buffer_memory_barriers(&to_host),
718+ );
708719 })?;
709720 }
710721 let mut data = staging.bytes()?[..w as usize * h as usize * BYTES_PER_PIXEL].to_vec();