From 59f2038dce0e7636c7afe8b922d025a05767a5e1 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Fri, 9 Apr 2021 07:31:37 +0000 Subject: [PATCH] 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 Reviewed-by: Corentin Wallez --- src/dawn_native/ExternalTexture.cpp | 2 ++ .../validation/ExternalTextureTests.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/dawn_native/ExternalTexture.cpp b/src/dawn_native/ExternalTexture.cpp index b65ba467d0..76d06c5f49 100644 --- a/src/dawn_native/ExternalTexture.cpp +++ b/src/dawn_native/ExternalTexture.cpp @@ -55,6 +55,8 @@ namespace dawn_native { ASSERT(descriptor); ASSERT(descriptor->plane0); + DAWN_TRY(device->ValidateObject(descriptor->plane0)); + const Format* format; DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format)); diff --git a/src/tests/unittests/validation/ExternalTextureTests.cpp b/src/tests/unittests/validation/ExternalTextureTests.cpp index 70c9590a13..29e5e5fd3c 100644 --- a/src/tests/unittests/validation/ExternalTextureTests.cpp +++ b/src/tests/unittests/validation/ExternalTextureTests.cpp @@ -94,6 +94,22 @@ namespace { externalDesc.format = kUnsupportedFormat; 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 \ No newline at end of file