@@ -29,7 +29,7 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
29
29
std::shared_ptr<ReservedAllocator> reservedAllocator;
30
30
size_t reservedSize;
31
31
};
32
- std::vector< SubAllocDescriptorSetRange> m_allocatableRanges = {};
32
+ std::unordered_map< uint32_t , SubAllocDescriptorSetRange> m_allocatableRanges = {};
33
33
34
34
35
35
public:
@@ -50,26 +50,20 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
50
50
auto count = redirect.getCount (storageIndex);
51
51
auto flags = redirect.getCreateFlags (storageIndex);
52
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
53
// Only bindings with these flags will be allocatable
61
54
if (flags.hasFlags (core::bitflag (IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_AFTER_BIND_BIT)
62
55
| IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_UNUSED_WHILE_PENDING_BIT
63
56
| IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_PARTIALLY_BOUND_BIT))
64
57
{
58
+ SubAllocDescriptorSetRange range;
65
59
range.reservedSize = AddressAllocator::reserved_size (maxAllocatableAlignment, static_cast <size_type>(count), args...);
66
60
range.reservedAllocator = std::shared_ptr<ReservedAllocator>(new ReservedAllocator ());
67
61
range.addressAllocator = std::shared_ptr<AddressAllocator>(new AddressAllocator (
68
62
range.reservedAllocator ->allocate (range.reservedSize , _NBL_SIMD_ALIGNMENT),
69
63
static_cast <size_type>(0 ), 0u , maxAllocatableAlignment, static_cast <size_type>(count), std::forward<Args>(args)...
70
64
));
65
+ m_allocatableRanges.emplace (binding.data , range);
71
66
}
72
- m_allocatableRanges.insert (m_allocatableRanges.begin () + binding.data , range);
73
67
}
74
68
}
75
69
}
@@ -91,12 +85,16 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
91
85
uint32_t getLayoutBindingCount () { return m_allocatableRanges.size (); }
92
86
93
87
// whether that binding index can be sub-allocated
94
- bool isBindingAllocatable (uint32_t binding) { return m_allocatableRanges[binding].reservedSize != 0 ; }
88
+ bool isBindingAllocatable (uint32_t binding)
89
+ {
90
+ return m_allocatableRanges.find (binding) != m_allocatableRanges.end ();
91
+ }
95
92
96
93
AddressAllocator& getBindingAllocator (uint32_t binding)
97
94
{
98
- assert (isBindingAllocatable (binding)); // Check if this binding has an allocator
99
- return *m_allocatableRanges[binding].addressAllocator ;
95
+ auto range = m_allocatableRanges.find (binding);
96
+ assert (range != m_allocatableRanges.end ());// Check if this binding has an allocator
97
+ return *range->second .addressAllocator ;
100
98
}
101
99
102
100
// main methods
0 commit comments