enabledExts值为:
VkApplicationInfo infos = {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pApplicationName = app_name,
.applicationVersion = 1,
.pEngineName = ENGINE_NAME,
.engineVersion = ENGINE_VERSION,
.apiVersion = VK_MAKE_API_VERSION (0, version_major, version_minor, 0)};
VkInstanceCreateInfo inst_info = {
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.pApplicationInfo = &infos,
.enabledExtensionCount = enabledExtsCount,
.ppEnabledExtensionNames = enabledExts,
.enabledLayerCount = enabledLayersCount,
.ppEnabledLayerNames = enabledLayers };
[VkInstanceCreateInfo]->vkCreateInstance <-[VkApplicationInfo]
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
vkEnumeratePhysicalDevices->[vector<VkPhysicalDevice>]->vkGetPhysicalDeviceQueueFamilyProperties->[vector<VkQueueFamilyProperties>]
VkQueueFamilyProperties[idx].queueFlags
VK_QUEUE_GRAPHICS_BIT 0 x x
VK_QUEUE_COMPUTE_BIT 0 x 2
VK_QUEUE_TRANSFER_BIT 0 1 2
x代表vector<VkQueueFamilyProperties>的索引不支持此标志
222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
VkDeviceCreateInfo device_info = {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.queueCreateInfoCount = qCount,
.pQueueCreateInfos = (VkDeviceQueueCreateInfo*)&pQueueInfos,
.enabledExtensionCount = enabledExtsCount,
.ppEnabledExtensionNames = enabledExts,
.pEnabledFeatures = &enabledFeatures,
.pNext = pNext};
其中:
pQueueInfos->queueCount = queueCount;//queueCount=1
pQueueInfos->queueFamilyIndex = phy->pQueue;//支持VK_QUEUE_GRAPHICS_BIT且vkGetPhysicalDeviceSurfaceSupportKHR支持的VkQueueFamilyProperties的索引
pQueueInfos->pQueuePriorities = queue_priorities;
phy->queues[phy->pQueue].queueCount -= queueCount;//分配后数量减去分配数queueCount
其中enabledExts值变为:
创建VkDevice:
VkDevice dev;
vkCreateDevice([VkPhysicalDevice],device_info,NULL,&dev)
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
VkSwapchainKHR newSwapchain;
VkSwapchainCreateInfoKHR createInfo = {
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
.surface = r->surface,
.minImageCount = surfCapabilities.minImageCount,
.imageFormat = r->format,
.imageColorSpace = r->colorSpace,
.imageExtent = {r->width,r->height},
.imageArrayLayers = 1,
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
.preTransform = surfCapabilities.currentTransform,
.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
.presentMode = r->presentMode,
.clipped = VK_TRUE,
.oldSwapchain = r->swapChain};
VK_CHECK_RESULT(vkCreateSwapchainKHR ([VkDevice], &createInfo, NULL, &newSwapchain));
1.其中r->format和r->colorSpace通过vkGetPhysicalDeviceSurfaceFormatsKHR获取[VkSurfaceFormatKHR],然后:
VkSurfaceFormatKHR* formats
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfaceFormatsKHR ([VkPhysicalDevice], [VkSurfaceKHR], &count, formats));
for (uint32_t i=0; i<count; i++){
if (formats[i].format == preferedFormat) {//preferedFormat为参数VkFormat preferedFormat
r->format = formats[i].format;
r->colorSpace = formats[i].colorSpace;
break;
}
}
2.其中r->presentMode通过vkGetPhysicalDeviceSurfacePresentModesKHR获取[VkPresentModeKHR]
VkPresentModeKHR* presentModes
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR([VkPhysicalDevice], [VkSurfaceKHR], &count, presentModes));
r->presentMode = -1;
for (uint32_t i=0; i<count; i++){
if (presentModes[i] == presentMode) {//presentMode为参数VkPresentModeKHR presentMode
r->presentMode = presentModes[i];
break;
}
}
3.其中surfCapabilities通过vkGetPhysicalDeviceSurfaceCapabilitiesKHR获取
VkSurfaceCapabilitiesKHR surfCapabilities;
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfaceCapabilitiesKHR([VkPhysicalDevice], [VkSurfaceKHR], &surfCapabilities));
assert (surfCapabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT);
4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444