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:
parent
02737aa6bd
commit
a24acf2fbc
|
@ -329,7 +329,8 @@ namespace dawn::native {
|
||||||
DAWN_INVALID_IF(source->texture->GetTextureState() == TextureBase::TextureState::Destroyed,
|
DAWN_INVALID_IF(source->texture->GetTextureState() == TextureBase::TextureState::Destroyed,
|
||||||
"Source texture %s is destroyed.", source->texture);
|
"Source texture %s is destroyed.", source->texture);
|
||||||
|
|
||||||
DAWN_INVALID_IF(source->texture->GetTextureState() == TextureBase::TextureState::Destroyed,
|
DAWN_INVALID_IF(
|
||||||
|
destination->texture->GetTextureState() == TextureBase::TextureState::Destroyed,
|
||||||
"Destination texture %s is destroyed.", destination->texture);
|
"Destination texture %s is destroyed.", destination->texture);
|
||||||
|
|
||||||
DAWN_TRY_CONTEXT(ValidateImageCopyTexture(device, *source, *copySize),
|
DAWN_TRY_CONTEXT(ValidateImageCopyTexture(device, *source, *copySize),
|
||||||
|
|
|
@ -159,6 +159,43 @@ TEST_F(CopyTextureForBrowserTest, IncorrectUsage) {
|
||||||
|
|
||||||
// Test source or destination texture is destroyed.
|
// Test source or destination texture is destroyed.
|
||||||
TEST_F(CopyTextureForBrowserTest, DestroyedTexture) {
|
TEST_F(CopyTextureForBrowserTest, DestroyedTexture) {
|
||||||
|
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 =
|
wgpu::Texture source =
|
||||||
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
|
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
|
||||||
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::TextureBinding);
|
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::TextureBinding);
|
||||||
|
@ -166,26 +203,13 @@ TEST_F(CopyTextureForBrowserTest, DestroyedTexture) {
|
||||||
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
|
Create2DTexture(16, 16, 5, 4, wgpu::TextureFormat::RGBA8Unorm,
|
||||||
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::RenderAttachment);
|
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::RenderAttachment);
|
||||||
|
|
||||||
wgpu::CopyTextureForBrowserOptions options = {};
|
|
||||||
|
|
||||||
// Valid src and dst textures.
|
|
||||||
{
|
|
||||||
TestCopyTextureForBrowser(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
|
|
||||||
{0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroyed src texture.
|
|
||||||
{
|
|
||||||
source.Destroy();
|
|
||||||
TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
|
|
||||||
{0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroyed dst texture.
|
|
||||||
{
|
|
||||||
destination.Destroy();
|
destination.Destroy();
|
||||||
TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
|
TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
|
||||||
{0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, options);
|
{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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue