1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#ifndef SDL_vulkan_internal_h_
22#define SDL_vulkan_internal_h_
23
24#include "SDL_internal.h"
25
26#ifdef SDL_VIDEO_VULKAN
27#ifdef SDL_VIDEO_DRIVER_ANDROID
28#define VK_USE_PLATFORM_ANDROID_KHR
29#endif
30#ifdef SDL_VIDEO_DRIVER_COCOA
31#define VK_USE_PLATFORM_METAL_EXT
32#define VK_USE_PLATFORM_MACOS_MVK
33#endif
34#ifdef SDL_VIDEO_DRIVER_UIKIT
35#define VK_USE_PLATFORM_METAL_EXT
36#define VK_USE_PLATFORM_IOS_MVK
37#endif
38#ifdef SDL_VIDEO_DRIVER_WAYLAND
39#define VK_USE_PLATFORM_WAYLAND_KHR
40#include "wayland/SDL_waylanddyn.h"
41#endif
42#ifdef SDL_VIDEO_DRIVER_WINDOWS
43#define VK_USE_PLATFORM_WIN32_KHR
44#include "../core/windows/SDL_windows.h"
45#endif
46#ifdef SDL_VIDEO_DRIVER_X11
47#define VK_USE_PLATFORM_XLIB_KHR
48#define VK_USE_PLATFORM_XCB_KHR
49#endif
50
51#define VK_NO_PROTOTYPES
52#include "./khronos/vulkan/vulkan.h"
53
54#include <SDL3/SDL_vulkan.h>
55
56extern const char *SDL_Vulkan_GetResultString(VkResult result);
57
58extern VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
59 PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties,
60 Uint32 *extensionCount); // free returned list with SDL_free
61
62/* Create a surface directly from a display connected to a physical device
63 * using the DisplayKHR extension.
64 * This needs to be passed an instance that was created with the VK_KHR_DISPLAY_EXTENSION_NAME
65 * extension. */
66extern bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr,
67 VkInstance instance,
68 const struct VkAllocationCallbacks *allocator,
69 VkSurfaceKHR *surface);
70
71/* Platform independent base function for destroying the Vulkan surface. Unlike surface
72 * creation, surface destruction doesn't require platform specific extensions like
73 * VK_KHR_wayland_surface, VK_KHR_android_surface or VK_EXT_metal_surface. The only
74 * necessary extension is cross platform VK_KHR_surface, which is a dependency to all
75 * WSI platform extensions, so we can handle surface destruction in an platform-independent
76 * manner. */
77extern void SDL_Vulkan_DestroySurface_Internal(void *vkGetInstanceProcAddr,
78 VkInstance instance,
79 VkSurfaceKHR surface,
80 const struct VkAllocationCallbacks *allocator);
81#else
82
83// No SDL Vulkan support, just include the header for typedefs
84#include <SDL3/SDL_vulkan.h>
85
86typedef void (*PFN_vkGetInstanceProcAddr)(void);
87typedef int (*PFN_vkEnumerateInstanceExtensionProperties)(void);
88
89#endif // SDL_VIDEO_VULKAN
90
91#endif // SDL_vulkan_internal_h_
92