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 <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
This commit is contained in:
Shaobo 2022-02-24 02:26:26 +00:00 committed by Dawn LUCI CQ
parent d5d12e3429
commit 6084407b21
1 changed files with 5 additions and 8 deletions

View File

@ -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");