Function fermium::vulkan::SDL_Vulkan_GetInstanceExtensions
source · pub unsafe extern "C" fn SDL_Vulkan_GetInstanceExtensions(
window: *mut SDL_Window,
pCount: *mut c_uint,
pNames: *mut *const c_char
) -> SDL_bool
Expand description
Get the names of the Vulkan instance extensions needed to create a surface
with SDL_Vulkan_CreateSurface
.
- [in]
window
Window for which the required Vulkan instance extensions should be retrieved (orNULL
). - [in,out]
pCount
pointer to ac_uint
related to the number of required Vulkan instance extensions (see below). - [out]
pNames
pointer to an array to be filled with the required Vulkan instance extensions (orNULL
).
Returns: SDL_TRUE
on success, SDL_FALSE
on error.
If pNames
is NULL
, then the number of required Vulkan instance
extensions is returned in pCount
. Otherwise, pCount
must point to a
variable set to the number of elements in the pNames
array, and on
return the variable is overwritten with the number of names actually
written to pNames
. If pCount
is less than the number of required
extensions, at most pCount
structures will be written. If pCount
is
smaller than the number of required extensions, SDL_FALSE
will be
returned instead of SDL_TRUE
, to indicate that not all the required
extensions were returned.
If window
is not NULL
, it will be checked against its creation flags
to ensure that the Vulkan flag is present. This parameter will be removed
in a future major release.
The returned list of extensions will contain VK_KHR_surface
and zero or
more platform specific extensions
The extension names queried here must be enabled when calling
vkCreateInstance
, otherwise surface creation will fail.
window
should have been created with the SDL_WINDOW_VULKAN
flag, or
be NULL
.
unsigned int count;
// get count of required extensions
if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, NULL))
handle_error();
static const char *const additionalExtensions[] =
{
VK_EXT_DEBUG_REPORT_EXTENSION_NAME, // example additional extension
};
size_t additionalExtensionsCount = sizeof(additionalExtensions) / sizeof(additionalExtensions[0]);
size_t extensionCount = count + additionalExtensionsCount;
const char **names = malloc(sizeof(const char *) * extensionCount);
if(!names)
handle_error();
// get names of required extensions
if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, names))
handle_error();
// copy additional extensions after required extensions
for(size_t i = 0; i < additionalExtensionsCount; i++)
names[i + count] = additionalExtensions[i];
VkInstanceCreateInfo instanceCreateInfo = {};
instanceCreateInfo.enabledExtensionCount = extensionCount;
instanceCreateInfo.ppEnabledExtensionNames = names;
// fill in rest of instanceCreateInfo
VkInstance instance;
// create the Vulkan instance
VkResult result = vkCreateInstance(&instanceCreateInfo, NULL, &instance);
free(names);
See Also: SDL_Vulkan_CreateSurface