vk_platform.h 2.8 KB

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