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 <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He 2021-02-19 05:15:47 +00:00 committed by Commit Bot service account
parent 1024d6e187
commit e9e9ee64f6
2 changed files with 12 additions and 2 deletions

View File

@ -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 {

View File

@ -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) {