Treat 'mipLevelCount == 0' as error

It's no longer a valid default value.

Bug: dawn:1026

Change-Id: I9de656f29c8b7673de412cef35dcfb8a45121ac7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64165
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp
index d2b6548..cb1f741 100644
--- a/src/dawn_native/Texture.cpp
+++ b/src/dawn_native/Texture.cpp
@@ -418,9 +418,7 @@
             }
         }
 
-        // TODO(jie.a.chen@intel.com): Remove 'desc.mipLevelCount == 0' once the WebGPU change is
-        // landed.
-        if (desc.mipLevelCount == 0 || desc.mipLevelCount == wgpu::kMipLevelCountUndefined) {
+        if (desc.mipLevelCount == wgpu::kMipLevelCountUndefined) {
             desc.mipLevelCount = texture->GetNumMipLevels() - desc.baseMipLevel;
         }
         return desc;
diff --git a/src/tests/unittests/validation/TextureViewValidationTests.cpp b/src/tests/unittests/validation/TextureViewValidationTests.cpp
index a07d3d9..886422d 100644
--- a/src/tests/unittests/validation/TextureViewValidationTests.cpp
+++ b/src/tests/unittests/validation/TextureViewValidationTests.cpp
@@ -79,6 +79,13 @@
             ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
         }
 
+        // It is an error to create a view with zero 'mipLevelCount'.
+        {
+            wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
+            descriptor.mipLevelCount = 0;
+            ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
+        }
+
         // It is OK to create a 2D texture view on a 2D texture.
         {
             wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
@@ -160,6 +167,14 @@
             ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
         }
 
+        // It is an error to create a view with zero 'mipLevelCount'.
+        {
+            wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
+            descriptor.dimension = wgpu::TextureViewDimension::e2D;
+            descriptor.mipLevelCount = 0;
+            ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
+        }
+
         // It is OK to create a 2D texture view on a 2D array texture.
         {
             wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
@@ -231,6 +246,13 @@
             ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
         }
 
+        // It is an error to create a view with zero 'mipLevelCount'.
+        {
+            wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
+            descriptor.mipLevelCount = 0;
+            ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
+        }
+
         // It is OK to create a 3D texture view on a 3D texture.
         {
             wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
@@ -475,6 +497,14 @@
             ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
         }
 
+        // It is an error to create a view with zero 'mipLevelCount'.
+        {
+            wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
+            descriptor.dimension = wgpu::TextureViewDimension::Cube;
+            descriptor.mipLevelCount = 0;
+            ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
+        }
+
         // It is OK to create a cube map texture view with arrayLayerCount == 6.
         {
             wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;