SDL 3.0
|
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_begin_code.h>
#include <SDL3/SDL_close_code.h>
Go to the source code of this file.
Macros | |
#define | VK_DEFINE_HANDLE(object) typedef struct object##_T* object; |
#define | VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; |
Functions | |
Vulkan support functions | |
int | SDL_Vulkan_LoadLibrary (const char *path) |
SDL_FunctionPointer | SDL_Vulkan_GetVkGetInstanceProcAddr (void) |
void | SDL_Vulkan_UnloadLibrary (void) |
char const *const * | SDL_Vulkan_GetInstanceExtensions (Uint32 *count) |
int | SDL_Vulkan_CreateSurface (SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface) |
void | SDL_Vulkan_DestroySurface (VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator) |
SDL_bool | SDL_Vulkan_GetPresentationSupport (VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex) |
#define VK_DEFINE_HANDLE | ( | object | ) | typedef struct object##_T* object; |
Functions for creating Vulkan surfaces on SDL windows.
Definition at line 45 of file SDL_vulkan.h.
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE | ( | object | ) | typedef uint64_t object; |
Definition at line 50 of file SDL_vulkan.h.
|
extern |
Create a Vulkan rendering surface for a window.
The window
must have been created with the SDL_WINDOW_VULKAN
flag and instance
must have been created with extensions returned by SDL_Vulkan_GetInstanceExtensions() enabled.
If allocator
is NULL, Vulkan will use the system default allocator. This argument is passed directly to Vulkan and isn't used by SDL itself.
window | the window to which to attach the Vulkan surface. |
instance | the Vulkan instance handle. |
allocator | a VkAllocationCallbacks struct, which lets the app set the allocator that creates the surface. Can be NULL. |
surface | a pointer to a VkSurfaceKHR handle to output the newly created surface. |
|
extern |
Destroy the Vulkan rendering surface of a window.
This should be called before SDL_DestroyWindow, if SDL_Vulkan_CreateSurface was called after SDL_CreateWindow.
The instance
must have been created with extensions returned by SDL_Vulkan_GetInstanceExtensions() enabled and surface
must have been created successfully by an SDL_Vulkan_CreateSurface() call.
If allocator
is NULL, Vulkan will use the system default allocator. This argument is passed directly to Vulkan and isn't used by SDL itself.
instance | the Vulkan instance handle. |
surface | vkSurfaceKHR handle to destroy. |
allocator | a VkAllocationCallbacks struct, which lets the app set the allocator that destroys the surface. Can be NULL. |
|
extern |
Get the Vulkan instance extensions needed for vkCreateInstance.
This should be called after either calling SDL_Vulkan_LoadLibrary() or creating an SDL_Window with the SDL_WINDOW_VULKAN
flag.
On return, the variable pointed to by count
will be set to the number of elements returned, suitable for using with VkInstanceCreateInfo::enabledExtensionCount, and the returned array can be used with VkInstanceCreateInfo::ppEnabledExtensionNames, for calling Vulkan's vkCreateInstance API.
You should not free the returned array; it is owned by SDL.
count | a pointer filled in with the number of extensions returned. |
|
extern |
Query support for presentation via a given physical device and queue family.
The instance
must have been created with extensions returned by SDL_Vulkan_GetInstanceExtensions() enabled.
instance | the Vulkan instance handle. |
physicalDevice | a valid Vulkan physical device handle. |
queueFamilyIndex | a valid queue family index for the given physical device. |
|
extern |
Get the address of the vkGetInstanceProcAddr
function.
This should be called after either calling SDL_Vulkan_LoadLibrary() or creating an SDL_Window with the SDL_WINDOW_VULKAN
flag.
The actual type of the returned function pointer is PFN_vkGetInstanceProcAddr, but that isn't available because the Vulkan headers are not included here. You should cast the return value of this function to that type, e.g.
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr();
vkGetInstanceProcAddr
or NULL on failure; call SDL_GetError() for more information.
|
extern |
Dynamically load the Vulkan loader library.
This should be called after initializing the video driver, but before creating any Vulkan windows. If no Vulkan loader library is loaded, the default library will be loaded upon creation of the first Vulkan window.
It is fairly common for Vulkan applications to link with libvulkan instead of explicitly loading it at run time. This will work with SDL provided the application links to a dynamic library and both it and SDL use the same search path.
If you specify a non-NULL path
, an application should retrieve all of the Vulkan functions it uses from the dynamic library using SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee path
points to the same vulkan loader library the application linked to.
On Apple devices, if path
is NULL, SDL will attempt to find the vkGetInstanceProcAddr
address within all the Mach-O images of the current process. This is because it is fairly common for Vulkan applications to link with libvulkan (and historically MoltenVK was provided as a static library). If it is not found, on macOS, SDL will attempt to load vulkan.framework/vulkan
, libvulkan.1.dylib
, MoltenVK.framework/MoltenVK
, and libMoltenVK.dylib
, in that order. On iOS, SDL will attempt to load libMoltenVK.dylib
. Applications using a dynamic framework or .dylib must ensure it is included in its application bundle.
On non-Apple devices, application linking with a static libvulkan is not supported. Either do not link to the Vulkan loader or link to a dynamic library version.
path | the platform dependent Vulkan loader library name or NULL. |
|
extern |
Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary().