Protect Texture::DestroyImpl against multiple calls for D3D12
Calling Texture::DestroyImpl will cause a crash when passing a nullptr D3D12 resource to the Present method of ID3D12SharingContract. Protect against crashes by checking whether the allocation we're destroying is valid before proceeding. Change-Id: Ifb68c1f85383db5027006cf435f43c84d1a463d9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42580 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
This commit is contained in:
parent
9b5f442c78
commit
c36a9e8579
|
@ -567,6 +567,11 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
device->DeallocateMemory(mResourceAllocation);
|
device->DeallocateMemory(mResourceAllocation);
|
||||||
|
|
||||||
|
// Now that we've deallocated the memory, the texture is no longer a swap chain texture.
|
||||||
|
// We can set mSwapChainTexture to false to avoid passing a nullptr to
|
||||||
|
// ID3D12SharingContract::Present.
|
||||||
|
mSwapChainTexture = false;
|
||||||
|
|
||||||
if (mDxgiKeyedMutex != nullptr) {
|
if (mDxgiKeyedMutex != nullptr) {
|
||||||
mDxgiKeyedMutex->ReleaseSync(uint64_t(mAcquireMutexKey) + 1);
|
mDxgiKeyedMutex->ReleaseSync(uint64_t(mAcquireMutexKey) + 1);
|
||||||
device->ReleaseKeyedMutexForTexture(std::move(mDxgiKeyedMutex));
|
device->ReleaseKeyedMutexForTexture(std::move(mDxgiKeyedMutex));
|
||||||
|
|
Loading…
Reference in New Issue