kronos_compute/implementation/
memory.rs1use crate::sys::*;
4use crate::core::*;
5use crate::ffi::*;
6
7#[no_mangle]
14pub unsafe extern "C" fn vkAllocateMemory(
15 device: VkDevice,
16 pAllocateInfo: *const VkMemoryAllocateInfo,
17 pAllocator: *const VkAllocationCallbacks,
18 pMemory: *mut VkDeviceMemory,
19) -> VkResult {
20 if device.is_null() || pAllocateInfo.is_null() || pMemory.is_null() {
21 return VkResult::ErrorInitializationFailed;
22 }
23
24 if let Some(icd) = super::forward::get_icd_if_enabled() {
26 if let Some(allocate_memory) = icd.allocate_memory {
27 return allocate_memory(device, pAllocateInfo, pAllocator, pMemory);
28 }
29 }
30
31 VkResult::ErrorInitializationFailed
33}
34
35#[no_mangle]
42pub unsafe extern "C" fn vkFreeMemory(
43 device: VkDevice,
44 memory: VkDeviceMemory,
45 pAllocator: *const VkAllocationCallbacks,
46) {
47 if device.is_null() || memory.is_null() {
48 return;
49 }
50
51 if let Some(icd) = super::forward::get_icd_if_enabled() {
53 if let Some(free_memory) = icd.free_memory {
54 free_memory(device, memory, pAllocator);
55 }
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) = super::forward::get_icd_if_enabled() {
81 if let Some(map_memory) = icd.map_memory {
82 return map_memory(device, memory, offset, size, flags, ppData);
83 }
84 }
85
86 VkResult::ErrorInitializationFailed
88}
89
90#[no_mangle]
96pub unsafe extern "C" fn vkUnmapMemory(
97 device: VkDevice,
98 memory: VkDeviceMemory,
99) {
100 if device.is_null() || memory.is_null() {
101 return;
102 }
103
104 if let Some(icd) = super::forward::get_icd_if_enabled() {
106 if let Some(unmap_memory) = icd.unmap_memory {
107 unmap_memory(device, memory);
108 }
109 }
110}