SDL_vulkan_internal.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
  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. #ifndef SDL_vulkan_internal_h_
  19. #define SDL_vulkan_internal_h_
  20. #include "SDL_internal.h"
  21. #ifdef SDL_VIDEO_VULKAN
  22. #ifdef SDL_VIDEO_DRIVER_ANDROID
  23. #define VK_USE_PLATFORM_ANDROID_KHR
  24. #endif
  25. #ifdef SDL_VIDEO_DRIVER_COCOA
  26. #define VK_USE_PLATFORM_METAL_EXT
  27. #define VK_USE_PLATFORM_MACOS_MVK
  28. #endif
  29. #ifdef SDL_VIDEO_DRIVER_UIKIT
  30. #define VK_USE_PLATFORM_METAL_EXT
  31. #define VK_USE_PLATFORM_IOS_MVK
  32. #endif
  33. #ifdef SDL_VIDEO_DRIVER_WAYLAND
  34. #define VK_USE_PLATFORM_WAYLAND_KHR
  35. #include "wayland/SDL_waylanddyn.h"
  36. #endif
  37. #ifdef SDL_VIDEO_DRIVER_WINDOWS
  38. #define VK_USE_PLATFORM_WIN32_KHR
  39. #include "../core/windows/SDL_windows.h"
  40. #endif
  41. #ifdef SDL_VIDEO_DRIVER_X11
  42. #define VK_USE_PLATFORM_XLIB_KHR
  43. #define VK_USE_PLATFORM_XCB_KHR
  44. #endif
  45. #define VK_NO_PROTOTYPES
  46. #include "./khronos/vulkan/vulkan.h"
  47. #include <SDL3/SDL_vulkan.h>
  48. extern const char *SDL_Vulkan_GetResultString(VkResult result);
  49. extern VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
  50. PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties,
  51. Uint32 *extensionCount); // free returned list with SDL_free
  52. /* Create a surface directly from a display connected to a physical device
  53. * using the DisplayKHR extension.
  54. * This needs to be passed an instance that was created with the VK_KHR_DISPLAY_EXTENSION_NAME
  55. * extension. */
  56. extern bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr,
  57. VkInstance instance,
  58. const struct VkAllocationCallbacks *allocator,
  59. VkSurfaceKHR *surface);
  60. /* Platform independent base function for destroying the Vulkan surface. Unlike surface
  61. * creation, surface destruction doesn't require platform specific extensions like
  62. * VK_KHR_wayland_surface, VK_KHR_android_surface or VK_EXT_metal_surface. The only
  63. * necessary extension is cross platform VK_KHR_surface, which is a dependency to all
  64. * WSI platform extensions, so we can handle surface destruction in an platform-independent
  65. * manner. */
  66. extern void SDL_Vulkan_DestroySurface_Internal(void *vkGetInstanceProcAddr,
  67. VkInstance instance,
  68. VkSurfaceKHR surface,
  69. const struct VkAllocationCallbacks *allocator);
  70. #else
  71. // No SDL Vulkan support, just include the header for typedefs
  72. #include <SDL3/SDL_vulkan.h>
  73. typedef void (*PFN_vkGetInstanceProcAddr)(void);
  74. typedef int (*PFN_vkEnumerateInstanceExtensionProperties)(void);
  75. #endif // SDL_VIDEO_VULKAN
  76. #endif // SDL_vulkan_internal_h_