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

Skip to content

Commit 87070e7

Browse files
committed
Rewrite explanation
1 parent 937e6ed commit 87070e7

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

09_Generating_Mipmaps.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,22 @@ We're now going to write the function generates the mipmaps:
101101
```c++
102102
void generateMipmaps(VkImage image, int32_t texWidth, int32_t texHeight, uint32_t mipLevels) {
103103
VkCommandBuffer commandBuffer = beginSingleTimeCommands();
104-
...
104+
105+
VkImageMemoryBarrier barrier = {};
106+
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
107+
barrier.image = image;
108+
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
109+
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
110+
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
111+
barrier.subresourceRange.baseArrayLayer = 0;
112+
barrier.subresourceRange.layerCount = 1;
113+
barrier.subresourceRange.levelCount = 1;
114+
105115
endSingleTimeCommands(commandBuffer);
106116
}
107117
```
108118

109-
Since we can't use `transitionImageLayout`, we need to record and submit another `VkCommandBuffer`.
110-
111-
```c++
112-
VkImageMemoryBarrier barrier = {};
113-
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
114-
barrier.image = image;
115-
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
116-
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
117-
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
118-
barrier.subresourceRange.baseArrayLayer = 0;
119-
barrier.subresourceRange.layerCount = 1;
120-
barrier.subresourceRange.levelCount = 1;
121-
```
122-
123-
We're going to insert several pipeline barriers, so we'll reuse this `VkImageMemoryBarrier` for each transition.
119+
We're going to make several transitions, so we'll reuse this `VkImageMemoryBarrier`.
124120

125121
```c++
126122
int32_t mipWidth = texWidth;

0 commit comments

Comments
 (0)