Caio Marcelo de Oliveira Filho | e3eb327 | 2020-06-01 21:00:51 -0700 | [diff] [blame] | 1 | // |
| 2 | // File: vk_platform.h |
| 3 | // |
| 4 | /* |
sugoi1 | bca2344 | 2022-01-26 17:49:23 -0500 | [diff] [blame] | 5 | ** Copyright 2014-2022 The Khronos Group Inc. |
Caio Marcelo de Oliveira Filho | e3eb327 | 2020-06-01 21:00:51 -0700 | [diff] [blame] | 6 | ** |
Nicolas Capens | 3b2cd31 | 2020-07-21 11:51:25 -0400 | [diff] [blame] | 7 | ** SPDX-License-Identifier: Apache-2.0 |
Caio Marcelo de Oliveira Filho | e3eb327 | 2020-06-01 21:00:51 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | |
| 11 | #ifndef VK_PLATFORM_H_ |
| 12 | #define VK_PLATFORM_H_ |
| 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" |
| 16 | { |
| 17 | #endif // __cplusplus |
| 18 | |
| 19 | /* |
| 20 | *************************************************************************************************** |
| 21 | * Platform-specific directives and type declarations |
| 22 | *************************************************************************************************** |
| 23 | */ |
| 24 | |
| 25 | /* Platform-specific calling convention macros. |
| 26 | * |
| 27 | * Platforms should define these so that Vulkan clients call Vulkan commands |
| 28 | * with the same calling conventions that the Vulkan implementation expects. |
| 29 | * |
| 30 | * VKAPI_ATTR - Placed before the return type in function declarations. |
| 31 | * Useful for C++11 and GCC/Clang-style function attribute syntax. |
| 32 | * VKAPI_CALL - Placed after the return type in function declarations. |
| 33 | * Useful for MSVC-style calling convention syntax. |
| 34 | * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. |
| 35 | * |
| 36 | * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); |
| 37 | * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); |
| 38 | */ |
| 39 | #if defined(_WIN32) |
| 40 | // On Windows, Vulkan commands use the stdcall convention |
| 41 | #define VKAPI_ATTR |
| 42 | #define VKAPI_CALL __stdcall |
| 43 | #define VKAPI_PTR VKAPI_CALL |
| 44 | #elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 |
sugoi1 | bca2344 | 2022-01-26 17:49:23 -0500 | [diff] [blame] | 45 | #error "Vulkan is not supported for the 'armeabi' NDK ABI" |
Caio Marcelo de Oliveira Filho | e3eb327 | 2020-06-01 21:00:51 -0700 | [diff] [blame] | 46 | #elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) |
| 47 | // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" |
| 48 | // calling convention, i.e. float parameters are passed in registers. This |
| 49 | // is true even if the rest of the application passes floats on the stack, |
| 50 | // as it does by default when compiling for the armeabi-v7a NDK ABI. |
| 51 | #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) |
| 52 | #define VKAPI_CALL |
| 53 | #define VKAPI_PTR VKAPI_ATTR |
| 54 | #else |
| 55 | // On other platforms, use the default calling convention |
| 56 | #define VKAPI_ATTR |
| 57 | #define VKAPI_CALL |
| 58 | #define VKAPI_PTR |
| 59 | #endif |
| 60 | |
Nicolas Capens | b461e20 | 2021-05-13 09:06:18 -0400 | [diff] [blame] | 61 | #if !defined(VK_NO_STDDEF_H) |
| 62 | #include <stddef.h> |
| 63 | #endif // !defined(VK_NO_STDDEF_H) |
Caio Marcelo de Oliveira Filho | e3eb327 | 2020-06-01 21:00:51 -0700 | [diff] [blame] | 64 | |
| 65 | #if !defined(VK_NO_STDINT_H) |
| 66 | #if defined(_MSC_VER) && (_MSC_VER < 1600) |
| 67 | typedef signed __int8 int8_t; |
| 68 | typedef unsigned __int8 uint8_t; |
| 69 | typedef signed __int16 int16_t; |
| 70 | typedef unsigned __int16 uint16_t; |
| 71 | typedef signed __int32 int32_t; |
| 72 | typedef unsigned __int32 uint32_t; |
| 73 | typedef signed __int64 int64_t; |
| 74 | typedef unsigned __int64 uint64_t; |
| 75 | #else |
| 76 | #include <stdint.h> |
| 77 | #endif |
| 78 | #endif // !defined(VK_NO_STDINT_H) |
| 79 | |
| 80 | #ifdef __cplusplus |
| 81 | } // extern "C" |
| 82 | #endif // __cplusplus |
| 83 | |
| 84 | #endif |