SDL_bool
SDL_Vulkan_GetInstanceExtensions(SDL_Window* window, unsigned int* count, char** names)
{
- if (!count) {
- SDL_SetError("count ptr is null");
- return SDL_FALSE;
- }
+ CHECK_WINDOW_MAGIC(window, SDL_FALSE);
if (!(window->flags & SDL_WINDOW_VULKAN)) {
SDL_SetError("Not setup with SDL_WINDOW_VULKAN flags");
return SDL_FALSE;
}
+ if (!count) {
+ SDL_SetError("count pointer is NULL");
+ return SDL_FALSE;
+ }
+
const char *driver = SDL_GetCurrentVideoDriver();
if (!driver) {
SDL_SetError("Current video driveer is NULL");
SDL_bool
SDL_Vulkan_CreateSurface(SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface)
{
- if (!window) {
- SDL_SetError("'window' is null");
- return SDL_FALSE;
- }
+ CHECK_WINDOW_MAGIC(window, SDL_FALSE);
- if (instance == 0) {
+ if (!instance) {
SDL_SetError("'instance' is null");
return SDL_FALSE;
}
+ if (!surface) {
+ SDL_SetError("'surface' is null");
+ return SDL_FALSE;
+ }
+
return _this->vulkan_CreateSurface(_this, window, instance, surface);
}
return SDL_FALSE;
}
+ if (!names) *count = 0;
+
err = _this->vk_data->vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
if (err < 0) {
SDL_SetError("Fail to get Instance extension");
NULL, &instance_extension_count, instance_extensions);
for (i = 0; i < instance_extension_count; i++) {
if (!strcmp(VK_KHR_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
- names[enabled_extension_count++] = VK_KHR_SURFACE_EXTENSION_NAME;
+ if (names && (*count > 0)) names[enabled_extension_count++] = VK_KHR_SURFACE_EXTENSION_NAME;
+ else enabled_extension_count++;
}
if (!strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
- names[enabled_extension_count++] = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
- }
-
- if (enabled_extension_count > 64) {
- SDL_SetError("Insufficient capacity for extension names");
- free(instance_extensions);
- return SDL_FALSE;
+ if (names && (*count > 0)) names[enabled_extension_count++] = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
+ else enabled_extension_count++;
}
}
free(instance_extensions);
}
- *count = enabled_extension_count;
+
+ if (*count == 0)
+ *count = enabled_extension_count;
+
return SDL_TRUE;
}