Skip to content

Commit f76abce

Browse files
authored
Merge pull request #100 from xwxw-g/patch-1
Fix some typos in 01_Swap_chain.adoc
2 parents f7d889f + 5f9c475 commit f76abce

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void initVulkan() {
327327
328328
void createSwapChain() {
329329
auto surfaceCapabilities = physicalDevice.getSurfaceCapabilitiesKHR( surface );
330-
swapChainImageFormat = chooseSwapSurfaceFormat(physicalDevice.getSurfaceFormatsKHR( 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;
@@ -372,15 +372,15 @@ object so it is among the larger createInfo structures in Vulkan:
372372
vk::SwapchainCreateInfoKHR swapChainCreateInfo{
373373
.flags = vk::SwapchainCreateFlagsKHR(), .
374374
surface = surface, .minImageCount = minImageCount,
375-
.imageFormat = swapChainImageFormat, .imageColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear,
375+
.imageFormat = swapChainSurfaceFormat.format, .imageColorSpace = swapChainSurfaceFormat.colorSpace,
376376
.imageExtent = swapChainExtent, .imageArrayLayers =1,
377377
.imageUsage = vk::ImageUsageFlagBits::eColorAttachment, .imageSharingMode = vk::SharingMode::eExclusive,
378378
.preTransform = surfaceCapabilities.currentTransform, .compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque,
379379
.presentMode = chooseSwapPresentMode(physicalDevice.getSurfacePresentModesKHR( surface )),
380380
.clipped = true, .oldSwapchain = nullptr };
381381
----
382382

383-
he `imageArrayLayers` specifies the number of layers each image consists of.
383+
The `imageArrayLayers` specifies the number of layers each image consists of.
384384
This is always `1` unless you are developing a stereoscopic 3D application. The
385385
`imageUsage` bit field specifies what kind of operations we'll use the images in
386386
the swap chain for. In this tutorial, we're going to render directly to them,
@@ -395,13 +395,13 @@ the rendered image to a swap chain image.
395395
uint32_t queueFamilyIndices[] = {graphicsFamily, presentFamily};
396396
397397
if (graphicsFamily != presentFamily) {
398-
createInfo.imageSharingMode = vk::SharingMode::eConcurrent;
399-
createInfo.queueFamilyIndexCount = 2;
400-
createInfo.pQueueFamilyIndices = queueFamilyIndices;
398+
swapChainCreateInfo.imageSharingMode = vk::SharingMode::eConcurrent;
399+
swapChainCreateInfo.queueFamilyIndexCount = 2;
400+
swapChainCreateInfo.pQueueFamilyIndices = queueFamilyIndices;
401401
} else {
402-
createInfo.imageSharingMode = vk::SharingMode::eExclusive;
403-
createInfo.queueFamilyIndexCount = 0; // Optional
404-
createInfo.pQueueFamilyIndices = nullptr; // Optional
402+
swapChainCreateInfo.imageSharingMode = vk::SharingMode::eExclusive;
403+
swapChainCreateInfo.queueFamilyIndexCount = 0; // Optional
404+
swapChainCreateInfo.pQueueFamilyIndices = nullptr; // Optional
405405
}
406406
----
407407

@@ -430,7 +430,7 @@ queue families.
430430

431431
[,c++]
432432
----
433-
createInfo.preTransform = surfaceCapabilities.currentTransform;
433+
swapChainCreateInfo.preTransform = surfaceCapabilities.currentTransform;
434434
----
435435

436436
We can specify that a certain transform should be applied to images in the swap
@@ -440,7 +440,7 @@ any transformation, simply specify the current transformation.
440440

441441
[,c++]
442442
----
443-
createInfo.compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque;
443+
swapChainCreateInfo.compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque;
444444
----
445445

446446
The `compositeAlpha` field specifies if the alpha channel should be used for
@@ -449,8 +449,8 @@ simply ignore the alpha channel, hence `VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR`.
449449

450450
[,c++]
451451
----
452-
createInfo.presentMode = presentMode;
453-
createInfo.clipped = vk::True;
452+
swapChainCreateInfo.presentMode = presentMode;
453+
swapChainCreateInfo.clipped = vk::True;
454454
----
455455

456456
The `presentMode` member speaks for itself. If the `clipped` member is set to
@@ -461,7 +461,7 @@ you'll get the best performance by enabling clipping.
461461

462462
[,c++]
463463
----
464-
createInfo.oldSwapchain = VK_NULL_HANDLE;
464+
swapChainCreateInfo.oldSwapchain = VK_NULL_HANDLE;
465465
----
466466

467467
That leaves one last field, `oldSwapChain`. With Vulkan, it's possible that
@@ -472,11 +472,12 @@ be specified in this field. This is a complex topic that we'll learn more about
472472
in xref:03_Drawing_a_triangle/04_Swap_chain_recreation.adoc[a future chapter]. For now, we'll assume that we'll only ever create
473473
one swap chain.
474474

475-
Now add a class member to store the `VkSwapchainKHR` object:
475+
Now add class members to store the `VkSwapchainKHR` object and its images:
476476

477477
[,c++]
478478
----
479479
VkSwapchainKHR swapChain;
480+
std::vector<vk::Image> swapChainImages;
480481
----
481482

482483
Creating the swap chain is now as simple as calling `vkCreateSwapchainKHR`:
@@ -496,7 +497,7 @@ successfully! If at this point you get an access violation error in
496497
'vkGetInstanceProcAddress' in layer SteamOverlayVulkanLayer.dll`, then see
497498
the xref:90_FAQ.adoc[FAQ entry] about the Steam overlay layer.
498499

499-
Try removing the `createInfo.imageExtent = extent;` line with validation layers
500+
Try removing the `swapChainCreateInfo.imageExtent = extent;` line with validation layers
500501
enabled. You'll see that one of the validation layers immediately catches the
501502
mistake and a helpful message is printed:
502503

0 commit comments

Comments
 (0)