Retrieve the swapchain images and create image views for them
| 853 | |
| 854 | // Retrieve the swapchain images and create image views for them |
| 855 | void setupSwapchainImages() |
| 856 | { |
| 857 | // Retrieve swapchain images |
| 858 | std::uint32_t objectCount = 0; |
| 859 | |
| 860 | if (vkGetSwapchainImagesKHR(device, swapchain, &objectCount, nullptr) != VK_SUCCESS) |
| 861 | { |
| 862 | vulkanAvailable = false; |
| 863 | return; |
| 864 | } |
| 865 | |
| 866 | swapchainImages.resize(objectCount); |
| 867 | swapchainImageViews.resize(objectCount); |
| 868 | |
| 869 | if (vkGetSwapchainImagesKHR(device, swapchain, &objectCount, swapchainImages.data()) != VK_SUCCESS) |
| 870 | { |
| 871 | vulkanAvailable = false; |
| 872 | return; |
| 873 | } |
| 874 | |
| 875 | VkImageViewCreateInfo imageViewCreateInfo = VkImageViewCreateInfo(); |
| 876 | imageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 877 | imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 878 | imageViewCreateInfo.format = swapchainFormat.format; |
| 879 | imageViewCreateInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; |
| 880 | imageViewCreateInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; |
| 881 | imageViewCreateInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; |
| 882 | imageViewCreateInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; |
| 883 | imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 884 | imageViewCreateInfo.subresourceRange.baseMipLevel = 0; |
| 885 | imageViewCreateInfo.subresourceRange.levelCount = 1; |
| 886 | imageViewCreateInfo.subresourceRange.baseArrayLayer = 0; |
| 887 | imageViewCreateInfo.subresourceRange.layerCount = 1; |
| 888 | |
| 889 | // Create an image view for each swapchain image |
| 890 | for (std::size_t i = 0; i < swapchainImages.size(); ++i) |
| 891 | { |
| 892 | imageViewCreateInfo.image = swapchainImages[i]; |
| 893 | |
| 894 | if (vkCreateImageView(device, &imageViewCreateInfo, nullptr, &swapchainImageViews[i]) != VK_SUCCESS) |
| 895 | { |
| 896 | vulkanAvailable = false; |
| 897 | return; |
| 898 | } |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | // Load vertex and fragment shader modules |
| 903 | void setupShaders() |
nothing calls this directly
no test coverage detected