Report error when plane0 is not a valid object in CreateExternalTexture

BUG=chromium:1197329
TEST=dawn_unittests

Change-Id: I801e1d8800c4138e1a3d6040cf623c58063bc30b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47400
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Jiawei Shao 2021-04-09 07:31:37 +00:00 committed by Commit Bot service account
parent 4a7c120456
commit 59f2038dce
2 changed files with 18 additions and 0 deletions

View File

@ -55,6 +55,8 @@ namespace dawn_native {
ASSERT(descriptor); ASSERT(descriptor);
ASSERT(descriptor->plane0); ASSERT(descriptor->plane0);
DAWN_TRY(device->ValidateObject(descriptor->plane0));
const Format* format; const Format* format;
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format)); DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format));

View File

@ -94,6 +94,22 @@ namespace {
externalDesc.format = kUnsupportedFormat; externalDesc.format = kUnsupportedFormat;
ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc));
} }
// Creating an external texture with an error texture view should fail.
{
wgpu::Texture internalTexture = device.CreateTexture(&textureDescriptor);
wgpu::TextureViewDescriptor errorViewDescriptor;
errorViewDescriptor.format = kDefaultTextureFormat;
errorViewDescriptor.dimension = wgpu::TextureViewDimension::e2D;
errorViewDescriptor.mipLevelCount = 1;
errorViewDescriptor.arrayLayerCount = 2;
ASSERT_DEVICE_ERROR(wgpu::TextureView errorTextureView =
internalTexture.CreateView(&errorViewDescriptor));
externalDesc.plane0 = errorTextureView;
externalDesc.format = kDefaultTextureFormat;
ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc));
}
} }
} // namespace } // namespace