From d4a3d66907d608ff06d2da56beb19039f0842ed6 Mon Sep 17 00:00:00 2001 From: rehlee <4790712+rehlee@users.noreply.github.com> Date: Sun, 21 Dec 2025 00:07:43 -0800 Subject: [PATCH 1/2] 01_Swap_Chain fix grammar and formatting. --- .../01_Presentation/01_Swap_chain.adoc | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc b/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc index 1e5a8139..10b9125a 100644 --- a/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc +++ b/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc @@ -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. @@ -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; @@ -370,14 +370,20 @@ 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. From 4789e6a0768b45b60244c3a9eda49e6be4c3a67f Mon Sep 17 00:00:00 2001 From: rehlee <4790712+rehlee@users.noreply.github.com> Date: Sun, 21 Dec 2025 00:16:37 -0800 Subject: [PATCH 2/2] 01_Swap_chain Formatting fix for swapChainCreateInfo --- en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc b/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc index 10b9125a..d59256f6 100644 --- a/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc +++ b/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc @@ -383,7 +383,8 @@ vk::SwapchainCreateInfoKHR swapChainCreateInfo{ .compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque, .presentMode = chooseSwapPresentMode(physicalDevice.getSurfacePresentModesKHR( *surface )), .clipped = true, - .oldSwapchain = nullptr }; + .oldSwapchain = nullptr +}; ---- The `imageArrayLayers` specifies the number of layers each image consists of.