Vulkan swapchain creation error

SwapChainSupportDetails swapChainSupport = QuerySwapChainSupport(physicalDevice);

			VkSurfaceFormatKHR surfaceFormat = ChooseSwapSurfaceFormat(swapChainSupport.formats);
			VkPresentModeKHR presentMode = ChooseSwapPresentMode(swapChainSupport.presentModes);
			VkExtent2D extent = ChooseSwapExtent(swapChainSupport.capabilities);

			uint32_t imageCount = swapChainSupport.capabilities.minImageCount + 1;

			if (swapChainSupport.capabilities.maxImageCount > 0 && imageCount > swapChainSupport.capabilities.maxImageCount) {
				imageCount = swapChainSupport.capabilities.maxImageCount;
			}

			VkSwapchainCreateInfoKHR swapchainInfo{};
			swapchainInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
			swapchainInfo.surface = m_surface;
			swapchainInfo.minImageCount = imageCount;
			swapchainInfo.imageFormat = surfaceFormat.format;
			swapchainInfo.imageColorSpace = surfaceFormat.colorSpace;
			swapchainInfo.imageExtent = extent;
			swapchainInfo.imageArrayLayers = 1;
			swapchainInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;

			QueueFamilyIndices indices = FindQueueFamilies(physicalDevice);
			uint32_t queueFamilyIndices[] = { indices.graphicsFamily.value(), indices.presentFamily.value() };

			if (indices.graphicsFamily != indices.presentFamily) {
				swapchainInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
				swapchainInfo.queueFamilyIndexCount = 2;
				swapchainInfo.pQueueFamilyIndices = queueFamilyIndices;
			}
			else {
				swapchainInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
				swapchainInfo.queueFamilyIndexCount = 0; // Optional
				swapchainInfo.pQueueFamilyIndices = nullptr; // Optional
			}

			swapchainInfo.preTransform = swapChainSupport.capabilities.currentTransform;
			swapchainInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
			swapchainInfo.presentMode = presentMode;
			swapchainInfo.clipped = VK_TRUE;
			swapchainInfo.oldSwapchain = VK_NULL_HANDLE;

			if (m_device == VK_NULL_HANDLE) Andromeda::Logger::Print("Device is null", LogType::Critical);

			VkResult result;
			if ((result = vkCreateSwapchainKHR(m_device, &swapchainInfo, nullptr, &m_swapChain)) != VK_SUCCESS) {
				Andromeda::Logger::Print("Failed to create swapchain! " + std::to_string(result), LogType::Critical);
				return false;
			}

I copied it off of Vulkan Tutorial. I also checked if anything is null and it doesn’t seem like it. I have validation layers and they don’t give any errors.

Edit: I get error -3

fixed it :stuck_out_tongue: set the extension count on the device to 0 by accident when there were extensions

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.