From e99a55baa8f353a42b43aa86e7dddc3d8b68d5dc Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Tue, 19 Nov 2024 14:51:59 -0600 Subject: render: create a vkqueue struct for Vulkan queues Add a vkqueue struct to the Vulkan device interface and shift queue operations to helper functions that interact with this new struct. This makes the initialization routines more readable and simplifies the interface. Signed-off-by: Danny Holman --- render/vulkan/swapchain.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'render/vulkan/swapchain.c') diff --git a/render/vulkan/swapchain.c b/render/vulkan/swapchain.c index 1247c9a..c6cea29 100644 --- a/render/vulkan/swapchain.c +++ b/render/vulkan/swapchain.c @@ -37,8 +37,8 @@ struct vkswapchain* create_swapchain(struct vksurface *surface, struct vkdev *de cinfo.presentMode = VK_PRESENT_MODE_MAILBOX_KHR; cinfo.clipped = VK_TRUE; cinfo.oldSwapchain = NULL; - if (dev->gfx_index != dev->pres_index) { - uint32_t qfams[] = {dev->gfx_index, dev->pres_index}; + if (dev->queues[0].index != dev->queues[3].index) { + uint32_t qfams[] = {dev->queues[0].index, dev->queues[3].index}; cinfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT; cinfo.queueFamilyIndexCount = 2; cinfo.pQueueFamilyIndices = qfams; @@ -57,9 +57,10 @@ struct vkswapchain* create_swapchain(struct vksurface *surface, struct vkdev *de VkImageViewCreateInfo vcinfo; for (uint32_t i = 0; i < swapchain->img_count; i++) { vcinfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + vcinfo.pNext = NULL; vcinfo.image = swapchain->images[i]; vcinfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - vcinfo.format = swapchain->format; + vcinfo.format = swapchain->format_khr.format; vcinfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; vcinfo.subresourceRange.baseMipLevel = 0; vcinfo.subresourceRange.levelCount = 1; @@ -103,10 +104,10 @@ void vkswapchain_present(struct vkswapchain *swapchain, struct vkdev *dev) { pinfo.pWaitSemaphores = &swapchain->render_complete; pinfo.swapchainCount = 1; pinfo.pSwapchains = &swapchain->handle; - pinfo.pImageIndices = &dev->pres_index; + pinfo.pImageIndices = &dev->queues[3].index; pinfo.pResults = NULL; - VkResult res = vkQueuePresentKHR(dev->pres_queue, &pinfo); + VkResult res = vkQueuePresentKHR(dev->queues[3].handle, &pinfo); if (res == VK_ERROR_OUT_OF_DATE_KHR || res == VK_SUBOPTIMAL_KHR) STUBBED("Recreate swapchain"); else if (res != VK_SUCCESS) -- cgit v1.2.3