diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index d2b6548c0e..cb1f741d2e 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -418,9 +418,7 @@ namespace dawn_native { } } - // 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 a07d3d9db3..886422d7e5 100644 --- a/src/tests/unittests/validation/TextureViewValidationTests.cpp +++ b/src/tests/unittests/validation/TextureViewValidationTests.cpp @@ -79,6 +79,13 @@ namespace { 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 @@ namespace { 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 @@ namespace { 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 @@ namespace { 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;