即使验证层和调试回调扩展已启用并正常工作(它们会响应错误的结构等),我仍然会得到一个" VK_ERROR_VALIDATION_FAILED_EXT"来自find ./GMDS_SRC/* -name '*.h' -o -name '*.c' -type f -exec chmod 444 {} \;
的结果,并且没有验证层错误来查明错误...
交换链创建(使用GTX 970):
vkCreateSwapchainKHR()
使用GLFW创建曲面(不会返回任何错误):
VkBool32 isSupported = false;
vkGetPhysicalDeviceSurfaceSupportKHR( physicalDevices[0], 0, surface, &isSupported);
if (!isSupported) {
std::cout << "*ERROR* This device doesn't support surfaces" << std::endl;
}
VkSurfaceCapabilitiesKHR surfCaps;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevices[0], surface, &surfCaps);
std::vector<VkSurfaceFormatKHR> deviceFormats;
uint32_t formatCount;
vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevices[0], surface, &formatCount, nullptr);
deviceFormats.resize(formatCount);
vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevices[0], surface, &formatCount, deviceFormats.data());
swapChainInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
swapChainInfo.pNext = nullptr;
swapChainInfo.flags = 0;
swapChainInfo.surface = surface;
swapChainInfo.minImageCount = surfCaps.minImageCount;
swapChainInfo.imageFormat = VK_FORMAT_B8G8R8A8_UNORM;
swapChainInfo.imageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
swapChainInfo.imageExtent = surfCaps.currentExtent;
swapChainInfo.imageArrayLayers = 1;
swapChainInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
swapChainInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
swapChainInfo.queueFamilyIndexCount = 0;
swapChainInfo.pQueueFamilyIndices = VK_NULL_HANDLE;
swapChainInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
swapChainInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
swapChainInfo.presentMode = VK_PRESENT_MODE_FIFO_KHR;
swapChainInfo.clipped = VK_TRUE; // TODO : TEST clipping against another window
swapChainInfo.oldSwapchain = VK_NULL_HANDLE;
result = vkCreateSwapchainKHR( device, &swapChainInfo, nullptr, &swapChain );
if (result) {
std::cout << "*ERROR* Swapchain Creation Failed :" << result << std::endl;
}
答案 0 :(得分:1)
关于代码的几点(可能导致问题):
VkResult
命令的vkGet*
swapChainInfo.imageFormat
deviceFormats
surfCaps.currentExtent
可以0xFFFFFFFF
swapChainInfo.pQueueFamilyIndices
是指针而不是句柄;使用nullptr
swapChainInfo.preTransform
surfCaps.supportedTransforms
swapChainInfo.compositeAlpha
surfCaps.supportedCompositeAlpha
答案 1 :(得分:0)
vkCreateSwapchainKHR
验证失败的原因有很多(请查看core_validation.cpp中的PreCallValidateCreateSwapchainKHR
)。
这里可能没有足够的代码来说明它失败的原因,例如,失败可能是因为表面无效。但是,为了查明问题,它应该在调试日志中给出一条失败消息,这将告诉你确切的原因。在尝试创建交换链之前,您应该通过调用CreateDebugReportCallbackEXT
来启用它。这还需要您启用VK_EXT_debug_report
扩展程序。有关详细信息,请参阅here。