1 // Copyright (C) 2018 The Android Open Source Project
2 // Copyright (C) 2018 Google Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 #pragma once
16
17 #include <vulkan/vulkan.h>
18
19 #ifdef __cplusplus
20 #include <algorithm>
21 #endif
22
23 // We keep advertising VK_MVK_moltenvk on MacOS for backwards compatibility, since in the older
24 // guest images the checks for the external memory support is done via this extension.
25 #ifndef VK_MVK_moltenvk
26 #define VK_MVK_moltenvk 1
27 #define VK_MVK_MOLTENVK_SPEC_VERSION 3
28 #define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"
29 #endif // VK_MVK_moltenvk
30
31 // VulkanStream features
32 #define VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT (1 << 0)
33 #define VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT (1 << 1)
34 #define VULKAN_STREAM_FEATURE_SHADER_FLOAT16_INT8_BIT (1 << 2)
35 #define VULKAN_STREAM_FEATURE_QUEUE_SUBMIT_WITH_COMMANDS_BIT (1 << 3)
36
37 #define VK_YCBCR_CONVERSION_DO_NOTHING ((VkSamplerYcbcrConversion)0x1111111111111111)
38
39 #ifdef __cplusplus
40
41 template <class T, typename F>
arrayany(const T * arr,uint32_t begin,uint32_t end,const F & func)42 bool arrayany(const T* arr, uint32_t begin, uint32_t end, const F& func) {
43 const T* e = arr + end;
44 return std::find_if(arr + begin, e, func) != e;
45 }
46
47 #define DEFINE_ALIAS_FUNCTION(ORIGINAL_FN, ALIAS_FN) \
48 template <typename... Args> \
49 inline auto ALIAS_FN(Args&&... args) -> decltype(ORIGINAL_FN(std::forward<Args>(args)...)) { \
50 return ORIGINAL_FN(std::forward<Args>(args)...); \
51 }
52
53 #endif
54