From e9e9ee64f652ce4b7ca019cbec30a8406f7c8259 Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Fri, 19 Feb 2021 05:15:47 +0000 Subject: [PATCH] Add a validation test for compressed texture with mipmaps Compressed textures (BC formats) can support full or partial mip chains. This tiny change adds a validation test to ensure it. Bug: dawn:558 Change-Id: I584b65b7d049a3f188e3b56ca5c9ff36748151ae Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42004 Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya Commit-Queue: Yunchao He --- src/dawn_native/Texture.cpp | 3 +-- .../unittests/validation/TextureValidationTests.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index 93e4070f4a..21ae34b61b 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -440,8 +440,7 @@ namespace dawn_native { } uint32_t TextureBase::GetHeight() const { ASSERT(!IsError()); - ASSERT(mDimension == wgpu::TextureDimension::e2D || - mDimension == wgpu::TextureDimension::e3D); + ASSERT(mDimension != wgpu::TextureDimension::e1D); return mSize.height; } uint32_t TextureBase::GetDepth() const { diff --git a/src/tests/unittests/validation/TextureValidationTests.cpp b/src/tests/unittests/validation/TextureValidationTests.cpp index f5c0de5430..7ff68f08d9 100644 --- a/src/tests/unittests/validation/TextureValidationTests.cpp +++ b/src/tests/unittests/validation/TextureValidationTests.cpp @@ -575,6 +575,17 @@ namespace { } } + TEST_F(CompressedTextureFormatsValidationTests, MipLevelCount) { + for (wgpu::TextureFormat format : utils::kBCFormats) { + for (uint32_t mipLevels : {1, 3, 6}) { + wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); + descriptor.format = format; + descriptor.mipLevelCount = mipLevels; + device.CreateTexture(&descriptor); + } + } + } + // Test the validation of sample count when creating textures in compressed texture formats. // It is invalid to specify SampleCount > 1 when we create a texture in BC formats. TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {