• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 haven't updated our Vulkan headers with the version 8 of VK_ANDROID_native_buffer, but we have
24 // implemented vkGetSwapchainGrallocUsage2ANDROID introduced in version 8 on the host which needs
25 // this type. We should remove this definition once our Vulkan headers are updated to support that
26 // version.
27 typedef VkFlags VkSwapchainImageUsageFlagsANDROID;
28 
29 // VulkanStream features
30 #define VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT (1 << 0)
31 #define VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT (1 << 1)
32 #define VULKAN_STREAM_FEATURE_SHADER_FLOAT16_INT8_BIT (1 << 2)
33 #define VULKAN_STREAM_FEATURE_QUEUE_SUBMIT_WITH_COMMANDS_BIT (1 << 3)
34 
35 #define VK_YCBCR_CONVERSION_DO_NOTHING ((VkSamplerYcbcrConversion)0x1111111111111111)
36 
37 #ifdef __cplusplus
38 
39 template<class T, typename F>
arrayany(const T * arr,uint32_t begin,uint32_t end,const F & func)40 bool arrayany(const T* arr, uint32_t begin, uint32_t end, const F& func) {
41     const T* e = arr + end;
42     return std::find_if(arr + begin, e, func) != e;
43 }
44 
45 #define DEFINE_ALIAS_FUNCTION(ORIGINAL_FN, ALIAS_FN) \
46 template <typename... Args> \
47 inline auto ALIAS_FN(Args&&... args) -> decltype(ORIGINAL_FN(std::forward<Args>(args)...)) { \
48   return ORIGINAL_FN(std::forward<Args>(args)...); \
49 }
50 
51 #endif
52