@@ -38,11 +38,11 @@ fragment is going to be determined. It is possible to use texture sampling in
3838the vertex shader, for example to dynamically deform a grid of vertices by a
3939[heightmap](https://en.wikipedia.org/wiki/Heightmap).
4040
41- If you would run the application with validation layers now, then you'll see
42- that it complains that the descriptor pool cannot allocate descriptor sets with
43- this layout, because it doesn't have any combined image sampler descriptors. Go
44- to the `createDescriptorPool` function and modify it to include a
45- `VkDescriptorPoolSize` for this descriptor:
41+ We must also create a larger descriptor pool to make room for the allocation
42+ of the combined image sampler by adding another `VkPoolSize` of type
43+ `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER` to the
44+ `VkDescriptorPoolCreateInfo`. Go to the `createDescriptorPool` function and
45+ modify it to include a `VkDescriptorPoolSize` for this descriptor:
4646
4747```c++
4848std::array<VkDescriptorPoolSize, 2> poolSizes{};
@@ -58,6 +58,24 @@ poolInfo.pPoolSizes = poolSizes.data();
5858poolInfo.maxSets = static_cast<uint32_t>(swapChainImages.size());
5959```
6060
61+ Inadequate descriptor pools are a good example of a problem that the validation
62+ layers will not catch: As of Vulkan 1.1, ` vkAllocateDescriptorSets ` may fail
63+ with the error code ` VK_ERROR_POOL_OUT_OF_MEMORY ` if the pool is not
64+ sufficiently large, but the driver may also try to solve the problem internally.
65+ This means that sometimes (depending on hardware, pool size and allocation size)
66+ the driver will let us get away with an allocation that exceeds the limits of
67+ our descriptor pool. Other times, ` vkAllocateDescriptorSets ` will fail and
68+ return ` VK_ERROR_POOL_OUT_OF_MEMORY ` . This can be particularly frustrating if
69+ the allocation succeeds on some machines, but fails on others.
70+
71+ Since Vulkan shifts the responsiblity for the allocation to the driver, it is no
72+ longer a strict requirement to only allocate as many descriptors of a certain
73+ type (` VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ` , etc.) as specified by the
74+ corresponding ` descriptorCount ` members for the creation of the descriptor pool.
75+ However, it remains best practise to do so, and in the future,
76+ ` VK_LAYER_KHRONOS_validation ` will warn about this type of problem if you enable
77+ [ Best Practice Validation] ( https://vulkan.lunarg.com/doc/view/1.1.126.0/windows/best_practices.html ) .
78+
6179The final step is to bind the actual image and sampler resources to the
6280descriptors in the descriptor set. Go to the ` createDescriptorSets ` function.
6381
0 commit comments