From adfdfccd64e22014b2a989da7951f72e983d54cd Mon Sep 17 00:00:00 2001 From: hYdos Date: Thu, 5 Mar 2020 08:08:36 +1000 Subject: [PATCH] can someone do research and figure out why the swapchain is broken while im gone --- .../ginger/engine/vulkan/api/GingerVK.java | 2 ++ .../engine/vulkan/render/Swapchain.java | 23 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/github/hydos/ginger/engine/vulkan/api/GingerVK.java b/src/main/java/com/github/hydos/ginger/engine/vulkan/api/GingerVK.java index 0ed1cde..576cf0e 100644 --- a/src/main/java/com/github/hydos/ginger/engine/vulkan/api/GingerVK.java +++ b/src/main/java/com/github/hydos/ginger/engine/vulkan/api/GingerVK.java @@ -2,6 +2,7 @@ package com.github.hydos.ginger.engine.vulkan.api; import com.github.hydos.ginger.engine.vulkan.io.VKWindow; +import com.github.hydos.ginger.engine.vulkan.render.Swapchain; import com.github.hydos.ginger.engine.vulkan.utils.VKUtils; public class GingerVK @@ -13,5 +14,6 @@ public class GingerVK VKWindow.createSurface(); VKUtils.createPhysicalDevice(); VKUtils.createLogicalDevice(); + Swapchain.createSwapChain(); } } diff --git a/src/main/java/com/github/hydos/ginger/engine/vulkan/render/Swapchain.java b/src/main/java/com/github/hydos/ginger/engine/vulkan/render/Swapchain.java index ccf278e..6c7d4a3 100644 --- a/src/main/java/com/github/hydos/ginger/engine/vulkan/render/Swapchain.java +++ b/src/main/java/com/github/hydos/ginger/engine/vulkan/render/Swapchain.java @@ -109,18 +109,14 @@ public class Swapchain imageCount.put(0, swapChainSupport.capabilities.maxImageCount()); } - VkSwapchainCreateInfoKHR createInfo = VkSwapchainCreateInfoKHR.callocStack(stack); - - createInfo.sType(KHRSwapchain.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR); - createInfo.surface(VKConstants.windowSurface); - - // Image settings - createInfo.minImageCount(imageCount.get(0)); - createInfo.imageFormat(surfaceFormat.format()); - createInfo.imageColorSpace(surfaceFormat.colorSpace()); - createInfo.imageExtent(extent); - createInfo.imageArrayLayers(1); - createInfo.imageUsage(VK12.VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); + VkSwapchainCreateInfoKHR createInfo = VkSwapchainCreateInfoKHR.callocStack(stack) + .sType(KHRSwapchain.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR) + .minImageCount(imageCount.get(0)) + .imageFormat(surfaceFormat.format()) + .imageColorSpace(surfaceFormat.colorSpace()) + .imageExtent(extent) + .imageArrayLayers(1) + .imageUsage(VK12.VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); QueueFamilyIndices indices = VKUtils.findQueueFamilies(); @@ -140,8 +136,7 @@ public class Swapchain LongBuffer pSwapChain = stack.longs(VK12.VK_NULL_HANDLE); - int result = KHRSwapchain.vkCreateSwapchainKHR( - VKConstants.device, createInfo, null, pSwapChain); + int result = KHRSwapchain.vkCreateSwapchainKHR(VKConstants.device, createInfo, null, pSwapChain); if(result != VK12.VK_SUCCESS) { throw new RuntimeException("Failed to create swap chain reason: " + VKUtils.translateVulkanResult(result)); }