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

Skip to content

Commit b4911fa

Browse files
committed
Fix wrong pool sizes for per frame descriptor sets
1 parent 72acbd2 commit b4911fa

9 files changed

Lines changed: 18 additions & 17 deletions

05_Uniform_buffers/01_Descriptor_pool_and_sets.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ to contain and how many of them, using `VkDescriptorPoolSize` structures.
3333
```c++
3434
VkDescriptorPoolSize poolSize = {};
3535
poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
36-
poolSize.descriptorCount = 1;
36+
poolSize.descriptorCount = static_cast<uint32_t>(swapChainImages.size());
3737
```
3838

39-
We only have a single descriptor right now with the uniform buffer type. This
39+
We will allocate one of these descriptors for every frame. This
4040
pool size structure is referenced by the main `VkDescriptorPoolCreateInfo`:
4141

4242
```c++
@@ -46,7 +46,8 @@ poolInfo.poolSizeCount = 1;
4646
poolInfo.pPoolSizes = &poolSize;
4747
```
4848

49-
We also need to specify the maximum number of descriptor sets that will be
49+
Aside from the maximum number of individual descriptors that are available, we
50+
also need to specify the maximum number of descriptor sets that may be
5051
allocated:
5152

5253
```c++

06_Texture_mapping/02_Combined_image_sampler.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ to the `createDescriptorPool` function and modify it to include a
4747
```c++
4848
std::array<VkDescriptorPoolSize, 2> poolSizes = {};
4949
poolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
50-
poolSizes[0].descriptorCount = 1;
50+
poolSizes[0].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
5151
poolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
52-
poolSizes[1].descriptorCount = 1;
52+
poolSizes[1].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
5353
5454
VkDescriptorPoolCreateInfo poolInfo = {};
5555
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
@@ -276,4 +276,4 @@ displays within the 3D world.
276276

277277
[C++ code](/code/25_texture_mapping.cpp) /
278278
[Vertex shader](/code/25_shader_textures.vert) /
279-
[Fragment shader](/code/25_shader_textures.frag)
279+
[Fragment shader](/code/25_shader_textures.frag)

code/22_descriptor_sets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ class HelloTriangleApplication {
745745
void createDescriptorPool() {
746746
VkDescriptorPoolSize poolSize = {};
747747
poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
748-
poolSize.descriptorCount = 1;
748+
poolSize.descriptorCount = static_cast<uint32_t>(swapChainImages.size());
749749

750750
VkDescriptorPoolCreateInfo poolInfo = {};
751751
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

code/23_texture_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ class HelloTriangleApplication {
890890
void createDescriptorPool() {
891891
VkDescriptorPoolSize poolSize = {};
892892
poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
893-
poolSize.descriptorCount = 1;
893+
poolSize.descriptorCount = static_cast<uint32_t>(swapChainImages.size());
894894

895895
VkDescriptorPoolCreateInfo poolInfo = {};
896896
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

code/24_sampler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ class HelloTriangleApplication {
926926
void createDescriptorPool() {
927927
VkDescriptorPoolSize poolSize = {};
928928
poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
929-
poolSize.descriptorCount = 1;
929+
poolSize.descriptorCount = static_cast<uint32_t>(swapChainImages.size());
930930

931931
VkDescriptorPoolCreateInfo poolInfo = {};
932932
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

code/25_texture_mapping.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,9 @@ class HelloTriangleApplication {
940940
void createDescriptorPool() {
941941
std::array<VkDescriptorPoolSize, 2> poolSizes = {};
942942
poolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
943-
poolSizes[0].descriptorCount = 1;
943+
poolSizes[0].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
944944
poolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
945-
poolSizes[1].descriptorCount = 1;
945+
poolSizes[1].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
946946

947947
VkDescriptorPoolCreateInfo poolInfo = {};
948948
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

code/26_depth_buffering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,9 +1035,9 @@ class HelloTriangleApplication {
10351035
void createDescriptorPool() {
10361036
std::array<VkDescriptorPoolSize, 2> poolSizes = {};
10371037
poolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
1038-
poolSizes[0].descriptorCount = 1;
1038+
poolSizes[0].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
10391039
poolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
1040-
poolSizes[1].descriptorCount = 1;
1040+
poolSizes[1].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
10411041

10421042
VkDescriptorPoolCreateInfo poolInfo = {};
10431043
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

code/27_model_loading.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,9 @@ class HelloTriangleApplication {
10811081
void createDescriptorPool() {
10821082
std::array<VkDescriptorPoolSize, 2> poolSizes = {};
10831083
poolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
1084-
poolSizes[0].descriptorCount = 1;
1084+
poolSizes[0].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
10851085
poolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
1086-
poolSizes[1].descriptorCount = 1;
1086+
poolSizes[1].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
10871087

10881088
VkDescriptorPoolCreateInfo poolInfo = {};
10891089
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

code/28_mipmapping.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,9 +1175,9 @@ class HelloTriangleApplication {
11751175
void createDescriptorPool() {
11761176
std::array<VkDescriptorPoolSize, 2> poolSizes = {};
11771177
poolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
1178-
poolSizes[0].descriptorCount = 1;
1178+
poolSizes[0].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
11791179
poolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
1180-
poolSizes[1].descriptorCount = 1;
1180+
poolSizes[1].descriptorCount = static_cast<uint32_t>(swapChainImages.size());
11811181

11821182
VkDescriptorPoolCreateInfo poolInfo = {};
11831183
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

0 commit comments

Comments
 (0)