From 4234d78201afa98e208fef71250c1efe1ee3ad81 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 15 Jun 2020 09:46:01 +0000 Subject: [PATCH] Deprecate TextureDescriptor::arrayLayerCount -> size.depth This updates CL: - Adds a deprecation warning to use size.depth instead of arrayLayerCount. - Changes all tests and samples to use size.depth. - Adds deprecation tests for the change. In particular the state tracking in TextureBase isn't changed yet because it requires non-trivial changes in the backends. It will be done in a follow-up CL. Bug:dawn:22 Change-Id: Ic02dfb5baaba8d5b06cd339ce988e9b1d16cb5e9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23101 Reviewed-by: Jiawei Shao Reviewed-by: Austin Eng Commit-Queue: Corentin Wallez --- examples/CppHelloTriangle.cpp | 1 - examples/SampleUtils.cpp | 1 - src/dawn_native/Device.cpp | 7 +++ src/dawn_native/SwapChain.cpp | 2 - src/dawn_native/Texture.cpp | 38 +++++++++++--- src/dawn_native/Texture.h | 5 ++ src/dawn_native/d3d12/TextureD3D12.cpp | 10 +++- src/dawn_native/metal/DeviceMTL.mm | 9 ++++ src/dawn_native/metal/TextureMTL.mm | 9 ++-- src/dawn_native/opengl/TextureGL.cpp | 2 +- src/dawn_native/vulkan/DeviceVk.cpp | 6 +++ src/dawn_native/vulkan/TextureVk.cpp | 2 +- src/tests/end2end/BindGroupTests.cpp | 1 - src/tests/end2end/ClipSpaceTests.cpp | 1 - src/tests/end2end/ColorStateTests.cpp | 1 - .../end2end/CompressedTextureFormatTests.cpp | 2 +- src/tests/end2end/CopyTests.cpp | 10 ++-- src/tests/end2end/CullingTests.cpp | 1 - .../end2end/D3D12ResourceWrappingTests.cpp | 7 ++- src/tests/end2end/DeprecatedAPITests.cpp | 50 +++++++++++++++++++ src/tests/end2end/DepthStencilStateTests.cpp | 2 - src/tests/end2end/DeviceLostTests.cpp | 1 - src/tests/end2end/IOSurfaceWrappingTests.cpp | 10 ++-- .../end2end/MultisampledRenderingTests.cpp | 3 +- .../end2end/NonzeroTextureCreationTests.cpp | 28 ++++------- src/tests/end2end/RenderPassLoadOpTests.cpp | 1 - src/tests/end2end/RenderPassTests.cpp | 1 - src/tests/end2end/SamplerTests.cpp | 1 - src/tests/end2end/StorageTextureTests.cpp | 3 +- .../SubresourceOutputAttachmentTests.cpp | 3 +- src/tests/end2end/TextureSubresourceTests.cpp | 3 +- src/tests/end2end/TextureViewTests.cpp | 3 +- src/tests/end2end/TextureZeroInitTests.cpp | 3 +- src/tests/end2end/ViewportTests.cpp | 1 - .../validation/BindGroupValidationTests.cpp | 3 +- .../CopyCommandsValidationTests.cpp | 7 ++- .../RenderPassDescriptorValidationTests.cpp | 3 +- .../RenderPipelineValidationTests.cpp | 1 - .../validation/ResourceUsageTrackingTests.cpp | 1 - .../StorageTextureValidationTests.cpp | 3 +- .../validation/TextureSubresourceTests.cpp | 3 +- .../validation/TextureValidationTests.cpp | 15 +++--- .../validation/TextureViewValidationTests.cpp | 3 +- .../unittests/validation/ValidationTest.cpp | 1 - .../VulkanImageWrappingTestsDmaBuf.cpp | 8 ++- .../VulkanImageWrappingTestsOpaqueFD.cpp | 7 ++- src/utils/WGPUHelpers.cpp | 1 - 47 files changed, 171 insertions(+), 113 deletions(-) diff --git a/examples/CppHelloTriangle.cpp b/examples/CppHelloTriangle.cpp index bc89a47cb2..44a26ca55f 100644 --- a/examples/CppHelloTriangle.cpp +++ b/examples/CppHelloTriangle.cpp @@ -56,7 +56,6 @@ void initTextures() { descriptor.size.width = 1024; descriptor.size.height = 1024; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/examples/SampleUtils.cpp b/examples/SampleUtils.cpp index 0e38786344..17b7c9e7c5 100644 --- a/examples/SampleUtils.cpp +++ b/examples/SampleUtils.cpp @@ -189,7 +189,6 @@ wgpu::TextureView CreateDefaultDepthStencilView(const wgpu::Device& device) { descriptor.size.width = 640; descriptor.size.height = 480; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8; descriptor.mipLevelCount = 1; diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index 211c321793..697b741324 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -1001,6 +1001,13 @@ namespace dawn_native { ResultOrError> DeviceBase::CreateTextureInternal( const TextureDescriptor* descriptor) { DAWN_TRY(ValidateIsAlive()); + + // TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to + // GPUTextureDescriptor.size.depth is done. + TextureDescriptor fixedDescriptor; + DAWN_TRY_ASSIGN(fixedDescriptor, FixTextureDescriptor(this, descriptor)); + descriptor = &fixedDescriptor; + if (IsValidationEnabled()) { DAWN_TRY(ValidateTextureDescriptor(this, descriptor)); } diff --git a/src/dawn_native/SwapChain.cpp b/src/dawn_native/SwapChain.cpp index d90c975874..3650fc0178 100644 --- a/src/dawn_native/SwapChain.cpp +++ b/src/dawn_native/SwapChain.cpp @@ -102,7 +102,6 @@ namespace dawn_native { desc.usage = swapChain->GetUsage(); desc.dimension = wgpu::TextureDimension::e2D; desc.size = {swapChain->GetWidth(), swapChain->GetHeight(), 1}; - desc.arrayLayerCount = 1; desc.format = swapChain->GetFormat(); desc.mipLevelCount = 1; desc.sampleCount = 1; @@ -181,7 +180,6 @@ namespace dawn_native { descriptor.size.width = mWidth; descriptor.size.height = mHeight; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = mFormat; descriptor.mipLevelCount = 1; diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index 3a39ffaf3a..d58fb322b1 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -101,8 +101,9 @@ namespace dawn_native { // Multisampled 2D array texture is not supported because on Metal it requires the // version of macOS be greater than 10.14. - if (descriptor->arrayLayerCount > 1) { - return DAWN_VALIDATION_ERROR("Multisampled 2D array texture is not supported."); + if (descriptor->size.depth > 1) { + return DAWN_VALIDATION_ERROR( + "Multisampled textures with depth > 1 are not supported."); } if (format->isCompressed) { @@ -163,7 +164,8 @@ namespace dawn_native { "The size of the texture is incompatible with the texture format"); } - if (descriptor->arrayLayerCount > kMaxTexture2DArrayLayers) { + if (descriptor->dimension == wgpu::TextureDimension::e2D && + descriptor->size.depth > kMaxTexture2DArrayLayers) { return DAWN_VALIDATION_ERROR("Texture 2D array layer count exceeded"); } if (descriptor->mipLevelCount > kMaxTexture2DMipLevels) { @@ -218,8 +220,7 @@ namespace dawn_native { // TODO(jiawei.shao@intel.com): check stuff based on the dimension if (descriptor->size.width == 0 || descriptor->size.height == 0 || - descriptor->size.depth == 0 || descriptor->arrayLayerCount == 0 || - descriptor->mipLevelCount == 0) { + descriptor->size.depth == 0 || descriptor->mipLevelCount == 0) { return DAWN_VALIDATION_ERROR("Cannot create an empty texture"); } @@ -326,6 +327,25 @@ namespace dawn_native { return desc; } + ResultOrError FixTextureDescriptor(DeviceBase* device, + const TextureDescriptor* desc) { + TextureDescriptor fixedDesc = *desc; + + if (desc->arrayLayerCount != 1) { + if (desc->size.depth != 1) { + return DAWN_VALIDATION_ERROR("arrayLayerCount and size.depth cannot both be != 1"); + } else { + fixedDesc.size.depth = fixedDesc.arrayLayerCount; + fixedDesc.arrayLayerCount = 1; + device->EmitDeprecationWarning( + "wgpu::TextureDescriptor::arrayLayerCount is deprecated in favor of " + "::size::depth"); + } + } + + return {std::move(fixedDesc)}; + } + bool IsValidSampleCount(uint32_t sampleCount) { switch (sampleCount) { case 1: @@ -352,11 +372,17 @@ namespace dawn_native { mDimension(descriptor->dimension), mFormat(device->GetValidInternalFormat(descriptor->format)), mSize(descriptor->size), - mArrayLayerCount(descriptor->arrayLayerCount), + mArrayLayerCount(descriptor->size.depth), mMipLevelCount(descriptor->mipLevelCount), mSampleCount(descriptor->sampleCount), mUsage(descriptor->usage), mState(state) { + // TODO(cwallez@chromium.org): Store the array layers in size.depth instead if extracting it + // in mArrayLayerCount. + ASSERT(mDimension == wgpu::TextureDimension::e2D); + mArrayLayerCount = mSize.depth; + mSize.depth = 1; + uint32_t subresourceCount = GetSubresourceCount(); mIsSubresourceContentInitializedAtIndex = std::vector(subresourceCount, false); diff --git a/src/dawn_native/Texture.h b/src/dawn_native/Texture.h index 964a1ac29c..3beafb641e 100644 --- a/src/dawn_native/Texture.h +++ b/src/dawn_native/Texture.h @@ -32,6 +32,11 @@ namespace dawn_native { const TextureBase* texture, const TextureViewDescriptor* descriptor); + // TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to + // GPUTextureDescriptor.size.depth is done. + ResultOrError FixTextureDescriptor(DeviceBase* device, + const TextureDescriptor* desc); + bool IsValidSampleCount(uint32_t sampleCount); static constexpr wgpu::TextureUsage kReadOnlyTextureUsages = diff --git a/src/dawn_native/d3d12/TextureD3D12.cpp b/src/dawn_native/d3d12/TextureD3D12.cpp index 0c3f6ee147..d44014b123 100644 --- a/src/dawn_native/d3d12/TextureD3D12.cpp +++ b/src/dawn_native/d3d12/TextureD3D12.cpp @@ -336,8 +336,8 @@ namespace dawn_native { namespace d3d12 { return DAWN_VALIDATION_ERROR("Mip level count must be 1"); } - if (descriptor->arrayLayerCount != 1) { - return DAWN_VALIDATION_ERROR("Array layer count must be 1"); + if (descriptor->size.depth != 1) { + return DAWN_VALIDATION_ERROR("Depth must be 1"); } if (descriptor->sampleCount != 1) { @@ -393,6 +393,12 @@ namespace dawn_native { namespace d3d12 { const TextureDescriptor* textureDescriptor = reinterpret_cast(descriptor->cTextureDescriptor); + // TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to + // GPUTextureDescriptor.size.depth is done. + TextureDescriptor fixedDescriptor; + DAWN_TRY_ASSIGN(fixedDescriptor, FixTextureDescriptor(device, textureDescriptor)); + textureDescriptor = &fixedDescriptor; + Ref dawnTexture = AcquireRef(new Texture(device, textureDescriptor, TextureState::OwnedExternal)); DAWN_TRY(dawnTexture->InitializeAsExternalTexture(textureDescriptor, sharedHandle, diff --git a/src/dawn_native/metal/DeviceMTL.mm b/src/dawn_native/metal/DeviceMTL.mm index d53e2e10cb..d8d0feb6a1 100644 --- a/src/dawn_native/metal/DeviceMTL.mm +++ b/src/dawn_native/metal/DeviceMTL.mm @@ -269,6 +269,15 @@ namespace dawn_native { namespace metal { uint32_t plane) { const TextureDescriptor* textureDescriptor = reinterpret_cast(descriptor->cTextureDescriptor); + + // TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to + // GPUTextureDescriptor.size.depth is done. + TextureDescriptor fixedDescriptor; + if (ConsumedError(FixTextureDescriptor(this, textureDescriptor), &fixedDescriptor)) { + return nullptr; + } + textureDescriptor = &fixedDescriptor; + if (ConsumedError(ValidateTextureDescriptor(this, textureDescriptor))) { return nullptr; } diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm index 3ed3b48012..88184ee277 100644 --- a/src/dawn_native/metal/TextureMTL.mm +++ b/src/dawn_native/metal/TextureMTL.mm @@ -275,7 +275,7 @@ namespace dawn_native { namespace metal { return DAWN_VALIDATION_ERROR("IOSurface mip level count must be 1"); } - if (descriptor->arrayLayerCount != 1) { + if (descriptor->size.depth != 1) { return DAWN_VALIDATION_ERROR("IOSurface array layer count must be 1"); } @@ -301,17 +301,18 @@ namespace dawn_native { namespace metal { MTLTextureDescriptor* CreateMetalTextureDescriptor(const TextureDescriptor* descriptor) { MTLTextureDescriptor* mtlDesc = [MTLTextureDescriptor new]; - mtlDesc.textureType = MetalTextureType(descriptor->dimension, descriptor->arrayLayerCount, + mtlDesc.textureType = MetalTextureType(descriptor->dimension, descriptor->size.depth, descriptor->sampleCount); mtlDesc.usage = MetalTextureUsage(descriptor->usage); mtlDesc.pixelFormat = MetalPixelFormat(descriptor->format); mtlDesc.width = descriptor->size.width; mtlDesc.height = descriptor->size.height; - mtlDesc.depth = descriptor->size.depth; + ASSERT(descriptor->dimension == wgpu::TextureDimension::e2D); + mtlDesc.depth = 1; mtlDesc.mipmapLevelCount = descriptor->mipLevelCount; - mtlDesc.arrayLength = descriptor->arrayLayerCount; + mtlDesc.arrayLength = descriptor->size.depth; mtlDesc.storageMode = MTLStorageModePrivate; mtlDesc.sampleCount = descriptor->sampleCount; diff --git a/src/dawn_native/opengl/TextureGL.cpp b/src/dawn_native/opengl/TextureGL.cpp index 7a181306ba..1236d47cc4 100644 --- a/src/dawn_native/opengl/TextureGL.cpp +++ b/src/dawn_native/opengl/TextureGL.cpp @@ -28,7 +28,7 @@ namespace dawn_native { namespace opengl { GLenum TargetForTexture(const TextureDescriptor* descriptor) { switch (descriptor->dimension) { case wgpu::TextureDimension::e2D: - if (descriptor->arrayLayerCount > 1) { + if (descriptor->size.depth > 1) { ASSERT(descriptor->sampleCount == 1); return GL_TEXTURE_2D_ARRAY; } else { diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index bb16f84ed6..db9ecb6519 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -558,6 +558,12 @@ namespace dawn_native { namespace vulkan { const TextureDescriptor* textureDescriptor = reinterpret_cast(descriptor->cTextureDescriptor); + // TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to + // GPUTextureDescriptor.size.depth is done. + TextureDescriptor fixedDescriptor; + DAWN_TRY_ASSIGN(fixedDescriptor, FixTextureDescriptor(this, textureDescriptor)); + textureDescriptor = &fixedDescriptor; + // Check services support this combination of handle type / image info if (!mExternalSemaphoreService->Supported()) { return DAWN_VALIDATION_ERROR("External semaphore usage not supported"); diff --git a/src/dawn_native/vulkan/TextureVk.cpp b/src/dawn_native/vulkan/TextureVk.cpp index 6698ac0ec7..3894d5aab9 100644 --- a/src/dawn_native/vulkan/TextureVk.cpp +++ b/src/dawn_native/vulkan/TextureVk.cpp @@ -430,7 +430,7 @@ namespace dawn_native { namespace vulkan { return DAWN_VALIDATION_ERROR("Mip level count must be 1"); } - if (descriptor->arrayLayerCount != 1) { + if (descriptor->size.depth != 1) { return DAWN_VALIDATION_ERROR("Array layer count must be 1"); } diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp index 99d5c0c77e..0f48c8d4e3 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -279,7 +279,6 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) { descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/ClipSpaceTests.cpp b/src/tests/end2end/ClipSpaceTests.cpp index 80ed9efe06..be97ced650 100644 --- a/src/tests/end2end/ClipSpaceTests.cpp +++ b/src/tests/end2end/ClipSpaceTests.cpp @@ -60,7 +60,6 @@ class ClipSpaceTest : public DawnTest { textureDescriptor.format = format; textureDescriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc; - textureDescriptor.arrayLayerCount = 1; textureDescriptor.mipLevelCount = 1; textureDescriptor.sampleCount = 1; textureDescriptor.size = {kSize, kSize, 1}; diff --git a/src/tests/end2end/ColorStateTests.cpp b/src/tests/end2end/ColorStateTests.cpp index 769ccd858f..f0fa1e5e3b 100644 --- a/src/tests/end2end/ColorStateTests.cpp +++ b/src/tests/end2end/ColorStateTests.cpp @@ -748,7 +748,6 @@ TEST_P(ColorStateTest, IndependentColorState) { descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/CompressedTextureFormatTests.cpp b/src/tests/end2end/CompressedTextureFormatTests.cpp index 0845ad8ad3..857ecd20d6 100644 --- a/src/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/tests/end2end/CompressedTextureFormatTests.cpp @@ -481,7 +481,7 @@ TEST_P(CompressedTextureBCFormatTest, CopyIntoNonZeroArrayLayer) { config.copyExtent3D = config.textureDescriptor.size; constexpr uint32_t kArrayLayerCount = 3; - config.textureDescriptor.arrayLayerCount = kArrayLayerCount; + config.textureDescriptor.size.depth = kArrayLayerCount; config.viewArrayLayer = kArrayLayerCount - 1; for (wgpu::TextureFormat format : kBCFormats) { diff --git a/src/tests/end2end/CopyTests.cpp b/src/tests/end2end/CopyTests.cpp index 498157d4d9..95a8aac9aa 100644 --- a/src/tests/end2end/CopyTests.cpp +++ b/src/tests/end2end/CopyTests.cpp @@ -80,8 +80,7 @@ class CopyTests_T2B : public CopyTests { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = textureSpec.width; descriptor.size.height = textureSpec.height; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = textureSpec.arraySize; + descriptor.size.depth = textureSpec.arraySize; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = textureSpec.level + 1; @@ -204,7 +203,6 @@ protected: descriptor.size.width = textureSpec.width; descriptor.size.height = textureSpec.height; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = textureSpec.level + 1; @@ -299,8 +297,7 @@ class CopyTests_T2T : public CopyTests { srcDescriptor.dimension = wgpu::TextureDimension::e2D; srcDescriptor.size.width = srcSpec.width; srcDescriptor.size.height = srcSpec.height; - srcDescriptor.size.depth = 1; - srcDescriptor.arrayLayerCount = srcSpec.arraySize; + srcDescriptor.size.depth = srcSpec.arraySize; srcDescriptor.sampleCount = 1; srcDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; srcDescriptor.mipLevelCount = srcSpec.level + 1; @@ -315,8 +312,7 @@ class CopyTests_T2T : public CopyTests { dstDescriptor.dimension = wgpu::TextureDimension::e2D; dstDescriptor.size.width = dstSpec.width; dstDescriptor.size.height = dstSpec.height; - dstDescriptor.size.depth = 1; - dstDescriptor.arrayLayerCount = dstSpec.arraySize; + dstDescriptor.size.depth = dstSpec.arraySize; dstDescriptor.sampleCount = 1; dstDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; dstDescriptor.mipLevelCount = dstSpec.level + 1; diff --git a/src/tests/end2end/CullingTests.cpp b/src/tests/end2end/CullingTests.cpp index 060c4918ce..79a2303979 100644 --- a/src/tests/end2end/CullingTests.cpp +++ b/src/tests/end2end/CullingTests.cpp @@ -64,7 +64,6 @@ class CullingTest : public DawnTest { textureDescriptor.format = format; textureDescriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc; - textureDescriptor.arrayLayerCount = 1; textureDescriptor.mipLevelCount = 1; textureDescriptor.sampleCount = 1; textureDescriptor.size = {kSize, kSize, 1}; diff --git a/src/tests/end2end/D3D12ResourceWrappingTests.cpp b/src/tests/end2end/D3D12ResourceWrappingTests.cpp index 9466f76732..2907a877fb 100644 --- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp +++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp @@ -63,7 +63,6 @@ namespace { baseDawnDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; baseDawnDescriptor.size = {kTestWidth, kTestHeight, 1}; baseDawnDescriptor.sampleCount = 1; - baseDawnDescriptor.arrayLayerCount = 1; baseDawnDescriptor.mipLevelCount = 1; baseDawnDescriptor.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::OutputAttachment | @@ -173,10 +172,10 @@ TEST_P(D3D12SharedHandleValidation, InvalidMipLevelCount) { ASSERT_EQ(texture.Get(), nullptr); } -// Test an error occurs if the descriptor array layer count isn't 1 -TEST_P(D3D12SharedHandleValidation, InvalidArrayLayerCount) { +// Test an error occurs if the descriptor depth isn't 1 +TEST_P(D3D12SharedHandleValidation, InvalidDepth) { DAWN_SKIP_TEST_IF(UsesWire()); - baseDawnDescriptor.arrayLayerCount = 2; + baseDawnDescriptor.size.depth = 2; wgpu::Texture texture; ComPtr d3d11Texture; diff --git a/src/tests/end2end/DeprecatedAPITests.cpp b/src/tests/end2end/DeprecatedAPITests.cpp index 087d1822fe..693e0c717a 100644 --- a/src/tests/end2end/DeprecatedAPITests.cpp +++ b/src/tests/end2end/DeprecatedAPITests.cpp @@ -82,6 +82,56 @@ TEST_P(DeprecationTests, SetSubDataStillWorks) { EXPECT_BUFFER_U32_EQ(data, buffer, 0); } +// Test that using TextureDescriptor::arrayLayerCount emits a warning. +TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountDeprecated) { + wgpu::TextureDescriptor desc; + desc.usage = wgpu::TextureUsage::Sampled; + desc.dimension = wgpu::TextureDimension::e2D; + desc.size = {1, 1, 1}; + desc.arrayLayerCount = 2; + desc.format = wgpu::TextureFormat::RGBA8Unorm; + desc.mipLevelCount = 1; + desc.sampleCount = 1; + + EXPECT_DEPRECATION_WARNING(device.CreateTexture(&desc)); +} + +// Test that using both TextureDescriptor::arrayLayerCount and size.depth triggers an error. +TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountAndDepthSizeIsError) { + wgpu::TextureDescriptor desc; + desc.usage = wgpu::TextureUsage::Sampled; + desc.dimension = wgpu::TextureDimension::e2D; + desc.size = {1, 1, 2}; + desc.arrayLayerCount = 2; + desc.format = wgpu::TextureFormat::RGBA8Unorm; + desc.mipLevelCount = 1; + desc.sampleCount = 1; + + ASSERT_DEVICE_ERROR(device.CreateTexture(&desc)); +} + +// Test that TextureDescriptor::arrayLayerCount does correct state tracking. +TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountStateTracking) { + wgpu::TextureDescriptor desc; + desc.usage = wgpu::TextureUsage::Sampled; + desc.dimension = wgpu::TextureDimension::e2D; + desc.size = {1, 1, 1}; + desc.arrayLayerCount = 2; + desc.format = wgpu::TextureFormat::RGBA8Unorm; + desc.mipLevelCount = 1; + desc.sampleCount = 1; + + wgpu::Texture texture; + EXPECT_DEPRECATION_WARNING(texture = device.CreateTexture(&desc)); + + wgpu::TextureViewDescriptor viewDesc; + viewDesc.dimension = wgpu::TextureViewDimension::e2DArray; + viewDesc.arrayLayerCount = 2; + texture.CreateView(&viewDesc); + viewDesc.arrayLayerCount = 3; + ASSERT_DEVICE_ERROR(texture.CreateView(&viewDesc)); +} + DAWN_INSTANTIATE_TEST(DeprecationTests, D3D12Backend(), MetalBackend(), diff --git a/src/tests/end2end/DepthStencilStateTests.cpp b/src/tests/end2end/DepthStencilStateTests.cpp index 80040ec4ef..4881437332 100644 --- a/src/tests/end2end/DepthStencilStateTests.cpp +++ b/src/tests/end2end/DepthStencilStateTests.cpp @@ -30,7 +30,6 @@ class DepthStencilStateTest : public DawnTest { renderTargetDescriptor.size.width = kRTSize; renderTargetDescriptor.size.height = kRTSize; renderTargetDescriptor.size.depth = 1; - renderTargetDescriptor.arrayLayerCount = 1; renderTargetDescriptor.sampleCount = 1; renderTargetDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; renderTargetDescriptor.mipLevelCount = 1; @@ -45,7 +44,6 @@ class DepthStencilStateTest : public DawnTest { depthDescriptor.size.width = kRTSize; depthDescriptor.size.height = kRTSize; depthDescriptor.size.depth = 1; - depthDescriptor.arrayLayerCount = 1; depthDescriptor.sampleCount = 1; depthDescriptor.format = wgpu::TextureFormat::Depth24PlusStencil8; depthDescriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/DeviceLostTests.cpp b/src/tests/end2end/DeviceLostTests.cpp index e4735333d3..fbae566264 100644 --- a/src/tests/end2end/DeviceLostTests.cpp +++ b/src/tests/end2end/DeviceLostTests.cpp @@ -229,7 +229,6 @@ TEST_P(DeviceLostTest, CreateTextureFails) { descriptor.size.width = 4; descriptor.size.height = 4; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.mipLevelCount = 1; descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.usage = wgpu::TextureUsage::OutputAttachment; diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp index 70b2b79786..af40c1b9d0 100644 --- a/src/tests/end2end/IOSurfaceWrappingTests.cpp +++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp @@ -122,7 +122,6 @@ class IOSurfaceValidationTests : public IOSurfaceTestBase { descriptor.format = wgpu::TextureFormat::BGRA8Unorm; descriptor.size = {10, 10, 1}; descriptor.sampleCount = 1; - descriptor.arrayLayerCount = 1; descriptor.mipLevelCount = 1; descriptor.usage = wgpu::TextureUsage::OutputAttachment; } @@ -180,10 +179,10 @@ TEST_P(IOSurfaceValidationTests, InvalidMipLevelCount) { ASSERT_EQ(texture.Get(), nullptr); } -// Test an error occurs if the descriptor array layer count isn't 1 -TEST_P(IOSurfaceValidationTests, InvalidArrayLayerCount) { +// Test an error occurs if the descriptor depth isn't 1 +TEST_P(IOSurfaceValidationTests, InvalidDepth) { DAWN_SKIP_TEST_IF(UsesWire()); - descriptor.arrayLayerCount = 2; + descriptor.size.depth = 2; ASSERT_DEVICE_ERROR(wgpu::Texture texture = WrapIOSurface(&descriptor, defaultIOSurface.get(), 0)); @@ -298,7 +297,6 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { textureDescriptor.format = format; textureDescriptor.size = {1, 1, 1}; textureDescriptor.sampleCount = 1; - textureDescriptor.arrayLayerCount = 1; textureDescriptor.mipLevelCount = 1; textureDescriptor.usage = wgpu::TextureUsage::Sampled; wgpu::Texture wrappingTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0); @@ -340,7 +338,6 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { textureDescriptor.format = format; textureDescriptor.size = {1, 1, 1}; textureDescriptor.sampleCount = 1; - textureDescriptor.arrayLayerCount = 1; textureDescriptor.mipLevelCount = 1; textureDescriptor.usage = wgpu::TextureUsage::OutputAttachment; wgpu::Texture ioSurfaceTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0); @@ -461,7 +458,6 @@ TEST_P(IOSurfaceUsageTests, UnclearedTextureIsCleared) { textureDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; textureDescriptor.size = {1, 1, 1}; textureDescriptor.sampleCount = 1; - textureDescriptor.arrayLayerCount = 1; textureDescriptor.mipLevelCount = 1; textureDescriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc; diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index cc3b3c3d7d..5fd35a9fc9 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -90,8 +90,7 @@ class MultisampledRenderingTest : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kWidth << (mipLevelCount - 1); descriptor.size.height = kHeight << (mipLevelCount - 1); - descriptor.size.depth = 1; - descriptor.arrayLayerCount = arrayLayerCount; + descriptor.size.depth = arrayLayerCount; descriptor.sampleCount = sampleCount; descriptor.format = format; descriptor.mipLevelCount = mipLevelCount; diff --git a/src/tests/end2end/NonzeroTextureCreationTests.cpp b/src/tests/end2end/NonzeroTextureCreationTests.cpp index 0026322e6b..cce7f5f9f3 100644 --- a/src/tests/end2end/NonzeroTextureCreationTests.cpp +++ b/src/tests/end2end/NonzeroTextureCreationTests.cpp @@ -34,7 +34,6 @@ TEST_P(NonzeroTextureCreationTests, TextureCreationClears) { descriptor.size.width = kSize; descriptor.size.height = kSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; @@ -58,7 +57,6 @@ TEST_P(NonzeroTextureCreationTests, Depth32TextureCreationDepthClears) { descriptor.size.width = kSize; descriptor.size.height = kSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.mipLevelCount = 1; descriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc; @@ -80,7 +78,6 @@ TEST_P(NonzeroTextureCreationTests, MipMapClears) { descriptor.size.width = kSize; descriptor.size.height = kSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = mipLevels; @@ -104,8 +101,7 @@ TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = arrayLayers; + descriptor.size.depth = arrayLayers; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; @@ -128,7 +124,6 @@ TEST_P(NonzeroTextureCreationTests, NonrenderableTextureFormat) { descriptor.size.width = kSize; descriptor.size.height = kSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Snorm; descriptor.mipLevelCount = 1; @@ -161,8 +156,7 @@ TEST_P(NonzeroTextureCreationTests, NonRenderableTextureClearWithMultiArrayLayer descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = 2; + descriptor.size.depth = 2; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Snorm; descriptor.mipLevelCount = 1; @@ -198,7 +192,6 @@ TEST_P(NonzeroTextureCreationTests, AllSubresourcesFilled) { baseDescriptor.sampleCount = 1; baseDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; baseDescriptor.mipLevelCount = 1; - baseDescriptor.arrayLayerCount = 1; baseDescriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc; RGBA8 filled(255, 255, 255, 255); @@ -207,10 +200,10 @@ TEST_P(NonzeroTextureCreationTests, AllSubresourcesFilled) { wgpu::TextureDescriptor descriptor = baseDescriptor; // Some textures may be cleared with render pass load/store ops. // Test above the max attachment count. - descriptor.arrayLayerCount = kMaxColorAttachments + 1; + descriptor.size.depth = kMaxColorAttachments + 1; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.arrayLayerCount; ++i) { + for (uint32_t i = 0; i < descriptor.size.depth; ++i) { EXPECT_TEXTURE_RGBA8_EQ(&filled, texture, 0, 0, 1, 1, 0, i); } } @@ -229,11 +222,11 @@ TEST_P(NonzeroTextureCreationTests, AllSubresourcesFilled) { wgpu::TextureDescriptor descriptor = baseDescriptor; // Some textures may be cleared with render pass load/store ops. // Test above the max attachment count. - descriptor.arrayLayerCount = kMaxColorAttachments + 1; + descriptor.size.depth = kMaxColorAttachments + 1; descriptor.mipLevelCount = 3; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.arrayLayerCount; ++i) { + for (uint32_t i = 0; i < descriptor.size.depth; ++i) { for (uint32_t j = 0; j < descriptor.mipLevelCount; ++j) { EXPECT_TEXTURE_RGBA8_EQ(&filled, texture, 0, 0, 1, 1, j, i); } @@ -251,7 +244,6 @@ TEST_P(NonzeroTextureCreationTests, NonRenderableAllSubresourcesFilled) { baseDescriptor.sampleCount = 1; baseDescriptor.format = wgpu::TextureFormat::RGBA8Snorm; baseDescriptor.mipLevelCount = 1; - baseDescriptor.arrayLayerCount = 1; baseDescriptor.usage = wgpu::TextureUsage::CopySrc; RGBA8 filled(1, 1, 1, 1); @@ -260,10 +252,10 @@ TEST_P(NonzeroTextureCreationTests, NonRenderableAllSubresourcesFilled) { wgpu::TextureDescriptor descriptor = baseDescriptor; // Some textures may be cleared with render pass load/store ops. // Test above the max attachment count. - descriptor.arrayLayerCount = kMaxColorAttachments + 1; + descriptor.size.depth = kMaxColorAttachments + 1; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.arrayLayerCount; ++i) { + for (uint32_t i = 0; i < descriptor.size.depth; ++i) { EXPECT_TEXTURE_RGBA8_EQ(&filled, texture, 0, 0, 1, 1, 0, i); } } @@ -282,11 +274,11 @@ TEST_P(NonzeroTextureCreationTests, NonRenderableAllSubresourcesFilled) { wgpu::TextureDescriptor descriptor = baseDescriptor; // Some textures may be cleared with render pass load/store ops. // Test above the max attachment count. - descriptor.arrayLayerCount = kMaxColorAttachments + 1; + descriptor.size.depth = kMaxColorAttachments + 1; descriptor.mipLevelCount = 3; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.arrayLayerCount; ++i) { + for (uint32_t i = 0; i < descriptor.size.depth; ++i) { for (uint32_t j = 0; j < descriptor.mipLevelCount; ++j) { EXPECT_TEXTURE_RGBA8_EQ(&filled, texture, 0, 0, 1, 1, j, i); } diff --git a/src/tests/end2end/RenderPassLoadOpTests.cpp b/src/tests/end2end/RenderPassLoadOpTests.cpp index 618f9c04df..db7b6a9ff8 100644 --- a/src/tests/end2end/RenderPassLoadOpTests.cpp +++ b/src/tests/end2end/RenderPassLoadOpTests.cpp @@ -62,7 +62,6 @@ class RenderPassLoadOpTests : public DawnTest { descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/RenderPassTests.cpp b/src/tests/end2end/RenderPassTests.cpp index c157a920aa..ead9bee23e 100644 --- a/src/tests/end2end/RenderPassTests.cpp +++ b/src/tests/end2end/RenderPassTests.cpp @@ -57,7 +57,6 @@ protected: descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = kFormat; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/SamplerTests.cpp b/src/tests/end2end/SamplerTests.cpp index 1c38a4cba9..a6385c2bb3 100644 --- a/src/tests/end2end/SamplerTests.cpp +++ b/src/tests/end2end/SamplerTests.cpp @@ -90,7 +90,6 @@ protected: descriptor.size.width = 2; descriptor.size.height = 2; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/StorageTextureTests.cpp b/src/tests/end2end/StorageTextureTests.cpp index 7b74b52290..f90f5ee4d1 100644 --- a/src/tests/end2end/StorageTextureTests.cpp +++ b/src/tests/end2end/StorageTextureTests.cpp @@ -411,10 +411,9 @@ class StorageTextureTests : public DawnTest { uint32_t height = kHeight, uint32_t arrayLayerCount = 1) { wgpu::TextureDescriptor descriptor; - descriptor.size = {width, height, 1}; + descriptor.size = {width, height, arrayLayerCount}; descriptor.format = format; descriptor.usage = usage; - descriptor.arrayLayerCount = arrayLayerCount; return device.CreateTexture(&descriptor); } diff --git a/src/tests/end2end/SubresourceOutputAttachmentTests.cpp b/src/tests/end2end/SubresourceOutputAttachmentTests.cpp index 7b402a5fa0..ff45abc954 100644 --- a/src/tests/end2end/SubresourceOutputAttachmentTests.cpp +++ b/src/tests/end2end/SubresourceOutputAttachmentTests.cpp @@ -121,8 +121,7 @@ class SubresourceOutputAttachmentTest : public DawnTest { renderTargetDesc.dimension = wgpu::TextureDimension::e2D; renderTargetDesc.size.width = kTextureSize; renderTargetDesc.size.height = kTextureSize; - renderTargetDesc.size.depth = 1; - renderTargetDesc.arrayLayerCount = kArrayLayerCount; + renderTargetDesc.size.depth = kArrayLayerCount; renderTargetDesc.sampleCount = 1; renderTargetDesc.format = format; renderTargetDesc.mipLevelCount = kMipLevelCount; diff --git a/src/tests/end2end/TextureSubresourceTests.cpp b/src/tests/end2end/TextureSubresourceTests.cpp index 29411de252..741e77af73 100644 --- a/src/tests/end2end/TextureSubresourceTests.cpp +++ b/src/tests/end2end/TextureSubresourceTests.cpp @@ -27,8 +27,7 @@ class TextureSubresourceTest : public DawnTest { wgpu::TextureUsage usage) { wgpu::TextureDescriptor texDesc; texDesc.dimension = wgpu::TextureDimension::e2D; - texDesc.size = {kSize, kSize, 1}; - texDesc.arrayLayerCount = arrayLayerCount; + texDesc.size = {kSize, kSize, arrayLayerCount}; texDesc.sampleCount = 1; texDesc.mipLevelCount = mipLevelCount; texDesc.usage = usage; diff --git a/src/tests/end2end/TextureViewTests.cpp b/src/tests/end2end/TextureViewTests.cpp index 0deb1120b4..c20d0af3ce 100644 --- a/src/tests/end2end/TextureViewTests.cpp +++ b/src/tests/end2end/TextureViewTests.cpp @@ -37,8 +37,7 @@ namespace { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = arrayLayerCount; + descriptor.size.depth = arrayLayerCount; descriptor.sampleCount = 1; descriptor.format = kDefaultFormat; descriptor.mipLevelCount = mipLevelCount; diff --git a/src/tests/end2end/TextureZeroInitTests.cpp b/src/tests/end2end/TextureZeroInitTests.cpp index 82155cf38c..4588e365b4 100644 --- a/src/tests/end2end/TextureZeroInitTests.cpp +++ b/src/tests/end2end/TextureZeroInitTests.cpp @@ -44,8 +44,7 @@ class TextureZeroInitTest : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = arrayLayerCount; + descriptor.size.depth = arrayLayerCount; descriptor.sampleCount = 1; descriptor.format = format; descriptor.mipLevelCount = mipLevelCount; diff --git a/src/tests/end2end/ViewportTests.cpp b/src/tests/end2end/ViewportTests.cpp index d001368314..56dac87db0 100644 --- a/src/tests/end2end/ViewportTests.cpp +++ b/src/tests/end2end/ViewportTests.cpp @@ -69,7 +69,6 @@ class ViewportTest : public DawnTest { textureDescriptor.format = format; textureDescriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc; - textureDescriptor.arrayLayerCount = 1; textureDescriptor.mipLevelCount = 1; textureDescriptor.sampleCount = 1; textureDescriptor.size = {kSize, kSize, 1}; diff --git a/src/tests/unittests/validation/BindGroupValidationTests.cpp b/src/tests/unittests/validation/BindGroupValidationTests.cpp index 571c8eebf2..42213cae3d 100644 --- a/src/tests/unittests/validation/BindGroupValidationTests.cpp +++ b/src/tests/unittests/validation/BindGroupValidationTests.cpp @@ -26,12 +26,11 @@ class BindGroupValidationTest : public ValidationTest { uint32_t layerCount) { wgpu::TextureDescriptor descriptor; descriptor.dimension = wgpu::TextureDimension::e2D; - descriptor.size = {16, 16, 1}; + descriptor.size = {16, 16, layerCount}; descriptor.sampleCount = 1; descriptor.mipLevelCount = 1; descriptor.usage = usage; descriptor.format = format; - descriptor.arrayLayerCount = layerCount; return device.CreateTexture(&descriptor); } diff --git a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp index a4e3bf0353..cbaee72247 100644 --- a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp +++ b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp @@ -39,8 +39,7 @@ class CopyCommandTest : public ValidationTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = arrayLayerCount; + descriptor.size.depth = arrayLayerCount; descriptor.sampleCount = sampleCount; descriptor.format = format; descriptor.mipLevelCount = mipLevelCount; @@ -548,7 +547,7 @@ TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) { ASSERT_DEVICE_ERROR(wgpu::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor)); wgpu::TextureDescriptor errorTextureDescriptor; - errorTextureDescriptor.arrayLayerCount = 0; + errorTextureDescriptor.size.depth = 0; ASSERT_DEVICE_ERROR(wgpu::Texture errorTexture = device.CreateTexture(&errorTextureDescriptor)); wgpu::BufferCopyView errorBufferCopyView = utils::CreateBufferCopyView(errorBuffer, 0, 0, 0); @@ -879,7 +878,7 @@ TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) { ASSERT_DEVICE_ERROR(wgpu::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor)); wgpu::TextureDescriptor errorTextureDescriptor; - errorTextureDescriptor.arrayLayerCount = 0; + errorTextureDescriptor.size.depth = 0; ASSERT_DEVICE_ERROR(wgpu::Texture errorTexture = device.CreateTexture(&errorTextureDescriptor)); wgpu::BufferCopyView errorBufferCopyView = utils::CreateBufferCopyView(errorBuffer, 0, 0, 0); diff --git a/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp b/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp index d25b246250..7c9b11b256 100644 --- a/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp +++ b/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp @@ -55,8 +55,7 @@ wgpu::Texture CreateTexture(wgpu::Device& device, descriptor.dimension = dimension; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = arrayLayerCount; + descriptor.size.depth = arrayLayerCount; descriptor.sampleCount = sampleCount; descriptor.format = format; descriptor.mipLevelCount = mipLevelCount; diff --git a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp index 7d20b1506c..5f1dfd5122 100644 --- a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -227,7 +227,6 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) { baseTextureDescriptor.size.width = 4; baseTextureDescriptor.size.height = 4; baseTextureDescriptor.size.depth = 1; - baseTextureDescriptor.arrayLayerCount = 1; baseTextureDescriptor.mipLevelCount = 1; baseTextureDescriptor.dimension = wgpu::TextureDimension::e2D; baseTextureDescriptor.usage = wgpu::TextureUsage::OutputAttachment; diff --git a/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp b/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp index 9fddf897a3..2590240ee9 100644 --- a/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp +++ b/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp @@ -33,7 +33,6 @@ namespace { wgpu::TextureDescriptor descriptor; descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size = {1, 1, 1}; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.mipLevelCount = 1; descriptor.usage = usage; diff --git a/src/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/tests/unittests/validation/StorageTextureValidationTests.cpp index 52f0f852b4..f3e8acaef0 100644 --- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp +++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp @@ -89,8 +89,7 @@ class StorageTextureValidationTests : public ValidationTest { uint32_t arrayLayerCount = 1) { wgpu::TextureDescriptor descriptor; descriptor.dimension = wgpu::TextureDimension::e2D; - descriptor.size = {16, 16, 1}; - descriptor.arrayLayerCount = arrayLayerCount; + descriptor.size = {16, 16, arrayLayerCount}; descriptor.sampleCount = sampleCount; descriptor.format = format; descriptor.mipLevelCount = 1; diff --git a/src/tests/unittests/validation/TextureSubresourceTests.cpp b/src/tests/unittests/validation/TextureSubresourceTests.cpp index 132544633c..cbed6393c7 100644 --- a/src/tests/unittests/validation/TextureSubresourceTests.cpp +++ b/src/tests/unittests/validation/TextureSubresourceTests.cpp @@ -28,8 +28,7 @@ namespace { wgpu::TextureUsage usage) { wgpu::TextureDescriptor texDesc; texDesc.dimension = wgpu::TextureDimension::e2D; - texDesc.size = {kSize, kSize, 1}; - texDesc.arrayLayerCount = arrayLayerCount; + texDesc.size = {kSize, kSize, arrayLayerCount}; texDesc.sampleCount = 1; texDesc.mipLevelCount = mipLevelCount; texDesc.usage = usage; diff --git a/src/tests/unittests/validation/TextureValidationTests.cpp b/src/tests/unittests/validation/TextureValidationTests.cpp index 5976832db0..c3d9612338 100644 --- a/src/tests/unittests/validation/TextureValidationTests.cpp +++ b/src/tests/unittests/validation/TextureValidationTests.cpp @@ -31,8 +31,7 @@ class TextureValidationTest : public ValidationTest { wgpu::TextureDescriptor descriptor; descriptor.size.width = kWidth; descriptor.size.height = kHeight; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = kDefaultArraySize; + descriptor.size.depth = kDefaultDepth; descriptor.mipLevelCount = kDefaultMipLevels; descriptor.sampleCount = kDefaultSampleCount; descriptor.dimension = wgpu::TextureDimension::e2D; @@ -46,7 +45,7 @@ class TextureValidationTest : public ValidationTest { private: static constexpr uint32_t kWidth = 32; static constexpr uint32_t kHeight = 32; - static constexpr uint32_t kDefaultArraySize = 1; + static constexpr uint32_t kDefaultDepth = 1; static constexpr uint32_t kDefaultMipLevels = 1; static constexpr uint32_t kDefaultSampleCount = 1; @@ -94,7 +93,7 @@ TEST_F(TextureValidationTest, SampleCount) { { wgpu::TextureDescriptor descriptor = defaultDescriptor; descriptor.sampleCount = 4; - descriptor.arrayLayerCount = 2; + descriptor.size.depth = 2; ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); } @@ -204,7 +203,7 @@ TEST_F(TextureValidationTest, ArrayLayerCount) { // Array layer count exceeding kMaxTexture2DArrayLayers is not allowed { wgpu::TextureDescriptor descriptor = defaultDescriptor; - descriptor.arrayLayerCount = kMaxTexture2DArrayLayers + 1u; + descriptor.size.depth = kMaxTexture2DArrayLayers + 1u; ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); } @@ -212,7 +211,7 @@ TEST_F(TextureValidationTest, ArrayLayerCount) { // Array layer count less than kMaxTexture2DArrayLayers is allowed; { wgpu::TextureDescriptor descriptor = defaultDescriptor; - descriptor.arrayLayerCount = kMaxTexture2DArrayLayers >> 1; + descriptor.size.depth = kMaxTexture2DArrayLayers >> 1; device.CreateTexture(&descriptor); } @@ -220,7 +219,7 @@ TEST_F(TextureValidationTest, ArrayLayerCount) { // Array layer count equal to kMaxTexture2DArrayLayers is allowed; { wgpu::TextureDescriptor descriptor = defaultDescriptor; - descriptor.arrayLayerCount = kMaxTexture2DArrayLayers; + descriptor.size.depth = kMaxTexture2DArrayLayers; device.CreateTexture(&descriptor); } @@ -487,7 +486,7 @@ TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) { for (wgpu::TextureFormat format : kBCFormats) { wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); descriptor.format = format; - descriptor.arrayLayerCount = 6; + descriptor.size.depth = 6; device.CreateTexture(&descriptor); } } diff --git a/src/tests/unittests/validation/TextureViewValidationTests.cpp b/src/tests/unittests/validation/TextureViewValidationTests.cpp index f607184339..32bf7a39a4 100644 --- a/src/tests/unittests/validation/TextureViewValidationTests.cpp +++ b/src/tests/unittests/validation/TextureViewValidationTests.cpp @@ -35,8 +35,7 @@ wgpu::Texture Create2DArrayTexture(wgpu::Device& device, descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = 1; - descriptor.arrayLayerCount = arrayLayerCount; + descriptor.size.depth = arrayLayerCount; descriptor.sampleCount = sampleCount; descriptor.format = kDefaultTextureFormat; descriptor.mipLevelCount = mipLevelCount; diff --git a/src/tests/unittests/validation/ValidationTest.cpp b/src/tests/unittests/validation/ValidationTest.cpp index 3d3aeee697..7db863d36d 100644 --- a/src/tests/unittests/validation/ValidationTest.cpp +++ b/src/tests/unittests/validation/ValidationTest.cpp @@ -105,7 +105,6 @@ ValidationTest::DummyRenderPass::DummyRenderPass(const wgpu::Device& device) descriptor.size.width = width; descriptor.size.height = height; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = attachmentFormat; descriptor.mipLevelCount = 1; diff --git a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp index 0e3324c255..3fc066065a 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp @@ -49,7 +49,6 @@ namespace dawn_native { namespace vulkan { defaultDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; defaultDescriptor.size = {1, 1, 1}; defaultDescriptor.sampleCount = 1; - defaultDescriptor.arrayLayerCount = 1; defaultDescriptor.mipLevelCount = 1; defaultDescriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst; @@ -204,9 +203,9 @@ namespace dawn_native { namespace vulkan { close(defaultFd); } - // Test an error occurs if the descriptor array layer count isn't 1 - TEST_P(VulkanImageWrappingValidationTests, InvalidArrayLayerCount) { - defaultDescriptor.arrayLayerCount = 2; + // Test an error occurs if the descriptor depth isn't 1 + TEST_P(VulkanImageWrappingValidationTests, InvalidDepth) { + defaultDescriptor.size.depth = 2; ASSERT_DEVICE_ERROR(wgpu::Texture texture = WrapVulkanImage(device, &defaultDescriptor, defaultFd, @@ -761,7 +760,6 @@ namespace dawn_native { namespace vulkan { descriptor.size.width = 640; descriptor.size.height = 480; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::BGRA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp index 3fc37cf788..b96fbcf960 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp @@ -212,7 +212,6 @@ namespace dawn_native { namespace vulkan { defaultDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; defaultDescriptor.size = {1, 1, 1}; defaultDescriptor.sampleCount = 1; - defaultDescriptor.arrayLayerCount = 1; defaultDescriptor.mipLevelCount = 1; defaultDescriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst; @@ -291,10 +290,10 @@ namespace dawn_native { namespace vulkan { EXPECT_EQ(texture.Get(), nullptr); } - // Test an error occurs if the descriptor array layer count isn't 1 - TEST_P(VulkanImageWrappingValidationTests, InvalidArrayLayerCount) { + // Test an error occurs if the descriptor depth isn't 1 + TEST_P(VulkanImageWrappingValidationTests, InvalidDepth) { DAWN_SKIP_TEST_IF(UsesWire()); - defaultDescriptor.arrayLayerCount = 2; + defaultDescriptor.size.depth = 2; ASSERT_DEVICE_ERROR(wgpu::Texture texture = WrapVulkanImage( device, &defaultDescriptor, defaultFd, defaultAllocationSize, diff --git a/src/utils/WGPUHelpers.cpp b/src/utils/WGPUHelpers.cpp index f0d1242fc9..5b703ea6d8 100644 --- a/src/utils/WGPUHelpers.cpp +++ b/src/utils/WGPUHelpers.cpp @@ -252,7 +252,6 @@ namespace utils { descriptor.size.width = width; descriptor.size.height = height; descriptor.size.depth = 1; - descriptor.arrayLayerCount = 1; descriptor.sampleCount = 1; descriptor.format = BasicRenderPass::kDefaultColorFormat; descriptor.mipLevelCount = 1;