skia2/third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator.cpp
Brandon DeRosier c0ff5a8560 Add flag that can be used to disable std::shared_mutex use in VMA.
This is needed for enabling Skia's Vulkan backend for Flutter on Windows and iOS 9, as the standard libraries in both of these contexts don't have `std::shared_mutex`.

When disabled on Windows, VMA falls back to using Win32 SRWLock.
The `vulkan.h` import in `vk_mem_alloc.h` which would normally import `windows.h` is commented out for Skia, and so the relevant symbols need to be declared before importing `vk_mem_alloc.h`.

Relevant Flutter Engine PR: https://github.com/flutter/engine/pull/29520

Change-Id: I2b1a621417155071b21e5c6d3b5ccc375c92a622
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/469207
Reviewed-by: Greg Daniel <egdaniel@google.com>
Auto-Submit: Brandon DeRosier <bdero@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-11-12 01:35:08 +00:00

29 lines
849 B
C++

/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// We use our own functions pointers
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
// vma_mem_alloc.h will use VMA_NULLABLE and VMA_NOT_NULL as clang nullability attribtues but does a
// poor job at using them everywhere. Thus it causes lots of clang compiler warnings. We just
// disable them here by defining them to be nothing.
#define VMA_NULLABLE
#define VMA_NOT_NULL
#define VMA_IMPLEMENTATION
// On windows, vk_mem_alloc.h uses Windows SRWLock, which is normally included by vulkan.h, and so
// the relevant symbols/defines need to be included here.
#ifdef _WIN32
#include <windows.h>
#endif
#include <vulkan/vulkan_core.h>
#include "GrVulkanMemoryAllocator.h"