Sarek_vulkan.Vulkan_api_memorymodule Device = Vulkan_api_devicetype 'a buffer = {buffer : Vulkan_types.vk_buffer;memory : Vulkan_types.vk_device_memory;size : int;elem_size : int;device : Device.t;mutable mapped_ptr : unit Ctypes.ptr option;mapped_cached : bool;The mapping is of HOST_CACHED memory, so the host can read it at memory speed. A mapping of device memory behind the PCIe BAR is write-combined and uncached: writes are fast, reads run at a few tens of MB/s.
*)}Test hook: while true, alloc places buffers in DEVICE_LOCAL memory that is never host-mapped, even where HOST_VISIBLE device memory exists, so the staged and imported copy paths of Vulkan_api_transfer can be exercised on a machine whose VRAM is host-visible. Production code never sets it.
val find_memory_type : Device.t -> int -> int -> int optionFind suitable memory type
val find_memory_type_excluding :
Device.t ->
int ->
required:int ->
excluded:int ->
int optionLike find_memory_type, for a type that also has none of the excluded flags.
val memory_type_is_cached : Device.t -> int -> boolWhether memory type index is HOST_CACHED.
val create_transient_pool : Device.t -> Vulkan_types.vk_command_poolA command pool private to one call: vkCmdXxx, vkBeginCommandBuffer and allocation need external synchronisation of their pool, and these copies run on whichever domain the caller is, so sharing device.command_pool would need a lock held across the recording. A transient pool per call needs none and adds no lock to the order batch_lock -> queue_lock.
val allocate_copy_command_buffer :
Device.t ->
Vulkan_types.vk_command_pool ->
Vulkan_types.vk_command_buffer Ctypes.structure Ctypes_static.ptr Ctypes.ptrval begin_one_time :
Vulkan_types.vk_command_buffer Ctypes.structure Ctypes_static.ptr ->
unitval submit_and_wait :
Device.t ->
Vulkan_types.vk_command_buffer Ctypes.structure Ctypes_static.ptr
Ctypes_static.ptr ->
unitval run_single_time_command :
Device.t ->
(Vulkan_types.vk_command_buffer Ctypes.structure Ctypes_static.ptr -> unit) ->
unitRecord record_fn into a one-time command buffer, submit it and wait.
Test instrumentation, not an API: staging buffers created since the library was loaded. Lets a test assert that a copy took the staging-free path.
val create_staging_buffer :
?cached:bool ->
Device.t ->
int ->
int ->
Vulkan_types.vk_buffer * Unsigned.UInt64.t * unit Ctypes_static.ptrA mapped HOST_VISIBLE | HOST_COHERENT buffer of size bytes. With ~cached:true the memory is HOST_CACHED when the device has such a type (the host reads it at memory speed; uncached staging memory reads at ~0.25 GB/s), otherwise the plain type.
val release_now : 'a buffer -> unitDestroy buf's Vulkan objects. Only when no launch can use the buffer.
val alloc :
Sarek_vulkan.Vulkan_api_release.Device.t ->
int ->
('a, 'b) Stdlib.Bigarray.kind ->
'c bufferval alloc_custom :
Sarek_vulkan.Vulkan_api_release.Device.t ->
size:int ->
elem_size:int ->
'a bufferval free : 'a buffer -> unitQueue the release of buf; see Vulkan_api_release. Safe from a GC finaliser.
Vulkan doesn't expose device pointers like CUDA. Return 0 as placeholder. Binding uses the buffer handle directly via set_arg_buffer.
Vulkan always uses explicit transfers (vkMapMemory/memcpy), never zero-copy
val host_to_device :
src:('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t ->
dst:'c buffer ->
unitval device_to_host :
src:'a buffer ->
dst:('b, 'c, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t ->
unitval host_ptr_to_device :
src_ptr:unit Ctypes_static.ptr ->
byte_size:int ->
dst:'a buffer ->
unitval device_to_host_ptr :
src:'a buffer ->
dst_ptr:unit Ctypes_static.ptr ->
byte_size:int ->
unit