@@ -342,6 +342,29 @@ void ValidationStateTracker::PreCallRecordCmdBlitImage2(VkCommandBuffer commandB
342
342
Get<IMAGE_STATE>(pBlitImageInfo->dstImage ));
343
343
}
344
344
345
+ struct BufferAddressInfillUpdateOps {
346
+ using Map = typename ValidationStateTracker::BufferAddressRangeMap;
347
+ using Iterator = typename Map::iterator;
348
+ using Value = typename Map::value_type;
349
+ using Mapped = typename Map::mapped_type;
350
+ using Range = typename Map::key_type;
351
+ void infill (Map &map, const Iterator &pos, const Range &infill_range) const {
352
+ map.insert (pos, Value (infill_range, insert_value));
353
+ }
354
+ void update (const Iterator &pos) const {
355
+ auto ¤t_buffer_list = pos->second ;
356
+ assert (!current_buffer_list.empty ());
357
+ const auto buffer_found_it = std::find (current_buffer_list.begin (), current_buffer_list.end (), insert_value[0 ]);
358
+ if (buffer_found_it == current_buffer_list.end ()) {
359
+ if (current_buffer_list.capacity () <= (current_buffer_list.size () + 1 )) {
360
+ current_buffer_list.reserve (current_buffer_list.capacity () * 2 );
361
+ }
362
+ current_buffer_list.emplace_back (insert_value[0 ]);
363
+ }
364
+ }
365
+ const Mapped &insert_value;
366
+ };
367
+
345
368
void ValidationStateTracker::PostCallRecordCreateBuffer (VkDevice device, const VkBufferCreateInfo *pCreateInfo,
346
369
const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer,
347
370
VkResult result) {
@@ -366,14 +389,8 @@ void ValidationStateTracker::PostCallRecordCreateBuffer(VkDevice device, const V
366
389
buffer_state->deviceAddress = opaque_capture_address->opaqueCaptureAddress ;
367
390
const auto address_range = buffer_state->DeviceAddressRange ();
368
391
369
- buffer_address_map_.split_and_merge_insert (
370
- {address_range, {buffer_state}}, [](auto ¤t_buffer_list, const auto &new_buffer) {
371
- assert (!current_buffer_list.empty ());
372
- const auto buffer_found_it = std::find (current_buffer_list.begin (), current_buffer_list.end (), new_buffer[0 ]);
373
- if (buffer_found_it == current_buffer_list.end ()) {
374
- current_buffer_list.emplace_back (new_buffer[0 ]);
375
- }
376
- });
392
+ BufferAddressInfillUpdateOps ops{{buffer_state}};
393
+ sparse_container::infill_update_range (buffer_address_map_, address_range, ops);
377
394
}
378
395
379
396
const VkBufferUsageFlags descriptor_buffer_usages =
@@ -5707,14 +5724,8 @@ void ValidationStateTracker::RecordGetBufferDeviceAddress(const VkBufferDeviceAd
5707
5724
buffer_state->deviceAddress = address;
5708
5725
const auto address_range = buffer_state->DeviceAddressRange ();
5709
5726
5710
- buffer_address_map_.split_and_merge_insert (
5711
- {address_range, {buffer_state}}, [](auto ¤t_buffer_list, const auto &new_buffer) {
5712
- assert (!current_buffer_list.empty ());
5713
- const auto buffer_found_it = std::find (current_buffer_list.begin (), current_buffer_list.end (), new_buffer[0 ]);
5714
- if (buffer_found_it == current_buffer_list.end ()) {
5715
- current_buffer_list.emplace_back (new_buffer[0 ]);
5716
- }
5717
- });
5727
+ BufferAddressInfillUpdateOps ops{{buffer_state}};
5728
+ sparse_container::infill_update_range (buffer_address_map_, address_range, ops);
5718
5729
}
5719
5730
}
5720
5731
0 commit comments