@@ -25,7 +25,6 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
25
25
26
26
protected:
27
27
struct SubAllocDescriptorSetRange {
28
- video::IGPUDescriptorSetLayout::SBinding binding;
29
28
std::shared_ptr<AddressAllocator> addressAllocator;
30
29
std::shared_ptr<ReservedAllocator> reservedAllocator;
31
30
size_t reservedSize;
@@ -36,31 +35,64 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
36
35
public:
37
36
// constructors
38
37
template <typename ... Args>
39
- inline SubAllocatedDescriptorSet (const std::span<const video::IGPUDescriptorSetLayout::SBinding> bindings,
40
- const value_type maxAllocatableAlignment, Args&&... args)
38
+ inline SubAllocatedDescriptorSet (video::IGPUDescriptorSetLayout* layout, const value_type maxAllocatableAlignment, Args&&... args)
41
39
{
42
- m_allocatableRanges.reserve (bindings.size ());
43
-
44
- for (auto & binding : bindings)
40
+ for (uint32_t descriptorType = 0 ; descriptorType < static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT); descriptorType++)
45
41
{
46
- SubAllocDescriptorSetRange range;
47
- range.binding = binding;
48
- range.reservedSize = 0 ;
49
- // Only bindings with these flags will be allocatable
50
- if (binding.createFlags .hasFlags (core::bitflag (IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_AFTER_BIND_BIT)
51
- | IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_UNUSED_WHILE_PENDING_BIT
52
- | IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_PARTIALLY_BOUND_BIT))
42
+ auto descType = static_cast <asset::IDescriptor::E_TYPE>(descriptorType);
43
+ auto & redirect = layout->getDescriptorRedirect (descType);
44
+
45
+ for (uint32_t i = 0 ; i < redirect.getBindingCount (); i++)
53
46
{
54
- range.reservedSize = AddressAllocator::reserved_size (maxAllocatableAlignment, static_cast <size_type>(binding.count ), args...);
55
- range.reservedAllocator = std::shared_ptr<ReservedAllocator>(new ReservedAllocator ());
56
- range.addressAllocator = std::shared_ptr<AddressAllocator>(new AddressAllocator (
57
- range.reservedAllocator ->allocate (range.reservedSize , _NBL_SIMD_ALIGNMENT),
58
- static_cast <size_type>(0 ), 0u , maxAllocatableAlignment, static_cast <size_type>(binding.count ), std::forward<Args>(args)...
59
- ));
47
+ auto binding = redirect.getBinding (i);
48
+ auto storageIndex = redirect.findBindingStorageIndex (binding);
49
+
50
+ auto count = redirect.getCount (storageIndex);
51
+ auto flags = redirect.getCreateFlags (storageIndex);
52
+
53
+ for (uint32_t j = m_allocatableRanges.size (); j < binding.data ; j++)
54
+ {
55
+ m_allocatableRanges.push_back ({});
56
+ }
57
+
58
+ SubAllocDescriptorSetRange range;
59
+ range.reservedSize = 0 ;
60
+ // Only bindings with these flags will be allocatable
61
+ if (flags.hasFlags (core::bitflag (IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_AFTER_BIND_BIT)
62
+ | IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_UNUSED_WHILE_PENDING_BIT
63
+ | IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_PARTIALLY_BOUND_BIT))
64
+ {
65
+ range.reservedSize = AddressAllocator::reserved_size (maxAllocatableAlignment, static_cast <size_type>(count), args...);
66
+ range.reservedAllocator = std::shared_ptr<ReservedAllocator>(new ReservedAllocator ());
67
+ range.addressAllocator = std::shared_ptr<AddressAllocator>(new AddressAllocator (
68
+ range.reservedAllocator ->allocate (range.reservedSize , _NBL_SIMD_ALIGNMENT),
69
+ static_cast <size_type>(0 ), 0u , maxAllocatableAlignment, static_cast <size_type>(count), std::forward<Args>(args)...
70
+ ));
71
+ }
72
+ m_allocatableRanges.insert (m_allocatableRanges.begin () + binding.data , range);
60
73
}
61
- m_allocatableRanges.push_back (range);
62
74
}
63
75
76
+ // for (auto& binding : bindings)
77
+ // {
78
+ // SubAllocDescriptorSetRange range;
79
+ // range.binding = binding;
80
+ // range.reservedSize = 0;
81
+ // // Only bindings with these flags will be allocatable
82
+ // if (binding.createFlags.hasFlags(core::bitflag(IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_AFTER_BIND_BIT)
83
+ // | IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_UNUSED_WHILE_PENDING_BIT
84
+ // | IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_PARTIALLY_BOUND_BIT))
85
+ // {
86
+ // range.reservedSize = AddressAllocator::reserved_size(maxAllocatableAlignment, static_cast<size_type>(binding.count), args...);
87
+ // range.reservedAllocator = std::shared_ptr<ReservedAllocator>(new ReservedAllocator());
88
+ // range.addressAllocator = std::shared_ptr<AddressAllocator>(new AddressAllocator(
89
+ // range.reservedAllocator->allocate(range.reservedSize, _NBL_SIMD_ALIGNMENT),
90
+ // static_cast<size_type>(0), 0u, maxAllocatableAlignment, static_cast<size_type>(binding.count), std::forward<Args>(args)...
91
+ // ));
92
+ // }
93
+ // m_allocatableRanges.push_back(range);
94
+ // }
95
+
64
96
}
65
97
66
98
~SubAllocatedDescriptorSet ()
0 commit comments