第一次通话后vkGetSwapChainImages崩溃

时间:2018-02-06 22:00:41

标签: c++ vulkan

我开始学习Vulkan,一切都很顺利,但不知何故,函数vkGetSwapChainImages()想破坏我的生活。 基本上,这就是我创建SwapChain的方式。 desiredFormat,desiredExtent,desiredUsage,desiredExtent和desiredTransform都设置得很好。

    VkSwapchainCreateInfoKHR swapChainCreateInfo = { };
    swapChainCreateInfo.sType = VkStructureType::VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
    swapChainCreateInfo.flags = 0;
    swapChainCreateInfo.pNext = nullptr;
    swapChainCreateInfo.compositeAlpha = VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
    swapChainCreateInfo.imageColorSpace = desiredFormat.colorSpace;
    swapChainCreateInfo.imageFormat = desiredFormat.format;
    swapChainCreateInfo.imageExtent = desiredExtent;
    swapChainCreateInfo.clipped = VK_TRUE;
    swapChainCreateInfo.imageArrayLayers = 1;
    swapChainCreateInfo.imageSharingMode = VkSharingMode::VK_SHARING_MODE_EXCLUSIVE;
    swapChainCreateInfo.surface = mRenderingSurface;
    swapChainCreateInfo.imageUsage = desiredUsage;
    swapChainCreateInfo.minImageCount = desiredImageCount;
    swapChainCreateInfo.presentMode = desiredMode;
    swapChainCreateInfo.oldSwapchain = oldSwapChain;
    swapChainCreateInfo.pQueueFamilyIndices = nullptr;
    swapChainCreateInfo.queueFamilyIndexCount = 0;
    swapChainCreateInfo.preTransform = desiredTransform;

    if ( vkCreateSwapchainKHR( mLogicalDevice, &swapChainCreateInfo, nullptr, &mSwapChain ) != VK_SUCCESS )
        return false;

如果我打电话给vkGetSwapChainImages,就不会发生任何不好的事情。但是如果我想第二次调用vkGetSwapChainImages,它就不起作用了,我得到了这样的异常

Exception thrown at 0x0433A209 (VkLayer_core_validation.dll) in Project1.exe: 0xC0000005: Access violation reading location 0x000000A8.

我不明白为什么会这样。我尝试从第一次调用中保存结果并使用它们,但我仍然收到错误,所以我觉得我在这里做错了。

0 个答案:

没有答案