From 6084407b212fc69f8626477dcd9d0b85db3a692a Mon Sep 17 00:00:00 2001 From: Shaobo Date: Thu, 24 Feb 2022 02:26:26 +0000 Subject: [PATCH] Change texture state validation in CopyTextureForBrowser() to report meaningful errors CopyTextureForBrowser() will support all uploading paths for WebGPU CopyExternalImageToTexture(). The validation checks for texture states should report accurate errors to meet CopyExternalImageToTexture() validate rules. Bug: dawn:1306 Change-Id: Ie3b25ec82246d53e6c82968b5dc2f8a253c560c1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81240 Reviewed-by: Austin Eng Commit-Queue: Shaobo Yan --- src/dawn/native/CopyTextureForBrowserHelper.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/dawn/native/CopyTextureForBrowserHelper.cpp b/src/dawn/native/CopyTextureForBrowserHelper.cpp index d51cb8333b..84b78c38a9 100644 --- a/src/dawn/native/CopyTextureForBrowserHelper.cpp +++ b/src/dawn/native/CopyTextureForBrowserHelper.cpp @@ -257,12 +257,6 @@ namespace dawn::native { return {}; } - MaybeError ValidateTextureState(const TextureBase* texture) { - DAWN_INVALID_IF(texture->GetTextureState() == TextureBase::TextureState::Destroyed, - "Destroyed texture %s used in CopyTextureForBrowser().", texture); - return {}; - } - RenderPipelineBase* GetCachedPipeline(InternalPipelineStore* store, wgpu::TextureFormat dstFormat) { auto pipeline = store->copyTextureForBrowserPipelines.find(dstFormat); @@ -332,8 +326,11 @@ namespace dawn::native { DAWN_TRY(device->ValidateObject(source->texture)); DAWN_TRY(device->ValidateObject(destination->texture)); - DAWN_TRY(ValidateTextureState(source->texture)); - DAWN_TRY(ValidateTextureState(destination->texture)); + DAWN_INVALID_IF(source->texture->GetTextureState() == TextureBase::TextureState::Destroyed, + "Source texture %s is destroyed.", source->texture); + + DAWN_INVALID_IF(source->texture->GetTextureState() == TextureBase::TextureState::Destroyed, + "Destination texture %s is destroyed.", destination->texture); DAWN_TRY_CONTEXT(ValidateImageCopyTexture(device, *source, *copySize), "validating the ImageCopyTexture for the source");