@@ -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