1// 2// File: vk_platform.h 3// 4/* 5** Copyright (c) 2014-2017 The Khronos Group Inc. 6** 7** Licensed under the Apache License, Version 2.0 (the "License"); 8** you may not use this file except in compliance with the License. 9** You may obtain a copy of the License at 10** 11** http://www.apache.org/licenses/LICENSE-2.0 12** 13** Unless required by applicable law or agreed to in writing, software 14** distributed under the License is distributed on an "AS IS" BASIS, 15** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16** See the License for the specific language governing permissions and 17** limitations under the License. 18*/ 19 20/* 21 * Below this point is based on the original Khronos vk_platform.h header, but simplified for use in 22 * Skia when we are not building with a Vulkan backend, but still need the type declarations for 23 * compiling. 24 */ 25 26#ifndef VK_PLATFORM_H_ 27#define VK_PLATFORM_H_ 28 29#ifdef __cplusplus 30extern "C" 31{ 32#endif // __cplusplus 33 34/* 35*************************************************************************************************** 36* Platform-specific directives and type declarations 37*************************************************************************************************** 38*/ 39 40/* Platform-specific calling convention macros. 41 * 42 * Platforms should define these so that Vulkan clients call Vulkan commands 43 * with the same calling conventions that the Vulkan implementation expects. 44 * 45 * VKAPI_ATTR - Placed before the return type in function declarations. 46 * Useful for C++11 and GCC/Clang-style function attribute syntax. 47 * VKAPI_CALL - Placed after the return type in function declarations. 48 * Useful for MSVC-style calling convention syntax. 49 * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. 50 * 51 * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); 52 * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); 53 */ 54#if defined(_WIN32) 55 // On Windows, Vulkan commands use the stdcall convention 56 #define VKAPI_ATTR 57 #define VKAPI_CALL __stdcall 58 #define VKAPI_PTR VKAPI_CALL 59#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 60 #error "Vulkan isn't supported for the 'armeabi' NDK ABI" 61#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) 62 // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" 63 // calling convention, i.e. float parameters are passed in registers. This 64 // is true even if the rest of the application passes floats on the stack, 65 // as it does by default when compiling for the armeabi-v7a NDK ABI. 66 #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) 67 #define VKAPI_CALL 68 #define VKAPI_PTR VKAPI_ATTR 69#else 70 // On other platforms, use the default calling convention 71 #define VKAPI_ATTR 72 #define VKAPI_CALL 73 #define VKAPI_PTR 74#endif 75 76#include <stddef.h> 77 78#if !defined(VK_NO_STDINT_H) 79 #if defined(_MSC_VER) && (_MSC_VER < 1600) 80 typedef signed __int8 int8_t; 81 typedef unsigned __int8 uint8_t; 82 typedef signed __int16 int16_t; 83 typedef unsigned __int16 uint16_t; 84 typedef signed __int32 int32_t; 85 typedef unsigned __int32 uint32_t; 86 typedef signed __int64 int64_t; 87 typedef unsigned __int64 uint64_t; 88 #else 89 #include <stdint.h> 90 #endif 91#endif // !defined(VK_NO_STDINT_H) 92 93#ifdef __cplusplus 94} // extern "C" 95#endif // __cplusplus 96 97#endif 98