Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43221c8

Browse files
committed
Remove superfluous transition from multisampling chapter
1 parent 0dd1459 commit 43221c8

2 files changed

Lines changed: 1 addition & 29 deletions

File tree

code/29_multisampling.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,6 @@ class HelloTriangleApplication {
817817

818818
createImage(swapChainExtent.width, swapChainExtent.height, 1, msaaSamples, colorFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, colorImage, colorImageMemory);
819819
colorImageView = createImageView(colorImage, colorFormat, VK_IMAGE_ASPECT_COLOR_BIT, 1);
820-
821-
transitionImageLayout(colorImage, colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 1);
822820
}
823821

824822
void createDepthResources() {
@@ -1104,13 +1102,7 @@ VkSampleCountFlagBits getMaxUsableSampleCount() {
11041102

11051103
sourceStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
11061104
destinationStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
1107-
} else if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) {
1108-
barrier.srcAccessMask = 0;
1109-
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
1110-
sourceStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
1111-
destinationStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
1112-
}
1113-
else {
1105+
} else {
11141106
throw std::invalid_argument("unsupported layout transition!");
11151107
}
11161108

en/10_Multisampling.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ void createColorResources() {
9999

100100
createImage(swapChainExtent.width, swapChainExtent.height, 1, msaaSamples, colorFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, colorImage, colorImageMemory);
101101
colorImageView = createImageView(colorImage, colorFormat, VK_IMAGE_ASPECT_COLOR_BIT, 1);
102-
103-
transitionImageLayout(colorImage, colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 1);
104102
}
105103
```
106104

@@ -115,24 +113,6 @@ void initVulkan() {
115113
}
116114
```
117115

118-
You may notice that the newly created color image uses a transition path from `VK_IMAGE_LAYOUT_UNDEFINED` to `VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL` which is a new case for us to handle. Let's update `transitionImageLayout` function to take this into account:
119-
120-
```c++
121-
void transitionImageLayout(VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t mipLevels) {
122-
...
123-
else if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) {
124-
barrier.srcAccessMask = 0;
125-
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
126-
sourceStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
127-
destinationStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
128-
}
129-
else {
130-
throw std::invalid_argument("unsupported layout transition!");
131-
}
132-
...
133-
}
134-
```
135-
136116
Now that we have a multisampled color buffer in place it's time to take care of depth. Modify `createDepthResources` and update the number of samples used by the depth buffer:
137117

138118
```c++

0 commit comments

Comments
 (0)