@@ -171,31 +171,54 @@ class NBL_API ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSetL
171
171
}
172
172
inline const ICPUDescriptorSetLayout* getLayout () const { return m_layout.get (); }
173
173
174
- std::pair<core::SRange<core::smart_refctd_ptr<IDescriptor>>, core::SRange<SDescriptorInfo::SBufferImageInfo>> getDescriptors (const uint32_t binding)
174
+ std::pair<core::SRange<core::smart_refctd_ptr<IDescriptor>>, core::SRange<SDescriptorInfo::SBufferImageInfo>> getDescriptors (const uint32_t binding, E_DESCRIPTOR_TYPE type = EDT_COUNT )
175
175
{
176
- const auto bindingInfo = std::lower_bound (getLayout ()->getBindings ().begin (), getLayout ()->getBindings ().end (), ICPUDescriptorSetLayout::SBinding{binding});
177
- assert (bindingInfo->binding == binding && " binding is not in the descriptor set!" );
176
+ if (type == EDT_COUNT)
177
+ {
178
+ for (uint32_t t = 0 ; t < EDT_COUNT; ++t)
179
+ {
180
+ const auto possibleType = static_cast <E_DESCRIPTOR_TYPE>(t);
181
+ const auto & redirect = getLayout ()->getDescriptorRedirect (possibleType);
182
+ if (redirect.searchForBinding (binding) != redirect.Invalid )
183
+ {
184
+ type = possibleType;
185
+ break ;
186
+ }
187
+ }
178
188
179
- const uint32_t descriptorOffset = getLayout ()->getDescriptorOffset (bindingInfo->type , binding);
180
- const uint32_t descriptorCount = bindingInfo->count ;
189
+ if (type == EDT_COUNT)
190
+ return { {nullptr , nullptr }, {nullptr , nullptr } };
191
+ }
192
+
193
+ const auto & redirect = getLayout ()->getDescriptorRedirect (type);
194
+ const auto bindingNumberIndex = redirect.searchForBinding (binding);
195
+ if (bindingNumberIndex == redirect.Invalid )
196
+ return { {nullptr , nullptr }, {nullptr , nullptr } };
197
+
198
+ const auto descriptorOffset = redirect.getStorageOffset (binding, bindingNumberIndex).data ;
199
+ const auto descriptorCount = redirect.getDescriptorCount (binding, bindingNumberIndex);
181
200
182
- auto descriptorsBegin = m_descriptors[bindingInfo-> type ]->begin () + descriptorOffset;
183
- auto descriptorInfosBegin = m_descriptorInfos[bindingInfo-> type ]->begin () + descriptorOffset;
201
+ auto descriptorsBegin = m_descriptors[type]->begin () + descriptorOffset;
202
+ auto descriptorInfosBegin = m_descriptorInfos[type]->begin () + descriptorOffset;
184
203
185
204
return { {descriptorsBegin, descriptorsBegin+descriptorCount}, {descriptorInfosBegin, descriptorInfosBegin+descriptorCount} };
186
205
}
187
206
188
207
core::SRange<core::smart_refctd_ptr<ICPUSampler>> getMutableSamplers (const uint32_t binding) const
189
208
{
190
- const uint32_t offset = getLayout ()->getMutableSamplerOffset (binding);
191
- if (offset == ~0u )
209
+ const auto & redirect = getLayout ()->getSamplerRedirect ();
210
+
211
+ const auto bindingNumberIndex = redirect.searchForBinding (binding);
212
+ if (bindingNumberIndex == redirect.Invalid )
192
213
return { nullptr , nullptr };
193
214
194
- const auto bindingInfo = std::lower_bound (getLayout ()->getBindings ().begin (), getLayout ()->getBindings ().end (), ICPUDescriptorSetLayout::SBinding{ binding });
195
- assert (bindingInfo->binding == binding && " binding is not in the descriptor set!" );
215
+ const auto offset = redirect.getStorageOffset (binding, bindingNumberIndex).data ;
216
+ assert (offset != redirect.Invalid );
217
+
218
+ const auto count = redirect.getDescriptorCount (binding, bindingNumberIndex);
196
219
197
220
auto samplersBegin = m_mutableSamplers->begin () + offset;
198
- return { samplersBegin, samplersBegin + bindingInfo-> count };
221
+ return { samplersBegin, samplersBegin + count };
199
222
}
200
223
201
224
inline core::smart_refctd_ptr<IDescriptor>* getDescriptorStorage (const E_DESCRIPTOR_TYPE type) const { return m_descriptors[type]->begin (); }
0 commit comments