Skip to content

Commit 5a90bda

Browse files
authored
Remove outdated reference to swapchain (#285)
This commit removes leftover references to the number of swapchain images in the "Uniform buffers" chapter.
1 parent dce8e86 commit 5a90bda

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

en/05_Uniform_buffers/00_Descriptor_layout_and_buffer.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,28 +273,21 @@ void createUniformBuffers() {
273273

274274
We're going to write a separate function that updates the uniform buffer with a
275275
new transformation every frame, so there will be no `vkMapMemory` here. The
276-
uniform data will be used for all draw calls, so the buffer containing it should only be destroyed when we stop rendering. Since it also depends on the number of swap chain images, which could change after a recreation, we'll clean it up in `cleanupSwapChain`:
276+
uniform data will be used for all draw calls, so the buffer containing it should only be destroyed when we stop rendering.
277277

278278
```c++
279-
void cleanupSwapChain() {
279+
void cleanup() {
280280
...
281281

282282
for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
283283
vkDestroyBuffer(device, uniformBuffers[i], nullptr);
284284
vkFreeMemory(device, uniformBuffersMemory[i], nullptr);
285285
}
286-
}
287-
```
288286

289-
This means that we also need to recreate it in `recreateSwapChain`:
287+
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
290288

291-
```c++
292-
void recreateSwapChain() {
293289
...
294290

295-
createFramebuffers();
296-
createUniformBuffers();
297-
createCommandBuffers();
298291
}
299292
```
300293

en/05_Uniform_buffers/01_Descriptor_pool_and_sets.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ void initVulkan() {
8686
...
8787
}
8888

89-
void recreateSwapChain() {
90-
...
91-
createDescriptorPool();
92-
createDescriptorSets();
93-
...
94-
}
95-
9689
...
9790

9891
void createDescriptorSets() {
@@ -113,7 +106,8 @@ allocInfo.descriptorSetCount = static_cast<uint32_t>(MAX_FRAMES_IN_FLIGHT);
113106
allocInfo.pSetLayouts = layouts.data();
114107
```
115108
116-
In our case we will create one descriptor set for each swap chain image, all with the same layout. Unfortunately we do need all the copies of the layout because the next function expects an array matching the number of sets.
109+
In our case we will create one descriptor set for each frame in flight, all with the same layout.
110+
Unfortunately we do need all the copies of the layout because the next function expects an array matching the number of sets.
117111
118112
Add a class member to hold the descriptor set handles and allocate them with
119113
`vkAllocateDescriptorSets`:
@@ -219,7 +213,7 @@ as its name implies.
219213
## Using descriptor sets
220214
221215
We now need to update the `createCommandBuffers` function to actually bind the
222-
right descriptor set for each swap chain image to the descriptors in the shader with `vkCmdBindDescriptorSets`. This needs to be done before the `vkCmdDrawIndexed` call:
216+
right descriptor set for each frame to the descriptors in the shader with `vkCmdBindDescriptorSets`. This needs to be done before the `vkCmdDrawIndexed` call:
223217
224218
```c++
225219
vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets[i], 0, nullptr);

0 commit comments

Comments
 (0)