Validate destination texture states for CopyTextureForBrowser

Current implmentation of ValidateCopyTextureForBrowser has a bug
to verify destination texture states.
This CL fix the simple bug and add noop copy in unittest to catch this
issue.

Bug: dawn:1306
Change-Id: I193105ced89db5092873d604c7dbf43d7ea4fba0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/82101
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Shaobo 2022-03-02 02:44:01 +00:00 committed by Dawn LUCI CQ
parent 02737aa6bd
commit a24acf2fbc
2 changed files with 34 additions and 9 deletions

View File

@ -329,8 +329,9 @@ namespace dawn::native {
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_INVALID_IF(
destination->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");

View File

@ -159,33 +159,57 @@ TEST_F(CopyTextureForBrowserTest, IncorrectUsage) {
// Test source or destination texture is destroyed.
TEST_F(CopyTextureForBrowserTest, DestroyedTexture) {
wgpu::Texture source =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::TextureBinding);
wgpu::Texture destination =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::RenderAttachment);
wgpu::CopyTextureForBrowserOptions options = {};
// Valid src and dst textures.
{
wgpu::Texture source =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::TextureBinding);
wgpu::Texture destination =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::RenderAttachment);
TestCopyTextureForBrowser(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
{0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, options);
// Check noop copy
TestCopyTextureForBrowser(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
{0, 0, 0}, {0, 0, 0}, wgpu::TextureAspect::All, options);
}
// Destroyed src texture.
{
wgpu::Texture source =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::TextureBinding);
wgpu::Texture destination =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::RenderAttachment);
source.Destroy();
TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
{0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, options);
// Check noop copy
TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
{0, 0, 0}, {0, 0, 0}, wgpu::TextureAspect::All, options);
}
// Destroyed dst texture.
{
wgpu::Texture source =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::TextureBinding);
wgpu::Texture destination =
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::RenderAttachment);
destination.Destroy();
TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
{0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, options);
// Check noop copy
TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
{0, 0, 0}, {0, 0, 0}, wgpu::TextureAspect::All, options);
}
}