From d90a4f50a1e21f6d40f8ad70b53e1cdb98fc33a3 Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Fri, 21 Jan 2022 23:38:08 +0000 Subject: [PATCH] Remove External Texture Format Member Validation Removes validation of the format member of an external texture descriptor. Replaces it with format information inferred from the passed texture. Bug: dawn:1082 Change-Id: I333c3659859501eff48a532aa4701f25a33124c2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77480 Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya Commit-Queue: Brandon1 Jones --- src/dawn_native/ExternalTexture.cpp | 25 ++++++------------- .../validation/BindGroupValidationTests.cpp | 5 ++-- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/dawn_native/ExternalTexture.cpp b/src/dawn_native/ExternalTexture.cpp index 63fa38560e..c701aa9ab4 100644 --- a/src/dawn_native/ExternalTexture.cpp +++ b/src/dawn_native/ExternalTexture.cpp @@ -22,14 +22,7 @@ namespace dawn::native { - MaybeError ValidateExternalTexturePlane(const TextureViewBase* textureView, - wgpu::TextureFormat format) { - if (textureView->GetFormat().format != format) { - return DAWN_VALIDATION_ERROR( - "The external texture descriptor specifies a texture format that is different from " - "at least one of the passed texture views."); - } - + MaybeError ValidateExternalTexturePlane(const TextureViewBase* textureView) { DAWN_INVALID_IF( (textureView->GetTexture()->GetUsage() & wgpu::TextureUsage::TextureBinding) == 0, "The external texture plane (%s) usage (%s) doesn't include the required usage (%s)", @@ -57,22 +50,20 @@ namespace dawn::native { DAWN_TRY(device->ValidateObject(descriptor->plane0)); - const Format* format; - DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format)); - DAWN_UNUSED(format); + wgpu::TextureFormat plane0Format = descriptor->plane0->GetFormat().format; - switch (descriptor->format) { + switch (plane0Format) { case wgpu::TextureFormat::RGBA8Unorm: case wgpu::TextureFormat::BGRA8Unorm: case wgpu::TextureFormat::RGBA16Float: - DAWN_TRY_CONTEXT( - ValidateExternalTexturePlane(descriptor->plane0, descriptor->format), - "validating plane0 against the external texture format (%s)", - descriptor->format); + DAWN_TRY(ValidateExternalTexturePlane(descriptor->plane0)); break; default: return DAWN_FORMAT_VALIDATION_ERROR( - "Format (%s) is not a supported external texture format.", descriptor->format); + "The external texture plane (%s) format (%s) is not a supported format " + "(%s, %s, %s).", + descriptor->plane0, plane0Format, wgpu::TextureFormat::RGBA8Unorm, + wgpu::TextureFormat::BGRA8Unorm, wgpu::TextureFormat::RGBA16Float); } return {}; diff --git a/src/tests/unittests/validation/BindGroupValidationTests.cpp b/src/tests/unittests/validation/BindGroupValidationTests.cpp index 16302b9e90..77e7636e7b 100644 --- a/src/tests/unittests/validation/BindGroupValidationTests.cpp +++ b/src/tests/unittests/validation/BindGroupValidationTests.cpp @@ -357,9 +357,10 @@ TEST_F(BindGroupValidationTest, ExternalTextureBindingType) { // Setting the external texture to an error external texture is an error. { + wgpu::Texture errorTexture = CreateTexture(wgpu::TextureUsage::TextureBinding, + wgpu::TextureFormat::RGBA8UnormSrgb, 1); wgpu::ExternalTextureDescriptor errorExternalDesciptor; - errorExternalDesciptor.plane0 = texture.CreateView(); - errorExternalDesciptor.format = wgpu::TextureFormat::R8Uint; + errorExternalDesciptor.plane0 = errorTexture.CreateView(); wgpu::ExternalTexture errorExternalTexture; ASSERT_DEVICE_ERROR(errorExternalTexture =