vsg: include/vsg/vk/DescriptorPools.h Source File

vsg 1.1.13 VulkanSceneGraph library

Loading...
Searching...
No Matches
DescriptorPools.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2024 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/state/DescriptorSet.h>
16#include <vsg/vk/DescriptorPool.h>
17#include <vsg/vk/ResourceRequirements.h>
18
19namespace vsg
20{
21
23 class VSG_DECLSPEC DescriptorPools : public Inherit<Object, DescriptorPools>
24 {
25 public:
26 explicit DescriptorPools(ref_ptr<Device> in_device);
27
28 ref_ptr<Device> device;
29 std::list<ref_ptr<DescriptorPool>> descriptorPools;
30
31 uint32_t minimum_maxSets = 0; // minimum value of maxSets when allocating new DescriptoPool.
32 uint32_t maximum_maxSets = 2048; // maximum value of minimum_maxSets can grow to.
33 double scale_maxSets = 2.0; // how to scale minimum_maxSets on each successive DescriptorPool allocation.
34
35 // totals of all the calls to reserve(const ResourceRequirements& requirements), used to guide allocation of new DescritproPool
36 uint32_t reserve_count = 0;
37 uint32_t reserve_maxSets = 0;
38 DescriptorPoolSizes reserve_descriptorPoolSizes;
39
41 void reserve(const ResourceRequirements& requirements);
42
43 // allocate vkDescriptorSet
44 ref_ptr<DescriptorSet::Implementation> allocateDescriptorSet(DescriptorSetLayout* descriptorSetLayout);
45
47 void report(std::ostream& out, indentation indent = {}) const;
48
50 bool available(uint32_t& numSets, DescriptorPoolSizes& availableDescriptorPoolSizes) const;
51
53 bool used(uint32_t& numSets, DescriptorPoolSizes& descriptorPoolSizes) const;
54
56 bool allocated(uint32_t& numSets, DescriptorPoolSizes& descriptorPoolSizes) const;
57
58 protected:
59 virtual ~DescriptorPools();
60
62 void getDescriptorPoolSizesToUse(uint32_t& maxSets, DescriptorPoolSizes& descriptorPoolSizes);
63 };
64 VSG_type_name(vsg::DescriptorPools);
65
66} // namespace vsg
vsg::DescriptorPools
Container for DescriptorPools.
Definition DescriptorPools.h:24
vsg::DescriptorPools::reserve
void reserve(const ResourceRequirements &requirements)
check if there are enough Descriptorsets/Descrioptors, if not allocated a new DescriptorPool for thes...
vsg::DescriptorPools::allocated
bool allocated(uint32_t &numSets, DescriptorPoolSizes &descriptorPoolSizes) const
compute the number of sets and descriptors allocated.
vsg::DescriptorPools::available
bool available(uint32_t &numSets, DescriptorPoolSizes &availableDescriptorPoolSizes) const
compute the number of sets and descriptors available.
vsg::DescriptorPools::used
bool used(uint32_t &numSets, DescriptorPoolSizes &descriptorPoolSizes) const
compute the number of sets and descriptors used.
vsg::DescriptorPools::getDescriptorPoolSizesToUse
void getDescriptorPoolSizesToUse(uint32_t &maxSets, DescriptorPoolSizes &descriptorPoolSizes)
get the maxSets and descriptorPoolSizes to use
vsg::DescriptorPools::report
void report(std::ostream &out, indentation indent={}) const
write the internal details to stream.
vsg::DescriptorSetLayout
DescriptorSetLayout encapsulates VkDescriptorSetLayout and VkDescriptorSetLayoutCreateInfo settings u...
Definition DescriptorSetLayout.h:29
vsg::ResourceRequirements
ResourceRequirements provides a container for various Vulkan resource requirements that can be used t...
Definition ResourceRequirements.h:30
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::indentation
helper class for inserting indentation into streams useful for formatting output.
Definition stream.h:39