Fix a bug about depth/stencil formats validation

Depth/stencil formats are invalid for 1D and 3D texture.
This change adds this validation rule, and adds a validation
test for it.

Bug: dawn:730
Change-Id: Idac6d1bf7b8c7261eb7b4b59504de10e13d049cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47200
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Yunchao He
2021-04-13 06:49:24 +00:00
committed by Commit Bot service account
parent e190045664
commit 71f3d58939
3 changed files with 35 additions and 0 deletions

View File

@@ -401,6 +401,33 @@ namespace {
}
}
// Test that depth/stencil formats are invalid for 3D texture
TEST_F(TextureValidationTest, DepthStencilFormatsFor3D) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
wgpu::TextureDimension dimensions[] = {
wgpu::TextureDimension::e1D,
wgpu::TextureDimension::e3D,
};
// TODO(dawn:690): Uncomment these depth/stencil formats after we implement them in Dawn.
wgpu::TextureFormat depthStencilFormats[] = {
wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth24Plus,
wgpu::TextureFormat::Stencil8, wgpu::TextureFormat::Depth24PlusStencil8,
// wgpu::TextureFormat::Depth16Unorm,
// wgpu::TextureFormat::Depth24UnormStencil8,
// wgpu::TextureFormat::Depth32FloatStencil8,
};
for (wgpu::TextureDimension dimension : dimensions) {
for (wgpu::TextureFormat format : depthStencilFormats) {
descriptor.format = format;
descriptor.dimension = dimension;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}
}
}
// Test that it is valid to destroy a texture
TEST_F(TextureValidationTest, DestroyTexture) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();