101e04c3fSmrg//
201e04c3fSmrg// File: vk_platform.h
301e04c3fSmrg//
401e04c3fSmrg/*
57ec681f3Smrg** Copyright 2014-2021 The Khronos Group Inc.
601e04c3fSmrg**
77ec681f3Smrg** SPDX-License-Identifier: Apache-2.0
801e04c3fSmrg*/
901e04c3fSmrg
1001e04c3fSmrg
1101e04c3fSmrg#ifndef VK_PLATFORM_H_
1201e04c3fSmrg#define VK_PLATFORM_H_
1301e04c3fSmrg
1401e04c3fSmrg#ifdef __cplusplus
1501e04c3fSmrgextern "C"
1601e04c3fSmrg{
1701e04c3fSmrg#endif // __cplusplus
1801e04c3fSmrg
1901e04c3fSmrg/*
2001e04c3fSmrg***************************************************************************************************
2101e04c3fSmrg*   Platform-specific directives and type declarations
2201e04c3fSmrg***************************************************************************************************
2301e04c3fSmrg*/
2401e04c3fSmrg
2501e04c3fSmrg/* Platform-specific calling convention macros.
2601e04c3fSmrg *
2701e04c3fSmrg * Platforms should define these so that Vulkan clients call Vulkan commands
2801e04c3fSmrg * with the same calling conventions that the Vulkan implementation expects.
2901e04c3fSmrg *
3001e04c3fSmrg * VKAPI_ATTR - Placed before the return type in function declarations.
3101e04c3fSmrg *              Useful for C++11 and GCC/Clang-style function attribute syntax.
3201e04c3fSmrg * VKAPI_CALL - Placed after the return type in function declarations.
3301e04c3fSmrg *              Useful for MSVC-style calling convention syntax.
3401e04c3fSmrg * VKAPI_PTR  - Placed between the '(' and '*' in function pointer types.
3501e04c3fSmrg *
3601e04c3fSmrg * Function declaration:  VKAPI_ATTR void VKAPI_CALL vkCommand(void);
3701e04c3fSmrg * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
3801e04c3fSmrg */
3901e04c3fSmrg#if defined(_WIN32)
4001e04c3fSmrg    // On Windows, Vulkan commands use the stdcall convention
4101e04c3fSmrg    #define VKAPI_ATTR
4201e04c3fSmrg    #define VKAPI_CALL __stdcall
4301e04c3fSmrg    #define VKAPI_PTR  VKAPI_CALL
4401e04c3fSmrg#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
4501e04c3fSmrg    #error "Vulkan isn't supported for the 'armeabi' NDK ABI"
4601e04c3fSmrg#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
4701e04c3fSmrg    // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
4801e04c3fSmrg    // calling convention, i.e. float parameters are passed in registers. This
4901e04c3fSmrg    // is true even if the rest of the application passes floats on the stack,
5001e04c3fSmrg    // as it does by default when compiling for the armeabi-v7a NDK ABI.
5101e04c3fSmrg    #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
5201e04c3fSmrg    #define VKAPI_CALL
5301e04c3fSmrg    #define VKAPI_PTR  VKAPI_ATTR
5401e04c3fSmrg#else
5501e04c3fSmrg    // On other platforms, use the default calling convention
5601e04c3fSmrg    #define VKAPI_ATTR
5701e04c3fSmrg    #define VKAPI_CALL
5801e04c3fSmrg    #define VKAPI_PTR
5901e04c3fSmrg#endif
6001e04c3fSmrg
617ec681f3Smrg#if !defined(VK_NO_STDDEF_H)
627ec681f3Smrg    #include <stddef.h>
637ec681f3Smrg#endif // !defined(VK_NO_STDDEF_H)
6401e04c3fSmrg
6501e04c3fSmrg#if !defined(VK_NO_STDINT_H)
6601e04c3fSmrg    #if defined(_MSC_VER) && (_MSC_VER < 1600)
6701e04c3fSmrg        typedef signed   __int8  int8_t;
6801e04c3fSmrg        typedef unsigned __int8  uint8_t;
6901e04c3fSmrg        typedef signed   __int16 int16_t;
7001e04c3fSmrg        typedef unsigned __int16 uint16_t;
7101e04c3fSmrg        typedef signed   __int32 int32_t;
7201e04c3fSmrg        typedef unsigned __int32 uint32_t;
7301e04c3fSmrg        typedef signed   __int64 int64_t;
7401e04c3fSmrg        typedef unsigned __int64 uint64_t;
7501e04c3fSmrg    #else
7601e04c3fSmrg        #include <stdint.h>
7701e04c3fSmrg    #endif
7801e04c3fSmrg#endif // !defined(VK_NO_STDINT_H)
7901e04c3fSmrg
8001e04c3fSmrg#ifdef __cplusplus
8101e04c3fSmrg} // extern "C"
8201e04c3fSmrg#endif // __cplusplus
8301e04c3fSmrg
8401e04c3fSmrg#endif
85