can someone do research and figure out why the swapchain is broken while im gone

liteCraft
hYdos 2020-03-05 08:08:36 +10:00
parent 4bb3409cef
commit adfdfccd64
2 changed files with 11 additions and 14 deletions

View File

@ -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.io.VKWindow;
import com.github.hydos.ginger.engine.vulkan.render.Swapchain;
import com.github.hydos.ginger.engine.vulkan.utils.VKUtils; import com.github.hydos.ginger.engine.vulkan.utils.VKUtils;
public class GingerVK public class GingerVK
@ -13,5 +14,6 @@ public class GingerVK
VKWindow.createSurface(); VKWindow.createSurface();
VKUtils.createPhysicalDevice(); VKUtils.createPhysicalDevice();
VKUtils.createLogicalDevice(); VKUtils.createLogicalDevice();
Swapchain.createSwapChain();
} }
} }

View File

@ -109,18 +109,14 @@ public class Swapchain
imageCount.put(0, swapChainSupport.capabilities.maxImageCount()); imageCount.put(0, swapChainSupport.capabilities.maxImageCount());
} }
VkSwapchainCreateInfoKHR createInfo = VkSwapchainCreateInfoKHR.callocStack(stack); VkSwapchainCreateInfoKHR createInfo = VkSwapchainCreateInfoKHR.callocStack(stack)
.sType(KHRSwapchain.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR)
createInfo.sType(KHRSwapchain.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR); .minImageCount(imageCount.get(0))
createInfo.surface(VKConstants.windowSurface); .imageFormat(surfaceFormat.format())
.imageColorSpace(surfaceFormat.colorSpace())
// Image settings .imageExtent(extent)
createInfo.minImageCount(imageCount.get(0)); .imageArrayLayers(1)
createInfo.imageFormat(surfaceFormat.format()); .imageUsage(VK12.VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
createInfo.imageColorSpace(surfaceFormat.colorSpace());
createInfo.imageExtent(extent);
createInfo.imageArrayLayers(1);
createInfo.imageUsage(VK12.VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
QueueFamilyIndices indices = VKUtils.findQueueFamilies(); QueueFamilyIndices indices = VKUtils.findQueueFamilies();
@ -140,8 +136,7 @@ public class Swapchain
LongBuffer pSwapChain = stack.longs(VK12.VK_NULL_HANDLE); LongBuffer pSwapChain = stack.longs(VK12.VK_NULL_HANDLE);
int result = KHRSwapchain.vkCreateSwapchainKHR( int result = KHRSwapchain.vkCreateSwapchainKHR(VKConstants.device, createInfo, null, pSwapChain);
VKConstants.device, createInfo, null, pSwapChain);
if(result != VK12.VK_SUCCESS) { if(result != VK12.VK_SUCCESS) {
throw new RuntimeException("Failed to create swap chain reason: " + VKUtils.translateVulkanResult(result)); throw new RuntimeException("Failed to create swap chain reason: " + VKUtils.translateVulkanResult(result));
} }