summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Halase <jordan@halase.me>2019-10-29 21:40:16 -0500
committerJordan Halase <jordan@halase.me>2019-10-29 21:40:16 -0500
commitd9c15249e6a92fe92f741610b9fdb0c8d012e722 (patch)
treeb750972d5455a05fa9c896f9ee92a25801a11a04
parent06e6b24dd81ca45b4d2df12f727a20f8f84a7893 (diff)
Fix memory leak and add check for swapchain support
-rw-r--r--main.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/main.c b/main.c
index bc1c36a..dde113a 100644
--- a/main.c
+++ b/main.c
@@ -575,8 +575,26 @@ static int isDeviceSuitable(const struct RenderVulkan *const vk,
if (canSurface) break;
}
}
+ free(queueProperties);
if (g >= nQueueFamilies) {
/* We only support graphics and present on the same queue family. */
+ printf("No graphics+support queue families found on this device\n");
+ return 0;
+ }
+ VkBool32 canSwapchain = 0;
+ uint32_t nExtensions;
+ vk->api->vkEnumerateDeviceExtensionProperties(pd, NULL, &nExtensions, NULL);
+ VkExtensionProperties *availableExtensions = malloc(nExtensions * sizeof(*availableExtensions));
+ vk->api->vkEnumerateDeviceExtensionProperties(pd, NULL, &nExtensions, availableExtensions);
+ for (uint32_t i = 0; i < nExtensions; ++i) {
+ if (!strcmp(availableExtensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME)) {
+ canSwapchain = 1;
+ break;
+ }
+ }
+ free(availableExtensions);
+ if (!canSwapchain) {
+ printf("Cannot use a swapchain on this device\n");
return 0;
}
*graphicsIndex = g;