| 1 |
// |
| 2 |
// File: vk_platform.h |
| 3 |
// |
| 4 |
/* |
| 5 |
** Copyright 2014-2026 The Khronos Group Inc. |
| 6 |
** |
| 7 |
** SPDX-License-Identifier: Apache-2.0 |
| 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 |
| 45 |
#error "Vulkan is not supported for the 'armeabi' NDK ABI" |
| 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 |
|
| 61 |
#if !defined(VK_NO_STDDEF_H) |
| 62 |
#include <stddef.h> |
| 63 |
#endif // !defined(VK_NO_STDDEF_H) |
| 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 |