@@ -8,7 +8,7 @@ before we visualize them on the screen. This infrastructure is
88known as the *swap chain* and must be created explicitly in Vulkan. The swap
99chain is essentially a queue of images that are waiting to be presented to the
1010screen. Our application will acquire such an image to draw to it, and then
11- return it to the queue. How exactly the queue works. The conditions for
11+ return it to the queue. How exactly the queue works and the conditions for
1212presenting an image from the queue depend on how the swap chain is set up. However,
1313the general purpose of the swap chain is to synchronize the presentation of
1414images with the refresh rate of the screen.
@@ -326,8 +326,8 @@ void initVulkan() {
326326}
327327
328328void createSwapChain() {
329- auto surfaceCapabilities = physicalDevice.getSurfaceCapabilitiesKHR( surface );
330- swapChainSurfaceFormat = chooseSwapSurfaceFormat(physicalDevice.getSurfaceFormatsKHR( surface ));
329+ auto surfaceCapabilities = physicalDevice.getSurfaceCapabilitiesKHR( * surface );
330+ swapChainSurfaceFormat = chooseSwapSurfaceFormat(physicalDevice.getSurfaceFormatsKHR( * surface ));
331331 swapChainExtent = chooseSwapExtent(surfaceCapabilities);
332332 auto minImageCount = std::max( 3u, surfaceCapabilities.minImageCount );
333333 minImageCount = ( surfaceCapabilities.maxImageCount > 0 && minImageCount > surfaceCapabilities.maxImageCount ) ? surfaceCapabilities.maxImageCount : minImageCount;
@@ -370,14 +370,20 @@ object so it is among the larger createInfo structures in Vulkan:
370370[,c++]
371371----
372372vk::SwapchainCreateInfoKHR swapChainCreateInfo{
373- .flags = vk::SwapchainCreateFlagsKHR(), .
374- surface = surface, .minImageCount = minImageCount,
375- .imageFormat = swapChainSurfaceFormat.format, .imageColorSpace = swapChainSurfaceFormat.colorSpace,
376- .imageExtent = swapChainExtent, .imageArrayLayers =1,
377- .imageUsage = vk::ImageUsageFlagBits::eColorAttachment, .imageSharingMode = vk::SharingMode::eExclusive,
378- .preTransform = surfaceCapabilities.currentTransform, .compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque,
379- .presentMode = chooseSwapPresentMode(physicalDevice.getSurfacePresentModesKHR( surface )),
380- .clipped = true, .oldSwapchain = nullptr };
373+ .flags = vk::SwapchainCreateFlagsKHR(),
374+ .surface = *surface,
375+ .minImageCount = minImageCount,
376+ .imageFormat = swapChainSurfaceFormat.format,
377+ .imageColorSpace = swapChainSurfaceFormat.colorSpace,
378+ .imageExtent = swapChainExtent,
379+ .imageArrayLayers =1,
380+ .imageUsage = vk::ImageUsageFlagBits::eColorAttachment,
381+ .imageSharingMode = vk::SharingMode::eExclusive,
382+ .preTransform = surfaceCapabilities.currentTransform,
383+ .compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque,
384+ .presentMode = chooseSwapPresentMode(physicalDevice.getSurfacePresentModesKHR( *surface )),
385+ .clipped = true,
386+ .oldSwapchain = nullptr };
381387----
382388
383389The `imageArrayLayers` specifies the number of layers each image consists of.
0 commit comments