Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ before we visualize them on the screen. This infrastructure is
known as the *swap chain* and must be created explicitly in Vulkan. The swap
chain is essentially a queue of images that are waiting to be presented to the
screen. Our application will acquire such an image to draw to it, and then
return it to the queue. How exactly the queue works. The conditions for
return it to the queue. How exactly the queue works and the conditions for
presenting an image from the queue depend on how the swap chain is set up. However,
the general purpose of the swap chain is to synchronize the presentation of
images with the refresh rate of the screen.
Expand Down Expand Up @@ -326,8 +326,8 @@ void initVulkan() {
}

void createSwapChain() {
auto surfaceCapabilities = physicalDevice.getSurfaceCapabilitiesKHR( surface );
swapChainSurfaceFormat = chooseSwapSurfaceFormat(physicalDevice.getSurfaceFormatsKHR( surface ));
auto surfaceCapabilities = physicalDevice.getSurfaceCapabilitiesKHR( *surface );
swapChainSurfaceFormat = chooseSwapSurfaceFormat(physicalDevice.getSurfaceFormatsKHR( *surface ));
swapChainExtent = chooseSwapExtent(surfaceCapabilities);
auto minImageCount = std::max( 3u, surfaceCapabilities.minImageCount );
minImageCount = ( surfaceCapabilities.maxImageCount > 0 && minImageCount > surfaceCapabilities.maxImageCount ) ? surfaceCapabilities.maxImageCount : minImageCount;
Expand Down Expand Up @@ -370,14 +370,21 @@ object so it is among the larger createInfo structures in Vulkan:
[,c++]
----
vk::SwapchainCreateInfoKHR swapChainCreateInfo{
.flags = vk::SwapchainCreateFlagsKHR(), .
surface = surface, .minImageCount = minImageCount,
.imageFormat = swapChainSurfaceFormat.format, .imageColorSpace = swapChainSurfaceFormat.colorSpace,
.imageExtent = swapChainExtent, .imageArrayLayers =1,
.imageUsage = vk::ImageUsageFlagBits::eColorAttachment, .imageSharingMode = vk::SharingMode::eExclusive,
.preTransform = surfaceCapabilities.currentTransform, .compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque,
.presentMode = chooseSwapPresentMode(physicalDevice.getSurfacePresentModesKHR( surface )),
.clipped = true, .oldSwapchain = nullptr };
.flags = vk::SwapchainCreateFlagsKHR(),
.surface = *surface,
.minImageCount = minImageCount,
.imageFormat = swapChainSurfaceFormat.format,
.imageColorSpace = swapChainSurfaceFormat.colorSpace,
.imageExtent = swapChainExtent,
.imageArrayLayers =1,
.imageUsage = vk::ImageUsageFlagBits::eColorAttachment,
.imageSharingMode = vk::SharingMode::eExclusive,
.preTransform = surfaceCapabilities.currentTransform,
.compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque,
.presentMode = chooseSwapPresentMode(physicalDevice.getSurfacePresentModesKHR( *surface )),
.clipped = true,
.oldSwapchain = nullptr
};
----

The `imageArrayLayers` specifies the number of layers each image consists of.
Expand Down
Loading