• 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 #ifndef VK_MVK_moltenvk
24 #define VK_MVK_moltenvk 1
25 #define VK_MVK_MOLTENVK_SPEC_VERSION 3
26 #define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"
27 
28 typedef void* MTLTextureRef;
29 typedef void* MTLBufferRef;
30 
31 typedef void(VKAPI_PTR* PFN_vkGetMTLDeviceMVK)(VkPhysicalDevice physicalDevice, void** pMTLDevice);
32 typedef VkResult(VKAPI_PTR* PFN_vkSetMTLTextureMVK)(VkImage image, MTLTextureRef mtlTexture);
33 typedef void(VKAPI_PTR* PFN_vkGetMTLTextureMVK)(VkImage image, MTLTextureRef* pMTLTexture);
34 typedef void(VKAPI_PTR* PFN_vkGetMTLBufferMVK)(VkBuffer buffer, void** pMTLBuffer);
35 typedef VkResult(VKAPI_PTR* PFN_vkUseIOSurfaceMVK)(VkImage image, void* ioSurface);
36 typedef void(VKAPI_PTR* PFN_vkGetIOSurfaceMVK)(VkImage image, void** pIOSurface);
37 
38 #endif  // VK_MVK_moltenvk
39 
40 // VulkanStream features
41 #define VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT (1 << 0)
42 #define VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT (1 << 1)
43 #define VULKAN_STREAM_FEATURE_SHADER_FLOAT16_INT8_BIT (1 << 2)
44 #define VULKAN_STREAM_FEATURE_QUEUE_SUBMIT_WITH_COMMANDS_BIT (1 << 3)
45 
46 #define VK_YCBCR_CONVERSION_DO_NOTHING ((VkSamplerYcbcrConversion)0x1111111111111111)
47 
48 #ifdef __cplusplus
49 
50 template<class T, typename F>
arrayany(const T * arr,uint32_t begin,uint32_t end,const F & func)51 bool arrayany(const T* arr, uint32_t begin, uint32_t end, const F& func) {
52     const T* e = arr + end;
53     return std::find_if(arr + begin, e, func) != e;
54 }
55 
56 #define DEFINE_ALIAS_FUNCTION(ORIGINAL_FN, ALIAS_FN) \
57 template <typename... Args> \
58 inline auto ALIAS_FN(Args&&... args) -> decltype(ORIGINAL_FN(std::forward<Args>(args)...)) { \
59   return ORIGINAL_FN(std::forward<Args>(args)...); \
60 }
61 
62 #endif
63