Fix ResourceHeapAllocation Memory Leak

ResourceAllocatorManager::DeallocateMemory was correctly invalidating the
passed in allocation object. However, since the subclass
ResourceHeapAllocation class was not overriding the Invalidate method and
clearing out the D3D12Resource pointer, the resource ended up being tied
to the lifetime of the Texture object instead of being released on Destroy.

In Chromium, this bug was particularly egregious as it meant swap chain
texture cleanup was at the whims of the Javascript garbage collector.

Bug: dawn:242
Change-Id: Ia5856c61c8d3b92a2247a9aaa5f91c5de0a99dcb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13200
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Rafael Cintron
2019-11-08 21:47:00 +00:00
committed by Commit Bot service account
parent 39b4b38f4f
commit 600a26d50a
4 changed files with 12 additions and 3 deletions

View File

@@ -54,14 +54,14 @@ namespace dawn_native {
uint64_t offset,
ResourceHeapBase* resourceHeap,
uint8_t* mappedPointer = nullptr);
~ResourceMemoryAllocation() = default;
virtual ~ResourceMemoryAllocation() = default;
ResourceHeapBase* GetResourceHeap() const;
uint64_t GetOffset() const;
uint8_t* GetMappedPointer() const;
AllocationInfo GetInfo() const;
void Invalidate();
virtual void Invalidate();
private:
AllocationInfo mInfo;