diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index 9cf2d689f4..faddc5b6c5 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -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; diff --git a/src/tests/end2end/DeprecatedAPITests.cpp b/src/tests/end2end/DeprecatedAPITests.cpp index 312063a5c6..f0783cf13f 100644 --- a/src/tests/end2end/DeprecatedAPITests.cpp +++ b/src/tests/end2end/DeprecatedAPITests.cpp @@ -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(),