[Vulkan] Free texture base region as well

This commit is contained in:
DrChat 2018-03-03 20:50:51 -06:00
parent 9774c93181
commit d0e5856608
2 changed files with 12 additions and 7 deletions

View File

@ -379,12 +379,19 @@ bool TextureCache::FreeTexture(Texture* texture) {
for (auto region_it = texture->regions.begin();
region_it != texture->regions.end(); ++region_it) {
TextureRegion* region = region_it->get();
for (auto view_it = region->views.begin(); view_it != region->views.end();
++view_it) {
vkDestroyImageView(*device_, (*view_it)->view, nullptr);
for (auto& view : region->views) {
vkDestroyImageView(*device_, view->view, nullptr);
}
vmaDestroyImage(mem_allocator_, region->image, region->allocation);
}
texture->regions.clear();
// Free the base region (which is not part of regions)
for (auto& view : texture->base_region->views) {
vkDestroyImageView(*device_, view->view, nullptr);
}
vmaDestroyImage(mem_allocator_, texture->base_region->image,
texture->base_region->allocation);
if (texture->access_watch_handle) {
memory_->CancelAccessWatch(texture->access_watch_handle);

View File

@ -80,10 +80,8 @@ class TextureCache {
std::vector<std::unique_ptr<TextureRegion>> regions;
// Non-owning; base region is also in the (owning) regions vector.
TextureRegion* base_region;
VkFramebuffer framebuffer; // Blit target frame buffer.
TextureRegion* base_region; // Base region representing the entire image.
VkFramebuffer framebuffer; // Blit target frame buffer.
uintptr_t access_watch_handle;
bool pending_invalidation;