@@ -89,6 +89,7 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
89
89
};
90
90
std::map<uint32_t , SubAllocDescriptorSetRange> m_allocatableRanges = {};
91
91
core::smart_refctd_ptr<video::IGPUDescriptorSet> m_descriptorSet;
92
+ core::smart_refctd_ptr<video::ILogicalDevice> m_logicalDevice;
92
93
93
94
#ifdef _NBL_DEBUG
94
95
std::recursive_mutex stAccessVerfier;
@@ -100,7 +101,8 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
100
101
public:
101
102
102
103
// constructors
103
- inline SubAllocatedDescriptorSet (core::smart_refctd_ptr<video::IGPUDescriptorSet>&& descriptorSet)
104
+ inline SubAllocatedDescriptorSet (core::smart_refctd_ptr<video::IGPUDescriptorSet>&& descriptorSet,
105
+ core::smart_refctd_ptr<video::ILogicalDevice>&& logicalDevice) : m_logicalDevice(std::move(logicalDevice))
104
106
{
105
107
auto layout = descriptorSet->getLayout ();
106
108
for (uint32_t descriptorType = 0 ; descriptorType < static_cast <uint32_t >(asset::IDescriptor::E_TYPE::ET_COUNT); descriptorType++)
@@ -174,20 +176,46 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted
174
176
bool stAccessVerifyDebugGuard () { return false ; }
175
177
#endif
176
178
179
+ video::IGPUDescriptorSet* getDescriptorSet () { return m_descriptorSet.get (); }
180
+
177
181
// ! Warning `outAddresses` needs to be primed with `invalid_value` values, otherwise no allocation happens for elements not equal to `invalid_value`
178
- inline void multi_allocate (uint32_t binding, size_type count, value_type* outAddresses)
182
+ inline void multi_allocate (uint32_t binding, size_type count, video::IGPUDescriptorSet::SDescriptorInfo* descriptors, value_type* outAddresses)
179
183
{
180
184
auto debugGuard = stAccessVerifyDebugGuard ();
181
185
182
186
auto allocator = getBindingAllocator (binding);
187
+
188
+ std::vector<video::IGPUDescriptorSet::SWriteDescriptorSet> writes;
189
+ std::vector<video::IGPUDescriptorSet::SDescriptorInfo> infos;
190
+ writes.reserve (count);
191
+ infos.reserve (count);
192
+
183
193
for (size_type i=0 ; i<count; i++)
184
194
{
185
195
if (outAddresses[i]!=AddressAllocator::invalid_address)
186
196
continue ;
187
197
188
198
outAddresses[i] = allocator->alloc_addr (1 ,1 );
189
199
// TODO: should also write something to the descriptor set (or probably leave that to the caller?)
200
+
201
+ auto & descriptor = descriptors[i];
202
+
203
+ video::IGPUDescriptorSet::SWriteDescriptorSet write;
204
+ {
205
+ write.dstSet = m_descriptorSet.get ();
206
+ write.binding = binding;
207
+ write.arrayElement = outAddresses[i];
208
+ write.count = 1u ;
209
+ // descriptors could be a const pointer, but the problem is that this pointer in
210
+ // SWriteDescriptorSet.info isn't const
211
+ // can we change it?
212
+ write.info = &descriptor;
213
+ }
214
+ infos.push_back (descriptor);
215
+ writes.push_back (write);
190
216
}
217
+
218
+ m_logicalDevice->updateDescriptorSets (writes, {});
191
219
}
192
220
inline void multi_deallocate (uint32_t binding, size_type count, const size_type* addr)
193
221
{
0 commit comments