| 3398 | } |
| 3399 | |
| 3400 | bool BlockMetadata_Linear::Validate() const |
| 3401 | { |
| 3402 | D3D12MA_VALIDATE(GetSumFreeSize() <= GetSize()); |
| 3403 | const SuballocationVectorType& suballocations1st = AccessSuballocations1st(); |
| 3404 | const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); |
| 3405 | |
| 3406 | D3D12MA_VALIDATE(suballocations2nd.empty() == (m_2ndVectorMode == SECOND_VECTOR_EMPTY)); |
| 3407 | D3D12MA_VALIDATE(!suballocations1st.empty() || |
| 3408 | suballocations2nd.empty() || |
| 3409 | m_2ndVectorMode != SECOND_VECTOR_RING_BUFFER); |
| 3410 | |
| 3411 | if (!suballocations1st.empty()) |
| 3412 | { |
| 3413 | // Null item at the beginning should be accounted into m_1stNullItemsBeginCount. |
| 3414 | D3D12MA_VALIDATE(suballocations1st[m_1stNullItemsBeginCount].type != SUBALLOCATION_TYPE_FREE); |
| 3415 | // Null item at the end should be just pop_back(). |
| 3416 | D3D12MA_VALIDATE(suballocations1st.back().type != SUBALLOCATION_TYPE_FREE); |
| 3417 | } |
| 3418 | if (!suballocations2nd.empty()) |
| 3419 | { |
| 3420 | // Null item at the end should be just pop_back(). |
| 3421 | D3D12MA_VALIDATE(suballocations2nd.back().type != SUBALLOCATION_TYPE_FREE); |
| 3422 | } |
| 3423 | |
| 3424 | D3D12MA_VALIDATE(m_1stNullItemsBeginCount + m_1stNullItemsMiddleCount <= suballocations1st.size()); |
| 3425 | D3D12MA_VALIDATE(m_2ndNullItemsCount <= suballocations2nd.size()); |
| 3426 | |
| 3427 | UINT64 sumUsedSize = 0; |
| 3428 | const size_t suballoc1stCount = suballocations1st.size(); |
| 3429 | UINT64 offset = 0; |
| 3430 | |
| 3431 | if (m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) |
| 3432 | { |
| 3433 | const size_t suballoc2ndCount = suballocations2nd.size(); |
| 3434 | size_t nullItem2ndCount = 0; |
| 3435 | for (size_t i = 0; i < suballoc2ndCount; ++i) |
| 3436 | { |
| 3437 | const Suballocation& suballoc = suballocations2nd[i]; |
| 3438 | const bool currFree = (suballoc.type == SUBALLOCATION_TYPE_FREE); |
| 3439 | |
| 3440 | const Allocation* alloc = (Allocation*)suballoc.privateData; |
| 3441 | if (!IsVirtual()) |
| 3442 | { |
| 3443 | D3D12MA_VALIDATE(currFree == (alloc == NULL)); |
| 3444 | } |
| 3445 | D3D12MA_VALIDATE(suballoc.offset >= offset); |
| 3446 | |
| 3447 | if (!currFree) |
| 3448 | { |
| 3449 | if (!IsVirtual()) |
| 3450 | { |
| 3451 | D3D12MA_VALIDATE(GetAllocationOffset(alloc->GetAllocHandle()) == suballoc.offset); |
| 3452 | D3D12MA_VALIDATE(alloc->GetSize() == suballoc.size); |
| 3453 | } |
| 3454 | sumUsedSize += suballoc.size; |
| 3455 | } |
| 3456 | else |
| 3457 | { |
no test coverage detected