🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
8.3 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 2017, Mark Callow
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_vulkan.h
  20. *
  21. * Header file for functions to creating Vulkan surfaces on SDL windows.
  22. */
  23. #ifndef SDL_vulkan_h_
  24. #define SDL_vulkan_h_
  25. #include "SDL_video.h"
  26. #include "begin_code.h"
  27. /* Set up for C function definitions, even when using C++ */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* Avoid including vulkan.h, don't define VkInstance if it's already included */
  32. #ifdef VULKAN_H_
  33. #define NO_SDL_VULKAN_TYPEDEFS
  34. #endif
  35. #ifndef NO_SDL_VULKAN_TYPEDEFS
  36. #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
  37. #if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
  38. #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
  39. #else
  40. #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
  41. #endif
  42. VK_DEFINE_HANDLE(VkInstance)
  43. VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
  44. #endif /* !NO_SDL_VULKAN_TYPEDEFS */
  45. typedef VkInstance SDL_vulkanInstance;
  46. typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */
  47. /**
  48. * \name Vulkan support functions
  49. *
  50. * \note SDL_Vulkan_GetInstanceExtensions & SDL_Vulkan_CreateSurface API
  51. * is compatable with Tizen's implementation of Vulkan in SDL.
  52. */
  53. /* @{ */
  54. /**
  55. * Dynamically load the Vulkan loader library.
  56. *
  57. * This should be called after initializing the video driver, but before
  58. * creating any Vulkan windows. If no Vulkan loader library is loaded, the
  59. * default library will be loaded upon creation of the first Vulkan window.
  60. *
  61. * It is fairly common for Vulkan applications to link with libvulkan instead
  62. * of explicitly loading it at run time. This will work with SDL provided the
  63. * application links to a dynamic library and both it and SDL use the same
  64. * search path.
  65. *
  66. * If you specify a non-NULL `path`, an application should retrieve all of the
  67. * Vulkan functions it uses from the dynamic library using
  68. * SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee `path` points
  69. * to the same vulkan loader library the application linked to.
  70. *
  71. * On Apple devices, if `path` is NULL, SDL will attempt to find the
  72. * `vkGetInstanceProcAddr` address within all the Mach-O images of the current
  73. * process. This is because it is fairly common for Vulkan applications to
  74. * link with libvulkan (and historically MoltenVK was provided as a static
  75. * library). If it is not found, on macOS, SDL will attempt to load
  76. * `vulkan.framework/vulkan`, `libvulkan.1.dylib`,
  77. * `MoltenVK.framework/MoltenVK`, and `libMoltenVK.dylib`, in that order. On
  78. * iOS, SDL will attempt to load `libMoltenVK.dylib`. Applications using a
  79. * dynamic framework or .dylib must ensure it is included in its application
  80. * bundle.
  81. *
  82. * On non-Apple devices, application linking with a static libvulkan is not
  83. * supported. Either do not link to the Vulkan loader or link to a dynamic
  84. * library version.
  85. *
  86. * \param path The platform dependent Vulkan loader library name or NULL
  87. * \returns 0 on success or -1 if the library couldn't be loaded; call
  88. * SDL_GetError() for more information.
  89. *
  90. * \since This function is available since SDL 2.0.6.
  91. *
  92. * \sa SDL_Vulkan_GetVkInstanceProcAddr
  93. * \sa SDL_Vulkan_UnloadLibrary
  94. */
  95. extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
  96. /**
  97. * Get the address of the `vkGetInstanceProcAddr` function.
  98. *
  99. * This should be called after either calling SDL_Vulkan_LoadLibrary() or
  100. * creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag.
  101. *
  102. * \returns the function pointer for `vkGetInstanceProcAddr` or NULL on error.
  103. *
  104. * \since This function is available since SDL 2.0.6.
  105. */
  106. extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void);
  107. /**
  108. * Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary()
  109. *
  110. * \since This function is available since SDL 2.0.6.
  111. *
  112. * \sa SDL_Vulkan_LoadLibrary
  113. */
  114. extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
  115. /**
  116. * Get the names of the Vulkan instance extensions needed to create a surface
  117. * with SDL_Vulkan_CreateSurface.
  118. *
  119. * If `pNames` is NULL, then the number of required Vulkan instance extensions
  120. * is returned in `pCount`. Otherwise, `pCount` must point to a variable set
  121. * to the number of elements in the `pNames` array, and on return the variable
  122. * is overwritten with the number of names actually written to `pNames`. If
  123. * `pCount` is less than the number of required extensions, at most `pCount`
  124. * structures will be written. If `pCount` is smaller than the number of
  125. * required extensions, SDL_FALSE will be returned instead of SDL_TRUE, to
  126. * indicate that not all the required extensions were returned.
  127. *
  128. * The `window` parameter is currently needed to be valid as of SDL 2.0.8,
  129. * however, this parameter will likely be removed in future releases
  130. *
  131. * \param window A window for which the required Vulkan instance extensions
  132. * should be retrieved (will be deprecated in a future release)
  133. * \param pCount A pointer to an unsigned int corresponding to the number of
  134. * extensions to be returned
  135. * \param pNames NULL or a pointer to an array to be filled with required
  136. * Vulkan instance extensions
  137. * \returns SDL_TRUE on success, SDL_FALSE on error.
  138. *
  139. * \since This function is available since SDL 2.0.6.
  140. *
  141. * \sa SDL_Vulkan_CreateSurface
  142. */
  143. extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions(SDL_Window *window,
  144. unsigned int *pCount,
  145. const char **pNames);
  146. /**
  147. * Create a Vulkan rendering surface for a window.
  148. *
  149. * The `window` must have been created with the `SDL_WINDOW_VULKAN` flag and
  150. * `instance` must have been created with extensions returned by
  151. * SDL_Vulkan_GetInstanceExtensions() enabled.
  152. *
  153. * \param window The window to which to attach the Vulkan surface
  154. * \param instance The Vulkan instance handle
  155. * \param surface A pointer to a VkSurfaceKHR handle to output the newly
  156. * created surface
  157. * \returns SDL_TRUE on success, SDL_FALSE on error.
  158. *
  159. * \since This function is available since SDL 2.0.6.
  160. *
  161. * \sa SDL_Vulkan_GetInstanceExtensions
  162. * \sa SDL_Vulkan_GetDrawableSize
  163. */
  164. extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window,
  165. VkInstance instance,
  166. VkSurfaceKHR* surface);
  167. /**
  168. * Get the size of the window's underlying drawable dimensions in pixels.
  169. *
  170. * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI
  171. * drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a
  172. * platform with high-DPI support (Apple calls this "Retina"), and not
  173. * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint.
  174. *
  175. * \param window an SDL_Window for which the size is to be queried
  176. * \param w Pointer to the variable to write the width to or NULL
  177. * \param h Pointer to the variable to write the height to or NULL
  178. *
  179. * \since This function is available since SDL 2.0.6.
  180. *
  181. * \sa SDL_GetWindowSize
  182. * \sa SDL_CreateWindow
  183. * \sa SDL_Vulkan_CreateSurface
  184. */
  185. extern DECLSPEC void SDLCALL SDL_Vulkan_GetDrawableSize(SDL_Window * window,
  186. int *w, int *h);
  187. /* @} *//* Vulkan support functions */
  188. /* Ends C function definitions when using C++ */
  189. #ifdef __cplusplus
  190. }
  191. #endif
  192. #include "close_code.h"
  193. #endif /* SDL_vulkan_h_ */