Flutter Engine
The Flutter Engine
VulkanMemoryAllocatorWrapper.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8// We use this header to include vk_mem_alloc.h to make sure we have the corect defines before we
9// include vulkan.h inside of vk_mem_alloc.h
10
11#ifndef VulkanMemoryAllocatorWrapper_DEFINED
12#define VulkanMemoryAllocatorWrapper_DEFINED
13
14// We only ever include this from src files which have already included vulkan.
15#ifndef VULKAN_CORE_H_
16#error "vulkan_core.h has not been included before trying to include the GrVulkanMemoryAllocator"
17#endif
18
19// TODO: We currently lock down our API to Vulkan 1.1. When we update Skia to support 1.3 then we
20// can remove this macro. We should also update the setting of the API level in the vma createInfo
21// struct when we do this
22#define VMA_VULKAN_VERSION 1001000
23
24// vk_mem_alloc.h checks to see if VULKAN_H_ has been included before trying to include vulkan.h.
25// However, some builds of Skia may not have access to vulkan.h and just have access to
26// vulkan_core.h. So we pretend we've already included vulkan.h (if it already hasn't been) which
27// will be fine for building internal skia files. If we do fake it out by defining VULKAN_H_ we
28// need to make sure to undefine it incase outside client code does later try to include the
29// real vulkan.h
30#ifndef VULKAN_H_
31#define VULKAN_H_
32#define GR_NEEDED_TO_DEFINE_VULKAN_H
33#endif
34// TODO: b/306154574 - Investigate whether it's possible to handle the
35// aforementioned preconditions while also allowing Skia to use the canonical
36// VMA without a wrapper. Inclusion of `vk_mem_alloc.h` causes an ODR violation.
37// This could cause an ODR issue if multiple users are including the same header
38// and implementation but passing in different defines. If there will be uses of
39// VMA outside of Skia, the client should instead tell Skia not to use VMA.
40// Then they should wrap their own instance of VMA into an implementation of
41// Skia's VulkanMemoryAllocator interface, and pass that object into context creation.
42#include "vk_mem_alloc.h" // NO_G3_REWRITE
43#ifdef GR_NEEDED_TO_DEFINE_VULKAN_H
44#undef VULKAN_H_
45#endif
46
47#endif