MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / init

Function init

framework/core/allocated.h:52–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 */
51template <typename DeviceType = vkb::core::DeviceC>
52void init(const DeviceType &device)
53{
54 VmaVulkanFunctions vma_vulkan_func{};
55 vma_vulkan_func.vkGetInstanceProcAddr = vkGetInstanceProcAddr;
56 vma_vulkan_func.vkGetDeviceProcAddr = vkGetDeviceProcAddr;
57
58 VmaAllocatorCreateInfo allocator_info{};
59 allocator_info.pVulkanFunctions = &vma_vulkan_func;
60 allocator_info.physicalDevice = static_cast<VkPhysicalDevice>(device.get_gpu().get_handle());
61 allocator_info.device = static_cast<VkDevice>(device.get_handle());
62 allocator_info.instance = static_cast<VkInstance>(device.get_gpu().get_instance().get_handle());
63
64 bool can_get_memory_requirements = device.get_gpu().is_extension_supported(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
65 bool has_dedicated_allocation = device.get_gpu().is_extension_supported(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
66 if (can_get_memory_requirements && has_dedicated_allocation && device.is_extension_enabled(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME))
67 {
68 allocator_info.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;
69 }
70
71 if (device.get_gpu().is_extension_supported(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME) &&
72 device.is_extension_enabled(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))
73 {
74 allocator_info.flags |= VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT;
75 }
76
77 if (device.get_gpu().is_extension_supported(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME) && device.is_extension_enabled(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME))
78 {
79 allocator_info.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT;
80 }
81
82 if (device.get_gpu().is_extension_supported(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME) &&
83 device.is_extension_enabled(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME))
84 {
85 allocator_info.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT;
86 }
87
88 if (device.get_gpu().is_extension_supported(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME) && device.is_extension_enabled(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME))
89 {
90 allocator_info.flags |= VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT;
91 }
92
93 if (device.get_gpu().is_extension_supported(VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME) &&
94 device.is_extension_enabled(VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME))
95 {
96 allocator_info.flags |= VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT;
97 }
98
99 init(allocator_info);
100}
101
102/**
103 * @brief Shuts down the VMA allocator and releases all resources. Should be preceeded with a call to `init`.

Callers 6

PhysicalDeviceMethod · 0.70
DeviceMethod · 0.70
initMethod · 0.70
AstcMethod · 0.50
RenderTargetMethod · 0.50
create_deviceMethod · 0.50

Calls 4

get_instanceMethod · 0.80
get_handleMethod · 0.45
is_extension_enabledMethod · 0.45

Tested by

no test coverage detected