| 506 | } |
| 507 | |
| 508 | void TextureManager::removeTextures(const Object* object) |
| 509 | { |
| 510 | FALCOR_CHECK(object != nullptr, "Missing object."); |
| 511 | |
| 512 | waitForAllTexturesLoading(); |
| 513 | |
| 514 | std::lock_guard<std::mutex> lock(mMutex); |
| 515 | |
| 516 | // Remove object from ownership of all its associated textures. |
| 517 | // All textures that are left without any owners will be removed below. |
| 518 | std::vector<CpuTextureHandle> handles; |
| 519 | { |
| 520 | auto obj = mObjectToHandles.find(object); |
| 521 | if (obj == mObjectToHandles.end()) |
| 522 | return; |
| 523 | for (auto handle : obj->second) |
| 524 | { |
| 525 | auto it = mHandleToObjects.find(handle); |
| 526 | FALCOR_ASSERT(it != mHandleToObjects.end()); |
| 527 | it->second.erase(object); |
| 528 | if (it->second.empty()) |
| 529 | handles.push_back(handle); |
| 530 | } |
| 531 | mObjectToHandles.erase(obj); |
| 532 | } |
| 533 | |
| 534 | // Remove all textures that are now unowned. |
| 535 | for (const auto& handle : handles) |
| 536 | removeTextureInternal(handle); |
| 537 | |
| 538 | if (!handles.empty()) |
| 539 | logInfo("Texture manager: Removed {} textures.", handles.size()); |
| 540 | } |
| 541 | |
| 542 | TextureManager::TextureDesc TextureManager::getTextureDesc(const CpuTextureHandle& handle) const |
| 543 | { |