I have now checked in support into vsg::Context::reserve(...) for checking availability of descriptor/descriptor sets in existing vsg::DescriptorPool, if enough are available then the reserve() just returns without any new allocations, but if there aren't enough then a new vsg::DescriptorPool is created to meet the short fall.
The nice thing about this scheme is you can allocated bigger DescriptorPool at start up then have this used until exhausted. The automatic recycling of VkDescriptorSet/Descriptors also works with this so if you are loading/destroying subgraphs through the life of the application that same DescriptorPool resources can be reused lower overheads. This is all done for you, so you don't have to worry about this.
Changes to support this are:
To allocate bigger DescriptorPool the scene graph initially required VSG has had been supported by assigning the vsg::ResourceHints to a node in your scene graph - typically the root node of subgraph. This is how vsgGIS::TileReader does it:
uint32_t tileMultiplier = std::min(estimatedNumOfTilesBelow, maxNumTilesBelow) + 1;
// set up the ResourceHints required to make sure the VSG preallocates enough Vulkan resources for the paged database
vsg::CollectResourceRequirements collectResourceRequirements;
group->accept(collectResourceRequirements);
group->setObject("ResourceHints", collectResourceRequirements.createResourceHints(tileMultiplier));
These are now available when the subgraph is loaded and the vsg::CollectResourceRequirements that is run on that subgraph after loading uses any ResourceHints it finds - this is how paged databases have had to work prior to the new dynamic DescriptorPool functionality. This new functionality makes it possible to do without ResourceHints, as DescriptorPool will now be allocated on demand, but they are still helpful in avoiding too many DescriptorPools being allocated on the fly.
As we now have dynamic DiscriptorPool support the need for really large values in ResouceHint is reduced substantially. I do testing here to see how much smaller we can go without forcing too many DescriptorPools to be required at rendering time.
Another item I'd like to add is a minimal DescriptorPool allocation size, so if your application wants to reserve a small number of descriptor set after loading a new model it can over-allocate so that any follow on loads won't force each load to require a new DescriptorPool.
--
Another way of making sure there is plenty of base resources is to set up a vsg::ResourceRequirements struct with the settings you want to account for and pass this to the initial vsg::Viewer:compile(resourceRequirements) call. I may need to refine some of the member names to help make some of this functionality clearer as this class has evolved since it's inception along with parts of the VSG. Now that the VSG code base is settle down to it's 1.0 inconsistencies are apparent so there will be a bit of refinement that needs to happen, I expect this will continue even after 1.0 as we learn more about the needs of VSG users, the evolution of the Vulkan and the VSG.
If you are reading through the VSG/vsgXchange etc. code bases and see things that aren't clear, coherent and consistent let me know. Even if the naming etc. is correct as is, if it's confusing/not clear then there may be other things that needed to tightened up/documented to improve clarity and easy of use.
Cheers,
Robert.