Allow arrayLayerCount=0 during the deprecation period.

The value 0 is the default value for default-constructed C descriptors
and should be allowed.

Bug: dawn:22
Change-Id: I876ec4d9c6d70a798b0d6cea5c2ccecaad850eff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26100
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2020-08-03 09:00:12 +00:00 committed by Commit Bot service account
parent 8c9858e9b8
commit 8c201dfadc
2 changed files with 16 additions and 2 deletions

View File

@ -331,9 +331,9 @@ namespace dawn_native {
const TextureDescriptor* desc) {
TextureDescriptor fixedDesc = *desc;
if (desc->arrayLayerCount != 1) {
if (desc->arrayLayerCount >= 2) {
if (desc->size.depth != 1) {
return DAWN_VALIDATION_ERROR("arrayLayerCount and size.depth cannot both be != 1");
return DAWN_VALIDATION_ERROR("arrayLayerCount and size.depth cannot both be set.");
} else {
fixedDesc.size.depth = fixedDesc.arrayLayerCount;
fixedDesc.arrayLayerCount = 1;

View File

@ -132,6 +132,20 @@ TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountStateTracking) {
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDesc));
}
// Test that using TextureDescriptor::arrayLayerCount = 0 is allowed
TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountZero) {
wgpu::TextureDescriptor desc;
desc.usage = wgpu::TextureUsage::Sampled;
desc.dimension = wgpu::TextureDimension::e2D;
desc.size = {1, 1, 1};
desc.arrayLayerCount = 0;
desc.format = wgpu::TextureFormat::RGBA8Unorm;
desc.mipLevelCount = 1;
desc.sampleCount = 1;
device.CreateTexture(&desc);
}
DAWN_INSTANTIATE_TEST(DeprecationTests,
D3D12Backend(),
MetalBackend(),