1//
2// File: vk_platform.h
3//
4/*
5** Copyright (c) 2014-2020 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
15extern "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 isn't 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#include <stddef.h>
62
63#if !defined(VK_NO_STDINT_H)
64 #if defined(_MSC_VER) && (_MSC_VER < 1600)
65 typedef signed __int8 int8_t;
66 typedef unsigned __int8 uint8_t;
67 typedef signed __int16 int16_t;
68 typedef unsigned __int16 uint16_t;
69 typedef signed __int32 int32_t;
70 typedef unsigned __int32 uint32_t;
71 typedef signed __int64 int64_t;
72 typedef unsigned __int64 uint64_t;
73 #else
74 #include <stdint.h>
75 #endif
76#endif // !defined(VK_NO_STDINT_H)
77
78#ifdef __cplusplus
79} // extern "C"
80#endif // __cplusplus
81
82#endif
83