Skip to content

Commit 908da9d

Browse files
committed
Bug Fix - Reserve vectors to avoid pointer change while iterating
1 parent 87a9c44 commit 908da9d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/nbl/video/CVulkanLogicalDevice.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,17 @@ class CVulkanLogicalDevice final : public ILogicalDevice
12461246
std::vector<VkSampler> vk_samplers;
12471247
std::vector<VkDescriptorSetLayoutBinding> vk_dsLayoutBindings;
12481248

1249+
uint32_t maxSamplersCount = 0u;
1250+
for (uint32_t b = 0u; b < bindingCount; ++b)
1251+
{
1252+
auto binding = _begin + b;
1253+
if (binding->samplers && binding->count > 0u)
1254+
maxSamplersCount += binding->count;
1255+
}
1256+
1257+
vk_samplers.reserve(maxSamplersCount); // Reserve to avoid resizing and pointer change while iterating
1258+
vk_dsLayoutBindings.reserve(bindingCount);
1259+
12491260
for (uint32_t b = 0u; b < bindingCount; ++b)
12501261
{
12511262
auto binding = _begin + b;

0 commit comments

Comments
 (0)