kronos_compute/implementation/
memory.rs1use crate::sys::*;
4use crate::core::*;
5use crate::ffi::*;
6use crate::implementation::icd_loader;
7
8#[no_mangle]
15pub unsafe extern "C" fn vkAllocateMemory(
16 device: VkDevice,
17 pAllocateInfo: *const VkMemoryAllocateInfo,
18 pAllocator: *const VkAllocationCallbacks,
19 pMemory: *mut VkDeviceMemory,
20) -> VkResult {
21 if device.is_null() || pAllocateInfo.is_null() || pMemory.is_null() {
22 return VkResult::ErrorInitializationFailed;
23 }
24
25 if let Some(icd) = icd_loader::icd_for_device(device) {
26 if let Some(f) = icd.allocate_memory { return f(device, pAllocateInfo, pAllocator, pMemory); }
27 }
28 if let Some(icd) = super::forward::get_icd_if_enabled() {
29 if let Some(allocate_memory) = icd.allocate_memory { return allocate_memory(device, pAllocateInfo, pAllocator, pMemory); }
30 }
31 VkResult::ErrorInitializationFailed
32}
33
34#[no_mangle]
41pub unsafe extern "C" fn vkFreeMemory(
42 device: VkDevice,
43 memory: VkDeviceMemory,
44 pAllocator: *const VkAllocationCallbacks,
45) {
46 if device.is_null() || memory.is_null() {
47 return;
48 }
49
50 if let Some(icd) = icd_loader::icd_for_device(device) {
51 if let Some(f) = icd.free_memory { f(device, memory, pAllocator); }
52 return;
53 }
54 if let Some(icd) = super::forward::get_icd_if_enabled() {
55 if let Some(free_memory) = icd.free_memory { free_memory(device, memory, pAllocator); }
56 }
57}
58
59#[no_mangle]
67pub unsafe extern "C" fn vkMapMemory(
68 device: VkDevice,
69 memory: VkDeviceMemory,
70 offset: VkDeviceSize,
71 size: VkDeviceSize,
72 flags: VkMemoryMapFlags,
73 ppData: *mut *mut libc::c_void,
74) -> VkResult {
75 if device.is_null() || memory.is_null() || ppData.is_null() {
76 return VkResult::ErrorInitializationFailed;
77 }
78
79 if let Some(icd) = icd_loader::icd_for_device(device) {
80 if let Some(f) = icd.map_memory { return f(device, memory, offset, size, flags, ppData); }
81 }
82 if let Some(icd) = super::forward::get_icd_if_enabled() {
83 if let Some(map_memory) = icd.map_memory { return map_memory(device, memory, offset, size, flags, ppData); }
84 }
85 VkResult::ErrorInitializationFailed
86}
87
88#[no_mangle]
94pub unsafe extern "C" fn vkUnmapMemory(
95 device: VkDevice,
96 memory: VkDeviceMemory,
97) {
98 if device.is_null() || memory.is_null() {
99 return;
100 }
101
102 if let Some(icd) = icd_loader::icd_for_device(device) {
103 if let Some(f) = icd.unmap_memory { f(device, memory); }
104 return;
105 }
106 if let Some(icd) = super::forward::get_icd_if_enabled() {
107 if let Some(unmap_memory) = icd.unmap_memory { unmap_memory(device, memory); }
108 }
109}