case AllocationCallbackRecord::TYPE_ALLOCATION:
{
if (record.data.allocation.returnedPtr)
- {
+ {
if (!de::contains(ptrToSlotIndex, record.data.allocation.returnedPtr))
{
ptrToSlotIndex[record.data.allocation.returnedPtr] = allocations.size();
else
{
const size_t slotNdx = ptrToSlotIndex[record.data.allocation.returnedPtr];
- if (!allocations[slotNdx].isLive)
+ if (!allocations[slotNdx].isLive)
{
allocations[slotNdx].isLive = true;
allocations[slotNdx].record = record;
if (record.data.reallocation.returnedPtr)
{
- DE_ASSERT(!de::contains(ptrToSlotIndex, record.data.reallocation.returnedPtr));
- ptrToSlotIndex[record.data.reallocation.returnedPtr] = allocations.size();
- allocations.push_back(AllocationSlot(record, true));
+ if (!de::contains(ptrToSlotIndex, record.data.reallocation.returnedPtr))
+ {
+ ptrToSlotIndex[record.data.reallocation.returnedPtr] = allocations.size();
+ allocations.push_back(AllocationSlot(record, true));
+ }
+ else
+ {
+ const size_t slotNdx = ptrToSlotIndex[record.data.reallocation.returnedPtr];
+ DE_ASSERT(!allocations[slotNdx].isLive);
+ allocations[slotNdx].isLive = true;
+ allocations[slotNdx].record = record;
+ }
}
}
return checkAndLog(log, validationResults, allowedLiveAllocScopeBits);
}
+size_t getLiveSystemAllocationTotal (const AllocationCallbackValidationResults& validationResults)
+{
+ size_t allocationTotal = 0;
+
+ DE_ASSERT(validationResults.violations.empty());
+
+ for (std::vector<AllocationCallbackRecord>::const_iterator alloc = validationResults.liveAllocations.begin();
+ alloc != validationResults.liveAllocations.end();
+ ++alloc)
+ {
+ DE_ASSERT(alloc->type == AllocationCallbackRecord::TYPE_ALLOCATION ||
+ alloc->type == AllocationCallbackRecord::TYPE_REALLOCATION);
+
+ const size_t size = (alloc->type == AllocationCallbackRecord::TYPE_ALLOCATION ? alloc->data.allocation.size : alloc->data.reallocation.size);
+ const size_t alignment = (alloc->type == AllocationCallbackRecord::TYPE_ALLOCATION ? alloc->data.allocation.alignment : alloc->data.reallocation.alignment);
+
+ allocationTotal += size + alignment - (alignment > 0 ? 1 : 0);
+ }
+
+ for (int internalAllocationTypeNdx = 0; internalAllocationTypeNdx < VK_INTERNAL_ALLOCATION_TYPE_LAST; ++internalAllocationTypeNdx)
+ {
+ for (int internalAllocationScopeNdx = 0; internalAllocationScopeNdx < VK_SYSTEM_ALLOCATION_SCOPE_LAST; ++internalAllocationScopeNdx)
+ allocationTotal += validationResults.internalAllocationTotal[internalAllocationTypeNdx][internalAllocationScopeNdx];
+ }
+
+ return allocationTotal;
+}
+
std::ostream& operator<< (std::ostream& str, const AllocationCallbackRecord& record)
{
switch (record.type)