| 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 |
#ifndef VK_PLATFORM_H_ |
| 22 |
#define VK_PLATFORM_H_ |
| 23 |
|
| 24 |
#if defined(__ANDROID__) |
| 25 |
#define VK_USE_PLATFORM_ANDROID_KHR 1 |
| 26 |
#elif defined(IOS) |
| 27 |
#define VK_USE_PLATFORM_IOS_MVK 1 |
| 28 |
#elif defined(__linux__) |
| 29 |
#if defined(FILAMENT_SUPPORTS_XCB) |
| 30 |
#define VK_USE_PLATFORM_XCB_KHR 1 |
| 31 |
#endif |
| 32 |
#if defined(FILAMENT_SUPPORTS_XLIB) |
| 33 |
#define VK_USE_PLATFORM_XLIB_KHR 1 |
| 34 |
#endif |
| 35 |
#elif defined(__APPLE__) |
| 36 |
#define VK_USE_PLATFORM_MACOS_MVK 1 |
| 37 |
#elif defined(WIN32) |
| 38 |
#define VK_USE_PLATFORM_WIN32_KHR 1 |
| 39 |
#endif |
| 40 |
|
| 41 |
#ifdef __cplusplus |
| 42 |
extern "C" |
| 43 |
{ |
| 44 |
#endif // __cplusplus |
| 45 |
|
| 46 |
/* |
| 47 |
*************************************************************************************************** |
| 48 |
* Platform-specific directives and type declarations |
| 49 |
*************************************************************************************************** |
| 50 |
*/ |
| 51 |
|
| 52 |
/* Platform-specific calling convention macros. |
| 53 |
* |
| 54 |
* Platforms should define these so that Vulkan clients call Vulkan commands |
| 55 |
* with the same calling conventions that the Vulkan implementation expects. |
| 56 |
* |
| 57 |
* VKAPI_ATTR - Placed before the return type in function declarations. |
| 58 |
* Useful for C++11 and GCC/Clang-style function attribute syntax. |
| 59 |
* VKAPI_CALL - Placed after the return type in function declarations. |
| 60 |
* Useful for MSVC-style calling convention syntax. |
| 61 |
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types. |
| 62 |
* |
| 63 |
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); |
| 64 |
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); |
| 65 |
*/ |
| 66 |
#if defined(_WIN32) |
| 67 |
// On Windows, Vulkan commands use the stdcall convention |
| 68 |
#define VKAPI_ATTR |
| 69 |
#define VKAPI_CALL __stdcall |
| 70 |
#define VKAPI_PTR VKAPI_CALL |
| 71 |
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 |
| 72 |
#error "Vulkan isn't supported for the 'armeabi' NDK ABI" |
| 73 |
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) |
| 74 |
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" |
| 75 |
// calling convention, i.e. float parameters are passed in registers. This |
| 76 |
// is true even if the rest of the application passes floats on the stack, |
| 77 |
// as it does by default when compiling for the armeabi-v7a NDK ABI. |
| 78 |
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) |
| 79 |
#define VKAPI_CALL |
| 80 |
#define VKAPI_PTR VKAPI_ATTR |
| 81 |
#else |
| 82 |
// On other platforms, use the default calling convention |
| 83 |
#define VKAPI_ATTR |
| 84 |
#define VKAPI_CALL |
| 85 |
#define VKAPI_PTR |
| 86 |
#endif |
| 87 |
|
| 88 |
#include <stddef.h> |
| 89 |
|
| 90 |
#if !defined(VK_NO_STDINT_H) |
| 91 |
#if defined(_MSC_VER) && (_MSC_VER < 1600) |
| 92 |
typedef signed __int8 int8_t; |
| 93 |
typedef unsigned __int8 uint8_t; |
| 94 |
typedef signed __int16 int16_t; |
| 95 |
typedef unsigned __int16 uint16_t; |
| 96 |
typedef signed __int32 int32_t; |
| 97 |
typedef unsigned __int32 uint32_t; |
| 98 |
typedef signed __int64 int64_t; |
| 99 |
typedef unsigned __int64 uint64_t; |
| 100 |
#else |
| 101 |
#include <stdint.h> |
| 102 |
#endif |
| 103 |
#endif // !defined(VK_NO_STDINT_H) |
| 104 |
|
| 105 |
#ifdef __cplusplus |
| 106 |
} // extern "C" |
| 107 |
#endif // __cplusplus |
| 108 |
|
| 109 |
#endif |