From 534a198f8855a7defc89a1d95ff23a33729aa4d1 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 22 Sep 2022 22:10:56 +0000 Subject: [PATCH] Validate that the device is alive when wrapping external images Will be tested in Chromium's webgpu_mailbox_unittest.cc Bug: chromium:1359106 Change-Id: I8a9bf01cd593f2835e2876fa04139fd3afda9b2e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103462 Reviewed-by: Loko Kung Commit-Queue: Austin Eng --- src/dawn/native/metal/DeviceMTL.mm | 4 +++- src/dawn/native/vulkan/DeviceVk.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dawn/native/metal/DeviceMTL.mm b/src/dawn/native/metal/DeviceMTL.mm index e5e592b6c2..4c8918472e 100644 --- a/src/dawn/native/metal/DeviceMTL.mm +++ b/src/dawn/native/metal/DeviceMTL.mm @@ -464,7 +464,9 @@ MaybeError Device::CopyFromStagingToTexture(const StagingBufferBase* source, Ref Device::CreateTextureWrappingIOSurface(const ExternalImageDescriptor* descriptor, IOSurfaceRef ioSurface) { const TextureDescriptor* textureDescriptor = FromAPI(descriptor->cTextureDescriptor); - + if (ConsumedError(ValidateIsAlive())) { + return nullptr; + } if (ConsumedError(ValidateTextureDescriptor(this, textureDescriptor))) { return nullptr; } diff --git a/src/dawn/native/vulkan/DeviceVk.cpp b/src/dawn/native/vulkan/DeviceVk.cpp index 5d6ba5a0a3..fec7cb51ad 100644 --- a/src/dawn/native/vulkan/DeviceVk.cpp +++ b/src/dawn/native/vulkan/DeviceVk.cpp @@ -904,6 +904,9 @@ TextureBase* Device::CreateTextureWrappingVulkanImage( const TextureDescriptor* textureDescriptor = FromAPI(descriptor->cTextureDescriptor); // Initial validation + if (ConsumedError(ValidateIsAlive())) { + return nullptr; + } if (ConsumedError(ValidateTextureDescriptor(this, textureDescriptor))) { return nullptr; }