我正在使用 vulkan 制作应用程序并遇到问题。
在我的笔记本电脑(仅限集成显卡),vkcube.exe 运行得很好。所以不存在扩展支持问题。但是当我自己创建一个应用程序时,它说 VK_KHR_swapchain 扩展不存在。
还有一个安全检查,我称之为
vkEnumerateDeviceExtensionProperties
,并且 VK_KHR_swapchain 存在于列表中,因此必须支持它。
这些是我的集成 GPU 支持的设备扩展:
[09:19:24:716] [TRACE]: Device Extension: VK_EXT_device_address_binding_report
[09:19:24:716] [TRACE]: Device Extension: VK_EXT_full_screen_exclusive
[09:19:24:717] [TRACE]: Device Extension: VK_KHR_swapchain
VkDeviceCreateInfo device_create_info = {VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO};
device_create_info.queueCreateInfoCount = index_count;
device_create_info.pQueueCreateInfos = queue_create_info;
device_create_info.pEnabledFeatures = &device_features;
device_create_info.enabledExtensionCount = 1;
const char* extension_names[1] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
device_create_info.ppEnabledExtensionNames = (const char* const*)&extension_names;
device_create_info.enabledLayerCount = 0;
device_create_info.ppEnabledLayerNames = 0;
GRD_LOG_DEBUG("Creating logical device for physical device: %s", context->device.properties.deviceName);
VkResult result = vkCreateDevice(
context->device.physical_device,
&device_create_info,
context->allocator,
&context->device.logical_device);
if (result != VK_SUCCESS)
{
GRD_LOG_FATAL("Could not create vulkan logical device. Result: %d", result);
return FALSE;
}
这是输出:
[08:58:45:587] [DEBUG]: Creating logical device for physical device: Intel(R) Iris(R) Xe Graphics
[08:58:45:587] [ERROR]: loader_validate_device_extensions: Device extension VK_KHR_swapchain not supported by selected physical device or enabled layers.
[08:58:45:589] [ERROR]: vkCreateDevice: Failed to validate extensions in list
[08:58:45:589] [FATAL]: Could not create vulkan logical device. Result: -7 // Result Code for Extension not present
这些是已启用的实例扩展。
[08:58:45:482] [DEBUG]: Vulkan Required extensions:
[08:58:45:482] [DEBUG]: 1: VK_KHR_surface
[08:58:45:483] [DEBUG]: 2: VK_KHR_get_physical_device_properties2
[08:58:45:483] [DEBUG]: 3: VK_KHR_portability_enumeration
[08:58:45:483] [DEBUG]: 4: VK_KHR_win32_surface
[08:58:45:483] [DEBUG]: 5: VK_EXT_debug_utils
好吧,伙计们,Vulkan 没有任何问题,并不是我预期 Vulkan 会出现任何问题。
我使用的是自定义分配器。在重新分配回调中,我分配了新内存,但没有复制旧内存块,这可能会导致一些数据损坏并导致此错误。
一旦我在重新分配回调中添加了复制前一个内存块的逻辑,程序就按预期工作了。