vk_platform.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // File: vk_platform.h
  3. //
  4. /*
  5. ** Copyright (c) 2014-2016 The Khronos Group Inc.
  6. **
  7. ** Permission is hereby granted, free of charge, to any person obtaining a
  8. ** copy of this software and/or associated documentation files (the
  9. ** "Materials"), to deal in the Materials without restriction, including
  10. ** without limitation the rights to use, copy, modify, merge, publish,
  11. ** distribute, sublicense, and/or sell copies of the Materials, and to
  12. ** permit persons to whom the Materials are furnished to do so, subject to
  13. ** the following conditions:
  14. **
  15. ** The above copyright notice and this permission notice shall be included
  16. ** in all copies or substantial portions of the Materials.
  17. **
  18. ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  22. ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
  25. */
  26. #ifndef __VK_PLATFORM_H__
  27. #define __VK_PLATFORM_H__
  28. #ifdef __cplusplus
  29. extern "C"
  30. {
  31. #endif // __cplusplus
  32. /*
  33. ***************************************************************************************************
  34. * Platform-specific directives and type declarations
  35. ***************************************************************************************************
  36. */
  37. /* Platform-specific calling convention macros.
  38. *
  39. * Platforms should define these so that Vulkan clients call Vulkan commands
  40. * with the same calling conventions that the Vulkan implementation expects.
  41. *
  42. * VKAPI_ATTR - Placed before the return type in function declarations.
  43. * Useful for C++11 and GCC/Clang-style function attribute syntax.
  44. * VKAPI_CALL - Placed after the return type in function declarations.
  45. * Useful for MSVC-style calling convention syntax.
  46. * VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
  47. *
  48. * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
  49. * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
  50. */
  51. #if defined(_WIN32)
  52. // On Windows, Vulkan commands use the stdcall convention
  53. #define VKAPI_ATTR
  54. #define VKAPI_CALL __stdcall
  55. #define VKAPI_PTR VKAPI_CALL
  56. #elif defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
  57. // Android does not support Vulkan in native code using the "armeabi" ABI.
  58. #error "Vulkan requires the 'armeabi-v7a' or 'armeabi-v7a-hard' ABI on 32-bit ARM CPUs"
  59. #elif defined(__ANDROID__) && defined(__ARM_ARCH_7A__)
  60. // On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling
  61. // convention, even if the application's native code is compiled with the
  62. // armeabi-v7a calling convention.
  63. #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
  64. #define VKAPI_CALL
  65. #define VKAPI_PTR VKAPI_ATTR
  66. #else
  67. // On other platforms, use the default calling convention
  68. #define VKAPI_ATTR
  69. #define VKAPI_CALL
  70. #define VKAPI_PTR
  71. #endif
  72. #include <stddef.h>
  73. #if !defined(VK_NO_STDINT_H)
  74. #if defined(_MSC_VER) && (_MSC_VER < 1600)
  75. typedef signed __int8 int8_t;
  76. typedef unsigned __int8 uint8_t;
  77. typedef signed __int16 int16_t;
  78. typedef unsigned __int16 uint16_t;
  79. typedef signed __int32 int32_t;
  80. typedef unsigned __int32 uint32_t;
  81. typedef signed __int64 int64_t;
  82. typedef unsigned __int64 uint64_t;
  83. #else
  84. #include <stdint.h>
  85. #endif
  86. #endif // !defined(VK_NO_STDINT_H)
  87. #ifdef __cplusplus
  88. } // extern "C"
  89. #endif // __cplusplus
  90. // Platform-specific headers required by platform window system extensions.
  91. // These are enabled prior to #including "vulkan.h". The same enable then
  92. // controls inclusion of the extension interfaces in vulkan.h.
  93. #ifdef VK_USE_PLATFORM_ANDROID_KHR
  94. #include <android/native_window.h>
  95. #endif
  96. #ifdef VK_USE_PLATFORM_MIR_KHR
  97. #include <mir_toolkit/client_types.h>
  98. #endif
  99. #ifdef VK_USE_PLATFORM_WAYLAND_KHR
  100. #include <wayland-client.h>
  101. #endif
  102. #ifdef VK_USE_PLATFORM_WIN32_KHR
  103. #include <windows.h>
  104. #endif
  105. #ifdef VK_USE_PLATFORM_XLIB_KHR
  106. #include <X11/Xlib.h>
  107. #endif
  108. #ifdef VK_USE_PLATFORM_XCB_KHR
  109. #include <xcb/xcb.h>
  110. #endif
  111. #endif // __VK_PLATFORM_H__