Sarek_vulkan.Vulkan_api_transferRanged host<->device copies (specs/vulkan-async-api.md).
Every copy completes before it returns. It first completes the device's pending launches (Vulkan_api_device.drain_pending), so it never lands under a kernel still using the buffer and always sees what a kernel wrote; a copy issued before a launch is visible to it (the launch is recorded after the copy has finished).
Three paths, by where the host bytes and the device bytes live:
Vulkan_api_host) and the host cannot access the device buffer at memory speed (unmapped, or uncached for reads), or a write of at least dma_min_bytes: one vkCmdCopyBuffer straight between the import and the device buffer (DMA, no staging, no host memcpy);mapped_cached for reads: uncached BAR memory reads at ~0.03 GB/s): one memcpy at the byte offset;memcpy and one vkCmdCopyBuffer; read-back staging is HOST_CACHED when available.module Device = Vulkan_api_devicemodule Memory = Vulkan_api_memorymodule Host = Vulkan_api_hostval total_bytes : 'a Memory.buffer -> intval record_copy :
Vulkan_types.vk_command_buffer Ctypes.structure Ctypes_static.ptr ->
src:Vulkan_types.vk_buffer ->
src_offset:int ->
dst:Vulkan_types.vk_buffer ->
dst_offset:int ->
byte_size:int ->
unitHost-to-device into a MAPPED buffer from a pinned range: below this many bytes a memcpy beats the submission and fence wait of a DMA copy (4 MiB: 19.0 vs 16.7 GB/s; 16 MiB: 19.0 vs 21.6 GB/s; RX 7900 XTX, H7 bench).
val with_staging :
?cached:bool ->
Memory.Device.t ->
byte_size:int ->
usage:int ->
(Vulkan_types.vk_buffer -> unit Ctypes_static.ptr -> 'a) ->
'aval check_range :
what:string ->
'a Memory.buffer ->
off:int ->
byte_size:int ->
unitval host_to_device_staged :
'a Memory.buffer ->
src_ptr:unit Ctypes_static.ptr ->
dst_offset:int ->
byte_size:int ->
unitval device_to_host_staged :
'a Memory.buffer ->
dst_ptr:unit Ctypes_static.ptr ->
src_offset:int ->
byte_size:int ->
unitval host_to_device_dma :
'a Memory.buffer ->
import:Vulkan_types.vk_buffer ->
src_offset:int ->
dst_offset:int ->
byte_size:int ->
unitval device_to_host_dma :
'a Memory.buffer ->
import:Vulkan_types.vk_buffer ->
src_offset:int ->
dst_offset:int ->
byte_size:int ->
unitval host_to_device :
src_ptr:nativeint ->
dst:'a Memory.buffer ->
dst_offset:int ->
byte_size:int ->
unitbyte_size bytes from raw host address src_ptr to dst_offset of dst.
val device_to_host :
src:'a Memory.buffer ->
src_offset:int ->
dst_ptr:nativeint ->
byte_size:int ->
unitbyte_size bytes from src_offset of src to raw host address dst_ptr.