diff --git a/dawn.json b/dawn.json index d69316d11c..b12ef8874a 100644 --- a/dawn.json +++ b/dawn.json @@ -875,8 +875,8 @@ "members": [ {"name": "width", "type": "uint32_t"}, {"name": "height", "type": "uint32_t", "default": 1}, - {"name": "depth", "type": "uint32_t", "default": 1}, - {"name": "depthOrArrayLayers", "type": "uint32_t", "default": 1} + {"name": "depthOrArrayLayers", "type": "uint32_t", "default": 1}, + {"name": "depth", "type": "uint32_t", "default": 1} ] }, "fence": { diff --git a/examples/CppHelloTriangle.cpp b/examples/CppHelloTriangle.cpp index dde6162a0e..164ebf2b46 100644 --- a/examples/CppHelloTriangle.cpp +++ b/examples/CppHelloTriangle.cpp @@ -55,7 +55,7 @@ void initTextures() { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = 1024; descriptor.size.height = 1024; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/examples/SampleUtils.cpp b/examples/SampleUtils.cpp index f344825dc7..3a0372818f 100644 --- a/examples/SampleUtils.cpp +++ b/examples/SampleUtils.cpp @@ -193,7 +193,7 @@ wgpu::TextureView CreateDefaultDepthStencilView(const wgpu::Device& device) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = 640; descriptor.size.height = 480; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8; descriptor.mipLevelCount = 1; diff --git a/src/dawn_native/CommandBuffer.cpp b/src/dawn_native/CommandBuffer.cpp index bde0c63252..9fd1a99c72 100644 --- a/src/dawn_native/CommandBuffer.cpp +++ b/src/dawn_native/CommandBuffer.cpp @@ -77,7 +77,8 @@ namespace dawn_native { const Extent3D& copySize) { switch (copy.texture->GetDimension()) { case wgpu::TextureDimension::e2D: - return {copy.aspect, {copy.origin.z, copySize.depth}, {copy.mipLevel, 1}}; + return { + copy.aspect, {copy.origin.z, copySize.depthOrArrayLayers}, {copy.mipLevel, 1}}; default: UNREACHABLE(); } @@ -181,7 +182,7 @@ namespace dawn_native { } const uint64_t overwrittenRangeSize = - copyTextureDataSizePerRow * heightInBlocks * copy->copySize.depth; + copyTextureDataSizePerRow * heightInBlocks * copy->copySize.depthOrArrayLayers; if (copy->destination.buffer->GetSize() > overwrittenRangeSize) { return false; } diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp index 9c85531fa7..00e62552a3 100644 --- a/src/dawn_native/CommandEncoder.cpp +++ b/src/dawn_native/CommandEncoder.cpp @@ -626,11 +626,14 @@ namespace dawn_native { const ImageCopyTexture* destination, const Extent3D* copySize) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { + Extent3D fixedCopySize = *copySize; + DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize)); + if (GetDevice()->IsValidationEnabled()) { DAWN_TRY(ValidateImageCopyBuffer(GetDevice(), *source)); DAWN_TRY(ValidateCanUseAs(source->buffer, wgpu::BufferUsage::CopySrc)); - DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *destination, *copySize)); + DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *destination, fixedCopySize)); DAWN_TRY(ValidateCanUseAs(destination->texture, wgpu::TextureUsage::CopyDst)); DAWN_TRY(ValidateTextureSampleCountInBufferCopyCommands(destination->texture)); @@ -639,25 +642,26 @@ namespace dawn_native { // because in the latter we divide copyExtent.width by blockWidth and // copyExtent.height by blockHeight while the divisibility conditions are // checked in validating texture copy range. - DAWN_TRY(ValidateTextureCopyRange(*destination, *copySize)); + DAWN_TRY(ValidateTextureCopyRange(*destination, fixedCopySize)); } const TexelBlockInfo& blockInfo = destination->texture->GetFormat().GetAspectInfo(destination->aspect).block; TextureDataLayout srcLayout = FixUpDeprecatedTextureDataLayoutOptions( - GetDevice(), source->layout, blockInfo, *copySize); + GetDevice(), source->layout, blockInfo, fixedCopySize); if (GetDevice()->IsValidationEnabled()) { DAWN_TRY(ValidateLinearTextureCopyOffset(srcLayout, blockInfo)); DAWN_TRY(ValidateLinearTextureData(srcLayout, source->buffer->GetSize(), blockInfo, - *copySize)); + fixedCopySize)); mTopLevelBuffers.insert(source->buffer); mTopLevelTextures.insert(destination->texture); } - ApplyDefaultTextureDataLayoutOptions(&srcLayout, blockInfo, *copySize); + ApplyDefaultTextureDataLayoutOptions(&srcLayout, blockInfo, fixedCopySize); // Skip noop copies. - if (copySize->width != 0 && copySize->height != 0 && copySize->depth != 0) { + if (fixedCopySize.width != 0 && fixedCopySize.height != 0 && + fixedCopySize.depthOrArrayLayers != 0) { // Record the copy command. CopyBufferToTextureCmd* copy = allocator->Allocate(Command::CopyBufferToTexture); @@ -670,7 +674,7 @@ namespace dawn_native { copy->destination.mipLevel = destination->mipLevel; copy->destination.aspect = ConvertAspect(destination->texture->GetFormat(), destination->aspect); - copy->copySize = *copySize; + copy->copySize = fixedCopySize; } return {}; @@ -681,8 +685,11 @@ namespace dawn_native { const ImageCopyBuffer* destination, const Extent3D* copySize) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { + Extent3D fixedCopySize = *copySize; + DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize)); + if (GetDevice()->IsValidationEnabled()) { - DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *source, *copySize)); + DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *source, fixedCopySize)); DAWN_TRY(ValidateCanUseAs(source->texture, wgpu::TextureUsage::CopySrc)); DAWN_TRY(ValidateTextureSampleCountInBufferCopyCommands(source->texture)); DAWN_TRY(ValidateTextureDepthStencilToBufferCopyRestrictions(*source)); @@ -694,25 +701,26 @@ namespace dawn_native { // because in the latter we divide copyExtent.width by blockWidth and // copyExtent.height by blockHeight while the divisibility conditions are // checked in validating texture copy range. - DAWN_TRY(ValidateTextureCopyRange(*source, *copySize)); + DAWN_TRY(ValidateTextureCopyRange(*source, fixedCopySize)); } const TexelBlockInfo& blockInfo = source->texture->GetFormat().GetAspectInfo(source->aspect).block; TextureDataLayout dstLayout = FixUpDeprecatedTextureDataLayoutOptions( - GetDevice(), destination->layout, blockInfo, *copySize); + GetDevice(), destination->layout, blockInfo, fixedCopySize); if (GetDevice()->IsValidationEnabled()) { DAWN_TRY(ValidateLinearTextureCopyOffset(dstLayout, blockInfo)); DAWN_TRY(ValidateLinearTextureData(dstLayout, destination->buffer->GetSize(), - blockInfo, *copySize)); + blockInfo, fixedCopySize)); mTopLevelTextures.insert(source->texture); mTopLevelBuffers.insert(destination->buffer); } - ApplyDefaultTextureDataLayoutOptions(&dstLayout, blockInfo, *copySize); + ApplyDefaultTextureDataLayoutOptions(&dstLayout, blockInfo, fixedCopySize); // Skip noop copies. - if (copySize->width != 0 && copySize->height != 0 && copySize->depth != 0) { + if (fixedCopySize.width != 0 && fixedCopySize.height != 0 && + fixedCopySize.depthOrArrayLayers != 0) { // Record the copy command. CopyTextureToBufferCmd* copy = allocator->Allocate(Command::CopyTextureToBuffer); @@ -724,7 +732,7 @@ namespace dawn_native { copy->destination.offset = dstLayout.offset; copy->destination.bytesPerRow = dstLayout.bytesPerRow; copy->destination.rowsPerImage = dstLayout.rowsPerImage; - copy->copySize = *copySize; + copy->copySize = fixedCopySize; } return {}; @@ -735,18 +743,20 @@ namespace dawn_native { const ImageCopyTexture* destination, const Extent3D* copySize) { mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { + Extent3D fixedCopySize = *copySize; + DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize)); if (GetDevice()->IsValidationEnabled()) { DAWN_TRY(GetDevice()->ValidateObject(source->texture)); DAWN_TRY(GetDevice()->ValidateObject(destination->texture)); - DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *source, *copySize)); - DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *destination, *copySize)); + DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *source, fixedCopySize)); + DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *destination, fixedCopySize)); DAWN_TRY( - ValidateTextureToTextureCopyRestrictions(*source, *destination, *copySize)); + ValidateTextureToTextureCopyRestrictions(*source, *destination, fixedCopySize)); - DAWN_TRY(ValidateTextureCopyRange(*source, *copySize)); - DAWN_TRY(ValidateTextureCopyRange(*destination, *copySize)); + DAWN_TRY(ValidateTextureCopyRange(*source, fixedCopySize)); + DAWN_TRY(ValidateTextureCopyRange(*destination, fixedCopySize)); DAWN_TRY(ValidateCanUseAs(source->texture, wgpu::TextureUsage::CopySrc)); DAWN_TRY(ValidateCanUseAs(destination->texture, wgpu::TextureUsage::CopyDst)); @@ -756,7 +766,8 @@ namespace dawn_native { } // Skip noop copies. - if (copySize->width != 0 && copySize->height != 0 && copySize->depth != 0) { + if (fixedCopySize.width != 0 && fixedCopySize.height != 0 && + fixedCopySize.depthOrArrayLayers != 0) { CopyTextureToTextureCmd* copy = allocator->Allocate(Command::CopyTextureToTexture); copy->source.texture = source->texture; @@ -768,7 +779,7 @@ namespace dawn_native { copy->destination.mipLevel = destination->mipLevel; copy->destination.aspect = ConvertAspect(destination->texture->GetFormat(), destination->aspect); - copy->copySize = *copySize; + copy->copySize = fixedCopySize; } return {}; diff --git a/src/dawn_native/CommandValidation.cpp b/src/dawn_native/CommandValidation.cpp index e8e2b2e961..e4ad9e236b 100644 --- a/src/dawn_native/CommandValidation.cpp +++ b/src/dawn_native/CommandValidation.cpp @@ -103,7 +103,7 @@ namespace dawn_native { uint32_t heightInBlocks = copySize.height / blockInfo.height; uint64_t bytesInLastRow = Safe32x32(widthInBlocks, blockInfo.byteSize); - if (copySize.depth == 0) { + if (copySize.depthOrArrayLayers == 0) { return 0; } @@ -122,14 +122,14 @@ namespace dawn_native { // // This means that if the computation of depth * bytesPerImage doesn't overflow, none of the // computations for requiredBytesInCopy will. (and it's not a very pessimizing check) - ASSERT(copySize.depth <= 1 || (bytesPerRow != wgpu::kCopyStrideUndefined && - rowsPerImage != wgpu::kCopyStrideUndefined)); + ASSERT(copySize.depthOrArrayLayers <= 1 || (bytesPerRow != wgpu::kCopyStrideUndefined && + rowsPerImage != wgpu::kCopyStrideUndefined)); uint64_t bytesPerImage = Safe32x32(bytesPerRow, rowsPerImage); - if (bytesPerImage > std::numeric_limits::max() / copySize.depth) { + if (bytesPerImage > std::numeric_limits::max() / copySize.depthOrArrayLayers) { return DAWN_VALIDATION_ERROR("requiredBytesInCopy is too large."); } - uint64_t requiredBytesInCopy = bytesPerImage * (copySize.depth - 1); + uint64_t requiredBytesInCopy = bytesPerImage * (copySize.depthOrArrayLayers - 1); if (heightInBlocks > 0) { ASSERT(heightInBlocks <= 1 || bytesPerRow != wgpu::kCopyStrideUndefined); uint64_t bytesInLastImage = Safe32x32(bytesPerRow, heightInBlocks - 1) + bytesInLastRow; @@ -159,14 +159,14 @@ namespace dawn_native { TextureDataLayout layout = originalLayout; if (copyExtent.height != 0 && layout.rowsPerImage == 0) { - if (copyExtent.depth > 1) { + if (copyExtent.depthOrArrayLayers > 1) { device->EmitDeprecationWarning( "rowsPerImage soon must be non-zero if copy depth > 1 (it will no longer " "default to the copy height)."); ASSERT(copyExtent.height % blockInfo.height == 0); uint32_t heightInBlocks = copyExtent.height / blockInfo.height; layout.rowsPerImage = heightInBlocks; - } else if (copyExtent.depth == 1) { + } else if (copyExtent.depthOrArrayLayers == 1) { device->EmitDeprecationWarning( "rowsPerImage soon must be non-zero or unspecified if copy depth == 1 (it will " "no longer default to the copy height)."); @@ -179,7 +179,7 @@ namespace dawn_native { ASSERT(copyExtent.width % blockInfo.width == 0); uint32_t widthInBlocks = copyExtent.width / blockInfo.width; uint32_t bytesInLastRow = widthInBlocks * blockInfo.byteSize; - if (copyExtent.height == 1 && copyExtent.depth == 1 && + if (copyExtent.height == 1 && copyExtent.depthOrArrayLayers == 1 && bytesInLastRow > layout.bytesPerRow) { device->EmitDeprecationWarning( "Soon, even if copy height == 1, bytesPerRow must be >= the byte size of each row " @@ -203,11 +203,11 @@ namespace dawn_native { uint32_t widthInBlocks = copyExtent.width / blockInfo.width; uint32_t bytesInLastRow = widthInBlocks * blockInfo.byteSize; - ASSERT(heightInBlocks <= 1 && copyExtent.depth <= 1); + ASSERT(heightInBlocks <= 1 && copyExtent.depthOrArrayLayers <= 1); layout->bytesPerRow = Align(bytesInLastRow, kTextureBytesPerRowAlignment); } if (layout->rowsPerImage == wgpu::kCopyStrideUndefined) { - ASSERT(copyExtent.depth <= 1); + ASSERT(copyExtent.depthOrArrayLayers <= 1); layout->rowsPerImage = heightInBlocks; } } @@ -219,8 +219,9 @@ namespace dawn_native { ASSERT(copyExtent.height % blockInfo.height == 0); uint32_t heightInBlocks = copyExtent.height / blockInfo.height; - if (copyExtent.depth > 1 && (layout.bytesPerRow == wgpu::kCopyStrideUndefined || - layout.rowsPerImage == wgpu::kCopyStrideUndefined)) { + if (copyExtent.depthOrArrayLayers > 1 && + (layout.bytesPerRow == wgpu::kCopyStrideUndefined || + layout.rowsPerImage == wgpu::kCopyStrideUndefined)) { return DAWN_VALIDATION_ERROR( "If copy depth > 1, bytesPerRow and rowsPerImage must be specified."); } @@ -316,7 +317,7 @@ namespace dawn_native { // For 2D textures, include the array layer as depth so it can be checked with other // dimensions. ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D); - mipSize.depth = texture->GetArrayLayers(); + mipSize.depthOrArrayLayers = texture->GetArrayLayers(); // All texture dimensions are in uint32_t so by doing checks in uint64_t we avoid // overflows. @@ -324,8 +325,9 @@ namespace dawn_native { static_cast(mipSize.width) || static_cast(textureCopy.origin.y) + static_cast(copySize.height) > static_cast(mipSize.height) || - static_cast(textureCopy.origin.z) + static_cast(copySize.depth) > - static_cast(mipSize.depth)) { + static_cast(textureCopy.origin.z) + + static_cast(copySize.depthOrArrayLayers) > + static_cast(mipSize.depthOrArrayLayers)) { return DAWN_VALIDATION_ERROR("Touching outside of the texture"); } @@ -422,7 +424,7 @@ namespace dawn_native { if (src.texture == dst.texture && src.mipLevel == dst.mipLevel) { ASSERT(src.texture->GetDimension() == wgpu::TextureDimension::e2D && dst.texture->GetDimension() == wgpu::TextureDimension::e2D); - if (IsRangeOverlapped(src.origin.z, dst.origin.z, copySize.depth)) { + if (IsRangeOverlapped(src.origin.z, dst.origin.z, copySize.depthOrArrayLayers)) { return DAWN_VALIDATION_ERROR( "Copy subresources cannot be overlapped when copying within the same " "texture."); diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index 6e082dd806..cf65c420d0 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -1247,10 +1247,12 @@ namespace dawn_native { ResultOrError> DeviceBase::CreateTextureInternal( const TextureDescriptor* descriptor) { DAWN_TRY(ValidateIsAlive()); + TextureDescriptor fixedDescriptor = *descriptor; + DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(this, &(fixedDescriptor.size))); if (IsValidationEnabled()) { - DAWN_TRY(ValidateTextureDescriptor(this, descriptor)); + DAWN_TRY(ValidateTextureDescriptor(this, &fixedDescriptor)); } - return CreateTextureImpl(descriptor); + return CreateTextureImpl(&fixedDescriptor); } MaybeError DeviceBase::CreateTextureViewInternal(TextureViewBase** result, diff --git a/src/dawn_native/Queue.cpp b/src/dawn_native/Queue.cpp index e3e9141475..d5fa05a2e4 100644 --- a/src/dawn_native/Queue.cpp +++ b/src/dawn_native/Queue.cpp @@ -115,9 +115,9 @@ namespace dawn_native { uint64_t imageAdditionalStride = dataLayout.bytesPerRow * (dataRowsPerImage - alignedRowsPerImage); - CopyTextureData(dstPointer, srcPointer, writeSizePixel.depth, alignedRowsPerImage, - imageAdditionalStride, alignedBytesPerRow, optimallyAlignedBytesPerRow, - dataLayout.bytesPerRow); + CopyTextureData(dstPointer, srcPointer, writeSizePixel.depthOrArrayLayers, + alignedRowsPerImage, imageAdditionalStride, alignedBytesPerRow, + optimallyAlignedBytesPerRow, dataLayout.bytesPerRow); return uploadHandle; } @@ -305,17 +305,21 @@ namespace dawn_native { size_t dataSize, const TextureDataLayout* dataLayout, const Extent3D* writeSize) { - DAWN_TRY(ValidateWriteTexture(destination, dataSize, dataLayout, writeSize)); + Extent3D fixedWriteSize = *writeSize; + DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedWriteSize)); - if (writeSize->width == 0 || writeSize->height == 0 || writeSize->depth == 0) { + DAWN_TRY(ValidateWriteTexture(destination, dataSize, dataLayout, &fixedWriteSize)); + + if (fixedWriteSize.width == 0 || fixedWriteSize.height == 0 || + fixedWriteSize.depthOrArrayLayers == 0) { return {}; } const TexelBlockInfo& blockInfo = destination->texture->GetFormat().GetAspectInfo(destination->aspect).block; TextureDataLayout layout = *dataLayout; - ApplyDefaultTextureDataLayoutOptions(&layout, blockInfo, *writeSize); - return WriteTextureImpl(*destination, data, layout, *writeSize); + ApplyDefaultTextureDataLayoutOptions(&layout, blockInfo, fixedWriteSize); + return WriteTextureImpl(*destination, data, layout, fixedWriteSize); } MaybeError QueueBase::WriteTextureImpl(const ImageCopyTexture& destination, @@ -375,12 +379,14 @@ namespace dawn_native { const ImageCopyTexture* destination, const Extent3D* copySize, const CopyTextureForBrowserOptions* options) { + Extent3D fixedCopySize = *copySize; + DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedCopySize)); if (GetDevice()->IsValidationEnabled()) { - DAWN_TRY( - ValidateCopyTextureForBrowser(GetDevice(), source, destination, copySize, options)); + DAWN_TRY(ValidateCopyTextureForBrowser(GetDevice(), source, destination, &fixedCopySize, + options)); } - return DoCopyTextureForBrowser(GetDevice(), source, destination, copySize, options); + return DoCopyTextureForBrowser(GetDevice(), source, destination, &fixedCopySize, options); } MaybeError QueueBase::ValidateSubmit(uint32_t commandCount, diff --git a/src/dawn_native/SwapChain.cpp b/src/dawn_native/SwapChain.cpp index 84f5a568ae..96ef193859 100644 --- a/src/dawn_native/SwapChain.cpp +++ b/src/dawn_native/SwapChain.cpp @@ -180,7 +180,7 @@ namespace dawn_native { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = mWidth; descriptor.size.height = mHeight; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 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 21ae34b61b..8679e952ae 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -118,7 +118,7 @@ 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->dimension != wgpu::TextureDimension::e2D || - descriptor->size.depth > 1) { + descriptor->size.depthOrArrayLayers > 1) { return DAWN_VALIDATION_ERROR("Multisampled texture must be 2D with depth=1"); } @@ -164,7 +164,7 @@ namespace dawn_native { MaybeError ValidateTextureSize(const TextureDescriptor* descriptor, const Format* format) { ASSERT(descriptor->size.width != 0 && descriptor->size.height != 0 && - descriptor->size.depth != 0); + descriptor->size.depthOrArrayLayers != 0); Extent3D maxExtent; switch (descriptor->dimension) { @@ -182,7 +182,7 @@ namespace dawn_native { } if (descriptor->size.width > maxExtent.width || descriptor->size.height > maxExtent.height || - descriptor->size.depth > maxExtent.depth) { + descriptor->size.depthOrArrayLayers > maxExtent.depthOrArrayLayers) { return DAWN_VALIDATION_ERROR("Texture dimension (width, height or depth) exceeded"); } @@ -191,7 +191,8 @@ namespace dawn_native { maxMippedDimension = std::max(maxMippedDimension, descriptor->size.height); } if (descriptor->dimension == wgpu::TextureDimension::e3D) { - maxMippedDimension = std::max(maxMippedDimension, descriptor->size.depth); + maxMippedDimension = + std::max(maxMippedDimension, descriptor->size.depthOrArrayLayers); } if (Log2(maxMippedDimension) + 1 < descriptor->mipLevelCount) { return DAWN_VALIDATION_ERROR("Texture has too many mip levels"); @@ -243,6 +244,26 @@ namespace dawn_native { } // anonymous namespace + MaybeError FixUpDeprecatedGPUExtent3DDepth(DeviceBase* device, Extent3D* extent) { + if (extent->depth != 1) { + // deprecated depth is assigned + if (extent->depthOrArrayLayers != 1) { + // both deprecated and updated API is used + return DAWN_VALIDATION_ERROR( + "Deprecated GPUExtent3D.depth and updated GPUExtent3D.depthOrArrayLengths are " + "both assigned."); + } + + extent->depthOrArrayLayers = extent->depth; + + device->EmitDeprecationWarning( + "GPUExtent3D.depth is deprecated. Please use GPUExtent3D.depthOrArrayLayers " + "instead."); + } + + return {}; + } + MaybeError ValidateTextureDescriptor(const DeviceBase* device, const TextureDescriptor* descriptor) { if (descriptor == nullptr) { @@ -264,7 +285,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->mipLevelCount == 0) { + descriptor->size.depthOrArrayLayers == 0 || descriptor->mipLevelCount == 0) { return DAWN_VALIDATION_ERROR("Cannot create an empty texture"); } @@ -399,7 +420,8 @@ namespace dawn_native { mSampleCount(descriptor->sampleCount), mUsage(descriptor->usage), mState(state) { - uint32_t subresourceCount = mMipLevelCount * mSize.depth * GetAspectCount(mFormat.aspects); + uint32_t subresourceCount = + mMipLevelCount * mSize.depthOrArrayLayers * GetAspectCount(mFormat.aspects); mIsSubresourceContentInitializedAtIndex = std::vector(subresourceCount, false); // Add readonly storage usage if the texture has a storage usage. The validation rules in @@ -446,7 +468,7 @@ namespace dawn_native { uint32_t TextureBase::GetDepth() const { ASSERT(!IsError()); ASSERT(mDimension == wgpu::TextureDimension::e3D); - return mSize.depth; + return mSize.depthOrArrayLayers; } uint32_t TextureBase::GetArrayLayers() const { ASSERT(!IsError()); @@ -455,7 +477,7 @@ namespace dawn_native { if (mDimension == wgpu::TextureDimension::e3D) { return 1; } - return mSize.depth; + return mSize.depthOrArrayLayers; } uint32_t TextureBase::GetNumMipLevels() const { ASSERT(!IsError()); @@ -554,7 +576,7 @@ namespace dawn_native { return extent; } - extent.depth = std::max(mSize.depth >> level, 1u); + extent.depthOrArrayLayers = std::max(mSize.depthOrArrayLayers >> level, 1u); return extent; } @@ -584,7 +606,7 @@ namespace dawn_native { uint32_t clampedCopyExtentHeight = (origin.y + extent.height > virtualSizeAtLevel.height) ? (virtualSizeAtLevel.height - origin.y) : extent.height; - return {clampedCopyExtentWidth, clampedCopyExtentHeight, extent.depth}; + return {clampedCopyExtentWidth, clampedCopyExtentHeight, extent.depthOrArrayLayers}; } TextureViewBase* TextureBase::CreateView(const TextureViewDescriptor* descriptor) { diff --git a/src/dawn_native/Texture.h b/src/dawn_native/Texture.h index 52cfa06c5a..108e11b9e6 100644 --- a/src/dawn_native/Texture.h +++ b/src/dawn_native/Texture.h @@ -38,6 +38,8 @@ namespace dawn_native { bool IsValidSampleCount(uint32_t sampleCount); + MaybeError FixUpDeprecatedGPUExtent3DDepth(DeviceBase* device, Extent3D* extent); + static constexpr wgpu::TextureUsage kReadOnlyTextureUsages = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::Sampled | kReadOnlyStorageTexture; diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index 0d8d83aaa5..020d0c6a24 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -81,8 +81,8 @@ namespace dawn_native { namespace d3d12 { copySize.width == srcSize.width && // copySize.height == dstSize.height && // copySize.height == srcSize.height && // - copySize.depth == dstSize.depth && // - copySize.depth == srcSize.depth; + copySize.depthOrArrayLayers == dstSize.depthOrArrayLayers && // + copySize.depthOrArrayLayers == srcSize.depthOrArrayLayers; } void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList, @@ -143,7 +143,7 @@ namespace dawn_native { namespace d3d12 { // that uses copySplits.copies2D[1]. std::array bufferOffsetsForNextSlice = {{0u, 0u}}; - for (uint32_t copySlice = 0; copySlice < copySize.depth; ++copySlice) { + for (uint32_t copySlice = 0; copySlice < copySize.depthOrArrayLayers; ++copySlice) { const uint32_t splitIndex = copySlice % copySplits.copies2D.size(); const Texture2DCopySplit& copySplitPerLayerBase = copySplits.copies2D[splitIndex]; @@ -882,7 +882,7 @@ namespace dawn_native { namespace d3d12 { // it is not allowed to copy with overlapped subresources, but we still // add the ASSERT here as a reminder for this possible misuse. ASSERT(!IsRangeOverlapped(copy->source.origin.z, copy->destination.origin.z, - copy->copySize.depth)); + copy->copySize.depthOrArrayLayers)); } source->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopySrc, srcRange); @@ -908,7 +908,8 @@ namespace dawn_native { namespace d3d12 { copy->copySize.width, copy->copySize.height, 1u}; for (Aspect aspect : IterateEnumMask(srcRange.aspects)) { - for (uint32_t slice = 0; slice < copy->copySize.depth; ++slice) { + for (uint32_t slice = 0; slice < copy->copySize.depthOrArrayLayers; + ++slice) { D3D12_TEXTURE_COPY_LOCATION srcLocation = ComputeTextureCopyLocationForTexture( source, copy->source.mipLevel, diff --git a/src/dawn_native/d3d12/D3D12Backend.cpp b/src/dawn_native/d3d12/D3D12Backend.cpp index 22d13dd9f1..39756982d7 100644 --- a/src/dawn_native/d3d12/D3D12Backend.cpp +++ b/src/dawn_native/d3d12/D3D12Backend.cpp @@ -79,7 +79,7 @@ namespace dawn_native { namespace d3d12 { TextureDescriptor textureDescriptor = {}; textureDescriptor.usage = static_cast(descriptor->usage); textureDescriptor.dimension = static_cast(mDimension); - textureDescriptor.size = {mSize.width, mSize.height, mSize.depth}; + textureDescriptor.size = {mSize.width, mSize.height, mSize.depthOrArrayLayers}; textureDescriptor.format = static_cast(mFormat); textureDescriptor.mipLevelCount = mMipLevelCount; textureDescriptor.sampleCount = mSampleCount; diff --git a/src/dawn_native/d3d12/TextureCopySplitter.cpp b/src/dawn_native/d3d12/TextureCopySplitter.cpp index e8cfae24de..d75257e2d6 100644 --- a/src/dawn_native/d3d12/TextureCopySplitter.cpp +++ b/src/dawn_native/d3d12/TextureCopySplitter.cpp @@ -131,7 +131,7 @@ namespace dawn_native { namespace d3d12 { copy.copies[0].bufferOffset = texelOffset; copy.copies[0].bufferSize.width = copySize.width + texelOffset.x; copy.copies[0].bufferSize.height = rowsPerImageInTexels + texelOffset.y; - copy.copies[0].bufferSize.depth = copySize.depth; + copy.copies[0].bufferSize.depthOrArrayLayers = copySize.depthOrArrayLayers; return copy; } @@ -178,12 +178,12 @@ namespace dawn_native { namespace d3d12 { uint32_t texelsPerRow = bytesPerRow / blockInfo.byteSize * blockInfo.width; copy.copies[0].copySize.width = texelsPerRow - texelOffset.x; copy.copies[0].copySize.height = copySize.height; - copy.copies[0].copySize.depth = copySize.depth; + copy.copies[0].copySize.depthOrArrayLayers = copySize.depthOrArrayLayers; copy.copies[0].bufferOffset = texelOffset; copy.copies[0].bufferSize.width = texelsPerRow; copy.copies[0].bufferSize.height = rowsPerImageInTexels + texelOffset.y; - copy.copies[0].bufferSize.depth = copySize.depth; + copy.copies[0].bufferSize.depthOrArrayLayers = copySize.depthOrArrayLayers; copy.copies[1].textureOffset.x = origin.x + copy.copies[0].copySize.width; copy.copies[1].textureOffset.y = origin.y; @@ -192,14 +192,14 @@ namespace dawn_native { namespace d3d12 { ASSERT(copySize.width > copy.copies[0].copySize.width); copy.copies[1].copySize.width = copySize.width - copy.copies[0].copySize.width; copy.copies[1].copySize.height = copySize.height; - copy.copies[1].copySize.depth = copySize.depth; + copy.copies[1].copySize.depthOrArrayLayers = copySize.depthOrArrayLayers; copy.copies[1].bufferOffset.x = 0; copy.copies[1].bufferOffset.y = texelOffset.y + blockInfo.height; copy.copies[1].bufferOffset.z = 0; copy.copies[1].bufferSize.width = copy.copies[1].copySize.width; copy.copies[1].bufferSize.height = rowsPerImageInTexels + texelOffset.y + blockInfo.height; - copy.copies[1].bufferSize.depth = copySize.depth; + copy.copies[1].bufferSize.depthOrArrayLayers = copySize.depthOrArrayLayers; return copy; } @@ -233,7 +233,7 @@ namespace dawn_native { namespace d3d12 { // When the copy only refers one texture 2D array layer copies.copies2D[1] will never be // used so we can safely early return here. - if (copySize.depth == 1) { + if (copySize.depthOrArrayLayers == 1) { return copies; } diff --git a/src/dawn_native/d3d12/TextureD3D12.cpp b/src/dawn_native/d3d12/TextureD3D12.cpp index 6b90c0a475..ba70e43774 100644 --- a/src/dawn_native/d3d12/TextureD3D12.cpp +++ b/src/dawn_native/d3d12/TextureD3D12.cpp @@ -344,7 +344,7 @@ namespace dawn_native { namespace d3d12 { return DAWN_VALIDATION_ERROR("Mip level count must be 1"); } - if (descriptor->size.depth != 1) { + if (descriptor->size.depthOrArrayLayers != 1) { return DAWN_VALIDATION_ERROR("Depth must be 1"); } @@ -360,7 +360,7 @@ namespace dawn_native { namespace d3d12 { const D3D12_RESOURCE_DESC d3dDescriptor = d3d12Resource->GetDesc(); if ((dawnDescriptor->size.width != d3dDescriptor.Width) || (dawnDescriptor->size.height != d3dDescriptor.Height) || - (dawnDescriptor->size.depth != 1)) { + (dawnDescriptor->size.depthOrArrayLayers != 1)) { return DAWN_VALIDATION_ERROR("D3D12 texture size doesn't match descriptor"); } @@ -485,7 +485,7 @@ namespace dawn_native { namespace d3d12 { const Extent3D& size = GetSize(); resourceDescriptor.Width = size.width; resourceDescriptor.Height = size.height; - resourceDescriptor.DepthOrArraySize = size.depth; + resourceDescriptor.DepthOrArraySize = size.depthOrArrayLayers; // This will need to be much more nuanced when WebGPU has // texture view compatibility rules. diff --git a/src/dawn_native/d3d12/UtilsD3D12.cpp b/src/dawn_native/d3d12/UtilsD3D12.cpp index 7f6d08f62f..7f3df52524 100644 --- a/src/dawn_native/d3d12/UtilsD3D12.cpp +++ b/src/dawn_native/d3d12/UtilsD3D12.cpp @@ -93,7 +93,7 @@ namespace dawn_native { namespace d3d12 { texture->GetD3D12CopyableSubresourceFormat(aspect); bufferLocation.PlacedFootprint.Footprint.Width = bufferSize.width; bufferLocation.PlacedFootprint.Footprint.Height = bufferSize.height; - bufferLocation.PlacedFootprint.Footprint.Depth = bufferSize.depth; + bufferLocation.PlacedFootprint.Footprint.Depth = bufferSize.depthOrArrayLayers; bufferLocation.PlacedFootprint.Footprint.RowPitch = rowPitch; return bufferLocation; } @@ -105,7 +105,7 @@ namespace dawn_native { namespace d3d12 { sourceRegion.front = offset.z; sourceRegion.right = offset.x + copySize.width; sourceRegion.bottom = offset.y + copySize.height; - sourceRegion.back = offset.z + copySize.depth; + sourceRegion.back = offset.z + copySize.depthOrArrayLayers; return sourceRegion; } @@ -201,7 +201,7 @@ namespace dawn_native { namespace d3d12 { std::array bufferOffsetsForNextSlice = { {0u, 0u}}; - for (uint32_t copySlice = 0; copySlice < copySize.depth; ++copySlice) { + for (uint32_t copySlice = 0; copySlice < copySize.depthOrArrayLayers; ++copySlice) { const uint32_t splitIndex = copySlice % copySplits.copies2D.size(); const Texture2DCopySplit& copySplitPerLayerBase = copySplits.copies2D[splitIndex]; diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm index 58b85fb625..a8794d7de1 100644 --- a/src/dawn_native/metal/CommandBufferMTL.mm +++ b/src/dawn_native/metal/CommandBufferMTL.mm @@ -638,7 +638,7 @@ namespace dawn_native { namespace metal { const TextureBufferCopySplit::CopyInfo& copyInfo = splitCopies.copies[i]; const uint32_t copyBaseLayer = copyInfo.textureOrigin.z; - const uint32_t copyLayerCount = copyInfo.copyExtent.depth; + const uint32_t copyLayerCount = copyInfo.copyExtent.depthOrArrayLayers; const MTLOrigin textureOrigin = MTLOriginMake(copyInfo.textureOrigin.x, copyInfo.textureOrigin.y, 0); const MTLSize copyExtent = @@ -688,7 +688,7 @@ namespace dawn_native { namespace metal { const TextureBufferCopySplit::CopyInfo& copyInfo = splitCopies.copies[i]; const uint32_t copyBaseLayer = copyInfo.textureOrigin.z; - const uint32_t copyLayerCount = copyInfo.copyExtent.depth; + const uint32_t copyLayerCount = copyInfo.copyExtent.depthOrArrayLayers; const MTLOrigin textureOrigin = MTLOriginMake(copyInfo.textureOrigin.x, copyInfo.textureOrigin.y, 0); const MTLSize copyExtent = @@ -738,7 +738,7 @@ namespace dawn_native { namespace metal { const MTLOrigin destinationOriginNoLayer = MTLOriginMake(copy->destination.origin.x, copy->destination.origin.y, 0); - for (uint32_t slice = 0; slice < copy->copySize.depth; ++slice) { + for (uint32_t slice = 0; slice < copy->copySize.depthOrArrayLayers; ++slice) { [commandContext->EnsureBlit() copyFromTexture:srcTexture->GetMTLTexture() sourceSlice:copy->source.origin.z + slice diff --git a/src/dawn_native/metal/DeviceMTL.mm b/src/dawn_native/metal/DeviceMTL.mm index e570639ce0..6dcf97d588 100644 --- a/src/dawn_native/metal/DeviceMTL.mm +++ b/src/dawn_native/metal/DeviceMTL.mm @@ -313,7 +313,7 @@ namespace dawn_native { namespace metal { const Extent3D clampedSize = texture->ClampToMipLevelVirtualSize(dst->mipLevel, dst->origin, copySizePixels); const uint32_t copyBaseLayer = dst->origin.z; - const uint32_t copyLayerCount = copySizePixels.depth; + const uint32_t copyLayerCount = copySizePixels.depthOrArrayLayers; const uint64_t bytesPerImage = dataLayout.rowsPerImage * dataLayout.bytesPerRow; MTLBlitOption blitOption = ComputeMTLBlitOption(texture->GetFormat(), dst->aspect); diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm index d10c675d30..49181747f9 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->size.depth != 1) { + if (descriptor->size.depthOrArrayLayers != 1) { return DAWN_VALIDATION_ERROR("IOSurface array layer count must be 1"); } @@ -285,7 +285,7 @@ namespace dawn_native { namespace metal { if (descriptor->size.width != IOSurfaceGetWidthOfPlane(ioSurface, plane) || descriptor->size.height != IOSurfaceGetHeightOfPlane(ioSurface, plane) || - descriptor->size.depth != 1) { + descriptor->size.depthOrArrayLayers != 1) { return DAWN_VALIDATION_ERROR("IOSurface size doesn't match descriptor"); } @@ -317,7 +317,7 @@ namespace dawn_native { namespace metal { // Choose the correct MTLTextureType and paper over differences in how the array layer count // is specified. - mtlDesc.depth = descriptor->size.depth; + mtlDesc.depth = descriptor->size.depthOrArrayLayers; mtlDesc.arrayLength = 1; switch (descriptor->dimension) { case wgpu::TextureDimension::e2D: @@ -532,8 +532,8 @@ namespace dawn_native { namespace metal { (largestMipSize.height / blockInfo.height), 512llu); - // TODO(enga): Multiply by largestMipSize.depth and do a larger 3D copy to clear a whole - // range of subresources when tracking that is improved. + // TODO(enga): Multiply by largestMipSize.depthOrArrayLayers and do a larger 3D copy to + // clear a whole range of subresources when tracking that is improved. uint64_t bufferSize = largestMipBytesPerImage * 1; if (bufferSize > std::numeric_limits::max()) { diff --git a/src/dawn_native/metal/UtilsMetal.mm b/src/dawn_native/metal/UtilsMetal.mm index 953deb9261..bc41ec5224 100644 --- a/src/dawn_native/metal/UtilsMetal.mm +++ b/src/dawn_native/metal/UtilsMetal.mm @@ -60,9 +60,9 @@ namespace dawn_native { namespace metal { // compute the correct range when checking if the buffer is big enough to contain the // data for the whole copy. Instead of looking at the position of the last texel in the // buffer, it computes the volume of the 3D box with bytesPerRow * (rowsPerImage / - // format.blockHeight) * copySize.depth. For example considering the pixel buffer below - // where in memory, each row data (D) of the texture is followed by some padding data - // (P): + // format.blockHeight) * copySize.depthOrArrayLayers. For example considering the pixel + // buffer below where in memory, each row data (D) of the texture is followed by some + // padding data (P): // |DDDDDDD|PP| // |DDDDDDD|PP| // |DDDDDDD|PP| @@ -85,7 +85,8 @@ namespace dawn_native { namespace metal { ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D); // Check whether buffer size is big enough. - bool needWorkaround = bufferSize - bufferOffset < bytesPerImage * copyExtent.depth; + bool needWorkaround = + bufferSize - bufferOffset < bytesPerImage * copyExtent.depthOrArrayLayers; if (!needWorkaround) { copy.count = 1; copy.copies[0].bufferOffset = bufferOffset; @@ -93,25 +94,25 @@ namespace dawn_native { namespace metal { copy.copies[0].bytesPerImage = bytesPerImage; copy.copies[0].textureOrigin = origin; copy.copies[0].copyExtent = {clampedCopyExtent.width, clampedCopyExtent.height, - copyExtent.depth}; + copyExtent.depthOrArrayLayers}; return copy; } uint64_t currentOffset = bufferOffset; // Doing all the copy except the last image. - if (copyExtent.depth > 1) { + if (copyExtent.depthOrArrayLayers > 1) { copy.copies[copy.count].bufferOffset = currentOffset; copy.copies[copy.count].bytesPerRow = bytesPerRow; copy.copies[copy.count].bytesPerImage = bytesPerImage; copy.copies[copy.count].textureOrigin = origin; copy.copies[copy.count].copyExtent = {clampedCopyExtent.width, clampedCopyExtent.height, - copyExtent.depth - 1}; + copyExtent.depthOrArrayLayers - 1}; ++copy.count; // Update offset to copy to the last image. - currentOffset += (copyExtent.depth - 1) * bytesPerImage; + currentOffset += (copyExtent.depthOrArrayLayers - 1) * bytesPerImage; } // Doing all the copy in last image except the last row. @@ -121,7 +122,7 @@ namespace dawn_native { namespace metal { copy.copies[copy.count].bytesPerRow = bytesPerRow; copy.copies[copy.count].bytesPerImage = bytesPerRow * (copyBlockRowCount - 1); copy.copies[copy.count].textureOrigin = {origin.x, origin.y, - origin.z + copyExtent.depth - 1}; + origin.z + copyExtent.depthOrArrayLayers - 1}; ASSERT(copyExtent.height - blockInfo.height < texture->GetMipLevelVirtualSize(mipLevel).height); @@ -146,7 +147,7 @@ namespace dawn_native { namespace metal { copy.copies[copy.count].bytesPerImage = lastRowDataSize; copy.copies[copy.count].textureOrigin = {origin.x, origin.y + copyExtent.height - blockInfo.height, - origin.z + copyExtent.depth - 1}; + origin.z + copyExtent.depthOrArrayLayers - 1}; copy.copies[copy.count].copyExtent = {clampedCopyExtent.width, lastRowCopyExtentHeight, 1}; ++copy.count; diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index e78c68bf8b..6573d12f29 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -472,7 +472,7 @@ namespace dawn_native { namespace opengl { blitMask |= GL_STENCIL_BUFFER_BIT; } // Iterate over all layers, doing a single blit for each. - for (uint32_t layer = 0; layer < copySize.depth; ++layer) { + for (uint32_t layer = 0; layer < copySize.depthOrArrayLayers; ++layer) { // Bind all required aspects for this layer. for (Aspect aspect : IterateEnumMask(src.aspect)) { GLenum glAttachment; @@ -652,7 +652,8 @@ namespace dawn_native { namespace opengl { if (texture->GetArrayLayers() > 1) { // TODO(jiawei.shao@intel.com): do a single copy when the data is // correctly packed. - for (size_t copyZ = 0; copyZ < copyExtent.depth; ++copyZ) { + for (size_t copyZ = 0; copyZ < copyExtent.depthOrArrayLayers; + ++copyZ) { uintptr_t offsetPerImage = static_cast( src.offset + copyZ * src.bytesPerRow * src.rowsPerImage); uint32_t dstOriginY = dst.origin.y; @@ -702,13 +703,15 @@ namespace dawn_native { namespace opengl { uint64_t copyDataSize = (copySize.width / blockInfo.width) * (copySize.height / blockInfo.height) * - blockInfo.byteSize * copySize.depth; + blockInfo.byteSize * + copySize.depthOrArrayLayers; if (texture->GetArrayLayers() > 1) { gl.CompressedTexSubImage3D( target, dst.mipLevel, dst.origin.x, dst.origin.y, dst.origin.z, - copyExtent.width, copyExtent.height, copyExtent.depth, - format.internalFormat, copyDataSize, + copyExtent.width, copyExtent.height, + copyExtent.depthOrArrayLayers, format.internalFormat, + copyDataSize, reinterpret_cast(static_cast(src.offset))); } else { gl.CompressedTexSubImage2D( @@ -734,8 +737,8 @@ namespace dawn_native { namespace opengl { if (texture->GetArrayLayers() > 1) { gl.TexSubImage3D(target, dst.mipLevel, dst.origin.x, dst.origin.y, dst.origin.z, copySize.width, - copySize.height, copySize.depth, format.format, - format.type, + copySize.height, copySize.depthOrArrayLayers, + format.format, format.type, reinterpret_cast( static_cast(src.offset))); } else { @@ -839,7 +842,7 @@ namespace dawn_native { namespace opengl { } const uint64_t bytesPerImage = dst.bytesPerRow * dst.rowsPerImage; - for (uint32_t layer = 0; layer < copySize.depth; ++layer) { + for (uint32_t layer = 0; layer < copySize.depthOrArrayLayers; ++layer) { gl.FramebufferTextureLayer(GL_READ_FRAMEBUFFER, glAttachment, texture->GetHandle(), src.mipLevel, src.origin.z + layer); @@ -892,7 +895,8 @@ namespace dawn_native { namespace opengl { src.mipLevel, src.origin.x, src.origin.y, src.origin.z, dstTexture->GetHandle(), dstTexture->GetGLTarget(), dst.mipLevel, dst.origin.x, dst.origin.y, dst.origin.z, - copySize.width, copySize.height, copy->copySize.depth); + copySize.width, copySize.height, + copy->copySize.depthOrArrayLayers); } else { CopyTextureToTextureWithBlit(gl, src, dst, copySize); } diff --git a/src/dawn_native/opengl/QueueGL.cpp b/src/dawn_native/opengl/QueueGL.cpp index 23eb14367e..17260b925e 100644 --- a/src/dawn_native/opengl/QueueGL.cpp +++ b/src/dawn_native/opengl/QueueGL.cpp @@ -59,7 +59,8 @@ namespace dawn_native { namespace opengl { const OpenGLFunctions& gl = ToBackend(GetDevice())->gl; Texture* texture = ToBackend(destination.texture); - SubresourceRange range(Aspect::Color, {destination.origin.z, writeSizePixel.depth}, + SubresourceRange range(Aspect::Color, + {destination.origin.z, writeSizePixel.depthOrArrayLayers}, {destination.mipLevel, 1}); if (IsCompleteSubresourceCopiedTo(texture, writeSizePixel, destination.mipLevel)) { texture->SetIsSubresourceContentInitialized(true, range); @@ -97,7 +98,7 @@ namespace dawn_native { namespace opengl { const uint8_t* slice = static_cast(data); for (uint32_t z = destination.origin.z; - z < destination.origin.z + writeSizePixel.depth; ++z) { + z < destination.origin.z + writeSizePixel.depthOrArrayLayers; ++z) { const uint8_t* d = slice; for (uint32_t y = destination.origin.y; @@ -122,8 +123,8 @@ namespace dawn_native { namespace opengl { gl.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, dataLayout.rowsPerImage * blockInfo.height); gl.TexSubImage3D(target, destination.mipLevel, destination.origin.x, destination.origin.y, destination.origin.z, writeSizePixel.width, - writeSizePixel.height, writeSizePixel.depth, format.format, - format.type, data); + writeSizePixel.height, writeSizePixel.depthOrArrayLayers, + format.format, format.type, data); gl.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); } gl.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -138,7 +139,7 @@ namespace dawn_native { namespace opengl { } } else { const uint8_t* slice = static_cast(data); - for (uint32_t z = 0; z < writeSizePixel.depth; ++z) { + for (uint32_t z = 0; z < writeSizePixel.depthOrArrayLayers; ++z) { const uint8_t* d = slice; for (uint32_t y = 0; y < writeSizePixel.height; ++y) { gl.TexSubImage3D(target, destination.mipLevel, destination.origin.x, diff --git a/src/dawn_native/opengl/TextureGL.cpp b/src/dawn_native/opengl/TextureGL.cpp index 5582d97979..c7fc9ef74b 100644 --- a/src/dawn_native/opengl/TextureGL.cpp +++ b/src/dawn_native/opengl/TextureGL.cpp @@ -29,7 +29,7 @@ namespace dawn_native { namespace opengl { GLenum TargetForTexture(const TextureDescriptor* descriptor) { switch (descriptor->dimension) { case wgpu::TextureDimension::e2D: - if (descriptor->size.depth > 1) { + if (descriptor->size.depthOrArrayLayers > 1) { ASSERT(descriptor->sampleCount == 1); return GL_TEXTURE_2D_ARRAY; } else { diff --git a/src/dawn_native/vulkan/CommandBufferVk.cpp b/src/dawn_native/vulkan/CommandBufferVk.cpp index 98bfb58dc4..62a0caf4b1 100644 --- a/src/dawn_native/vulkan/CommandBufferVk.cpp +++ b/src/dawn_native/vulkan/CommandBufferVk.cpp @@ -58,7 +58,7 @@ namespace dawn_native { namespace vulkan { Extent3D imageExtentDst = ComputeTextureCopyExtent(dstCopy, copySize); return imageExtentSrc.width == imageExtentDst.width && imageExtentSrc.height == imageExtentDst.height && - imageExtentSrc.depth == imageExtentDst.depth; + imageExtentSrc.depthOrArrayLayers == imageExtentDst.depthOrArrayLayers; } VkImageCopy ComputeImageCopyRegion(const TextureCopy& srcCopy, @@ -76,7 +76,7 @@ namespace dawn_native { namespace vulkan { region.srcSubresource.aspectMask = VulkanAspectMask(aspect); region.srcSubresource.mipLevel = srcCopy.mipLevel; region.srcSubresource.baseArrayLayer = srcCopy.origin.z; - region.srcSubresource.layerCount = copySize.depth; + region.srcSubresource.layerCount = copySize.depthOrArrayLayers; region.srcOffset.x = srcCopy.origin.x; region.srcOffset.y = srcCopy.origin.y; @@ -85,7 +85,7 @@ namespace dawn_native { namespace vulkan { region.dstSubresource.aspectMask = VulkanAspectMask(aspect); region.dstSubresource.mipLevel = dstCopy.mipLevel; region.dstSubresource.baseArrayLayer = dstCopy.origin.z; - region.dstSubresource.layerCount = copySize.depth; + region.dstSubresource.layerCount = copySize.depthOrArrayLayers; region.dstOffset.x = dstCopy.origin.x; region.dstOffset.y = dstCopy.origin.y; @@ -459,7 +459,7 @@ namespace dawn_native { namespace vulkan { // Create the temporary buffer. Note that We don't need to respect WebGPU's 256 alignment // because it isn't a hard constraint in Vulkan. uint64_t tempBufferSize = - widthInBlocks * heightInBlocks * copySize.depth * blockInfo.byteSize; + widthInBlocks * heightInBlocks * copySize.depthOrArrayLayers * blockInfo.byteSize; BufferDescriptor tempBufferDescriptor; tempBufferDescriptor.size = tempBufferSize; tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; @@ -689,8 +689,8 @@ namespace dawn_native { namespace vulkan { // subresources should all be GENERAL instead of what we set now. Currently // it is not allowed to copy with overlapped subresources, but we still // add the ASSERT here as a reminder for this possible misuse. - ASSERT( - !IsRangeOverlapped(src.origin.z, dst.origin.z, copy->copySize.depth)); + ASSERT(!IsRangeOverlapped(src.origin.z, dst.origin.z, + copy->copySize.depthOrArrayLayers)); } // TODO after Yunchao's CL diff --git a/src/dawn_native/vulkan/TextureVk.cpp b/src/dawn_native/vulkan/TextureVk.cpp index 870b59f8db..28f9499f7e 100644 --- a/src/dawn_native/vulkan/TextureVk.cpp +++ b/src/dawn_native/vulkan/TextureVk.cpp @@ -199,12 +199,12 @@ namespace dawn_native { namespace vulkan { case wgpu::TextureDimension::e2D: info->imageType = VK_IMAGE_TYPE_2D; info->extent = {size.width, size.height, 1}; - info->arrayLayers = size.depth; + info->arrayLayers = size.depthOrArrayLayers; break; case wgpu::TextureDimension::e3D: info->imageType = VK_IMAGE_TYPE_3D; - info->extent = {size.width, size.height, size.depth}; + info->extent = {size.width, size.height, size.depthOrArrayLayers}; info->arrayLayers = 1; break; @@ -456,7 +456,7 @@ namespace dawn_native { namespace vulkan { return DAWN_VALIDATION_ERROR("Mip level count must be 1"); } - if (descriptor->size.depth != 1) { + if (descriptor->size.depthOrArrayLayers != 1) { return DAWN_VALIDATION_ERROR("Array layer count must be 1"); } diff --git a/src/dawn_native/vulkan/UtilsVulkan.cpp b/src/dawn_native/vulkan/UtilsVulkan.cpp index 7e58319ae2..6167201df0 100644 --- a/src/dawn_native/vulkan/UtilsVulkan.cpp +++ b/src/dawn_native/vulkan/UtilsVulkan.cpp @@ -130,7 +130,7 @@ namespace dawn_native { namespace vulkan { region.imageOffset.z = 0; region.imageSubresource.baseArrayLayer = textureCopy.origin.z; - region.imageSubresource.layerCount = copySize.depth; + region.imageSubresource.layerCount = copySize.depthOrArrayLayers; Extent3D imageExtent = ComputeTextureCopyExtent(textureCopy, copySize); region.imageExtent.width = imageExtent.width; diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp index a518e89062..e44aeb2f98 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -298,7 +298,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/BufferZeroInitTests.cpp b/src/tests/end2end/BufferZeroInitTests.cpp index 327723e43f..67226efa16 100644 --- a/src/tests/end2end/BufferZeroInitTests.cpp +++ b/src/tests/end2end/BufferZeroInitTests.cpp @@ -96,7 +96,7 @@ class BufferZeroInitTest : public DawnTest { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - for (uint32_t arrayLayer = 0; arrayLayer < size.depth; ++arrayLayer) { + for (uint32_t arrayLayer = 0; arrayLayer < size.depthOrArrayLayers; ++arrayLayer) { wgpu::TextureViewDescriptor viewDescriptor; viewDescriptor.format = format; viewDescriptor.dimension = wgpu::TextureViewDimension::e2D; @@ -145,7 +145,7 @@ class BufferZeroInitTest : public DawnTest { const uint64_t expectedValueCount = bufferSize / sizeof(float); std::vector expectedValues(expectedValueCount, 0.f); - for (uint32_t slice = 0; slice < spec.textureSize.depth; ++slice) { + for (uint32_t slice = 0; slice < spec.textureSize.depthOrArrayLayers; ++slice) { const uint64_t baseOffsetBytesPerSlice = spec.bufferOffset + spec.bytesPerRow * spec.rowsPerImage * slice; for (uint32_t y = 0; y < spec.textureSize.height; ++y) { @@ -963,7 +963,8 @@ TEST_P(BufferZeroInitTest, Copy2DArrayTextureToBuffer) { constexpr wgpu::Extent3D kTextureSize = {64u, 4u, 3u}; // bytesPerRow == texelBlockSizeInBytes * copySize.width && rowsPerImage == copySize.height && - // bytesPerRow * (rowsPerImage * (copySize.depth - 1) + copySize.height) == buffer.size + // bytesPerRow * (rowsPerImage * (copySize.depthOrArrayLayers - 1) + copySize.height) == + // buffer.size { TestBufferZeroInitInCopyTextureToBuffer( {kTextureSize, 0u, 0u, kTextureBytesPerRowAlignment, kTextureSize.height, 0u}); @@ -976,7 +977,7 @@ TEST_P(BufferZeroInitTest, Copy2DArrayTextureToBuffer) { {kTextureSize, 0u, 0u, kTextureBytesPerRowAlignment, kRowsPerImage, 1u}); } - // bytesPerRow * rowsPerImage * copySize.depth < buffer.size + // bytesPerRow * rowsPerImage * copySize.depthOrArrayLayers < buffer.size { constexpr uint64_t kExtraBufferSize = 16u; TestBufferZeroInitInCopyTextureToBuffer({kTextureSize, 0u, kExtraBufferSize, diff --git a/src/tests/end2end/ColorStateTests.cpp b/src/tests/end2end/ColorStateTests.cpp index b9b6d6cb32..91db43a8fe 100644 --- a/src/tests/end2end/ColorStateTests.cpp +++ b/src/tests/end2end/ColorStateTests.cpp @@ -771,7 +771,7 @@ TEST_P(ColorStateTest, IndependentColorState) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 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 a95f834a32..06b8afada1 100644 --- a/src/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/tests/end2end/CompressedTextureFormatTests.cpp @@ -64,14 +64,14 @@ class CompressedTextureBCFormatTest : public DawnTest { copyRowsPerImage = copyHeightInBlock; } uint32_t copyBytesPerImage = copyBytesPerRow * copyRowsPerImage; - uint32_t uploadBufferSize = - copyConfig.bufferOffset + copyBytesPerImage * copyConfig.copyExtent3D.depth; + uint32_t uploadBufferSize = copyConfig.bufferOffset + + copyBytesPerImage * copyConfig.copyExtent3D.depthOrArrayLayers; // Fill data with the pre-prepared one-block compressed texture data. std::vector data(uploadBufferSize, 0); std::vector oneBlockCompressedTextureData = GetOneBlockBCFormatTextureData(copyConfig.textureDescriptor.format); - for (uint32_t layer = 0; layer < copyConfig.copyExtent3D.depth; ++layer) { + for (uint32_t layer = 0; layer < copyConfig.copyExtent3D.depthOrArrayLayers; ++layer) { for (uint32_t h = 0; h < copyHeightInBlock; ++h) { for (uint32_t w = 0; w < copyWidthInBlock; ++w) { uint32_t uploadBufferOffset = copyConfig.bufferOffset + @@ -227,14 +227,14 @@ class CompressedTextureBCFormatTest : public DawnTest { if (config.copyOrigin3D.y + config.copyExtent3D.height > virtualSizeAtLevel.height) { noPaddingExtent3D.height = virtualSizeAtLevel.height - config.copyOrigin3D.y; } - noPaddingExtent3D.depth = 1u; + noPaddingExtent3D.depthOrArrayLayers = 1u; std::vector expectedData = GetExpectedData(config.textureDescriptor.format, noPaddingExtent3D); wgpu::Origin3D firstLayerCopyOrigin = {config.copyOrigin3D.x, config.copyOrigin3D.y, 0}; for (uint32_t layer = config.copyOrigin3D.z; - layer < config.copyOrigin3D.z + config.copyExtent3D.depth; ++layer) { + layer < config.copyOrigin3D.z + config.copyExtent3D.depthOrArrayLayers; ++layer) { wgpu::BindGroup bindGroup = CreateBindGroupForTest( renderPipeline.GetBindGroupLayout(0), bcTexture, config.textureDescriptor.format, layer, config.viewMipmapLevel); @@ -391,7 +391,7 @@ class CompressedTextureBCFormatTest : public DawnTest { static std::vector FillExpectedData(const wgpu::Extent3D& testRegion, RGBA8 leftColorInBlock, RGBA8 rightColorInBlock) { - ASSERT(testRegion.depth == 1); + ASSERT(testRegion.depthOrArrayLayers == 1); std::vector expectedData(testRegion.width * testRegion.height, leftColorInBlock); for (uint32_t y = 0; y < testRegion.height; ++y) { @@ -409,7 +409,7 @@ class CompressedTextureBCFormatTest : public DawnTest { static wgpu::Extent3D GetVirtualSizeAtLevel(const CopyConfig& config) { return {config.textureDescriptor.size.width >> config.viewMipmapLevel, config.textureDescriptor.size.height >> config.viewMipmapLevel, - config.textureDescriptor.size.depth}; + config.textureDescriptor.size.depthOrArrayLayers}; } static wgpu::Extent3D GetPhysicalSizeAtLevel(const CopyConfig& config) { @@ -484,7 +484,7 @@ TEST_P(CompressedTextureBCFormatTest, CopyIntoNonZeroArrayLayer) { config.copyExtent3D = config.textureDescriptor.size; constexpr uint32_t kArrayLayerCount = 3; - config.textureDescriptor.size.depth = kArrayLayerCount; + config.textureDescriptor.size.depthOrArrayLayers = kArrayLayerCount; config.copyOrigin3D.z = kArrayLayerCount - 1; for (wgpu::TextureFormat format : utils::kBCFormats) { @@ -973,8 +973,8 @@ TEST_P(CompressedTextureBCFormatTest, RowPitchEqualToSlicePitch) { } // Test the workaround in the B2T copies when (bufferSize - bufferOffset < bytesPerImage * -// copyExtent.depth) on Metal backends. As copyExtent.depth can only be 1 for BC formats, on Metal -// backend we will use two copies to implement such copy. +// copyExtent.depthOrArrayLayers) on Metal backends. As copyExtent.depthOrArrayLayers can only be 1 +// for BC formats, on Metal backend we will use two copies to implement such copy. TEST_P(CompressedTextureBCFormatTest, LargeImageHeight) { // TODO(jiawei.shao@intel.com): find out why this test fails on Windows Intel OpenGL drivers. DAWN_SKIP_TEST_IF(IsIntel() && IsOpenGL() && IsWindows()); @@ -995,7 +995,7 @@ TEST_P(CompressedTextureBCFormatTest, LargeImageHeight) { } // Test the workaround in the B2T copies when (bufferSize - bufferOffset < bytesPerImage * -// copyExtent.depth) and copyExtent needs to be clamped. +// copyExtent.depthOrArrayLayers) and copyExtent needs to be clamped. TEST_P(CompressedTextureBCFormatTest, LargeImageHeightAndClampedCopyExtent) { // TODO(jiawei.shao@intel.com): find out why this test fails on Windows Intel OpenGL drivers. DAWN_SKIP_TEST_IF(IsIntel() && IsOpenGL() && IsWindows()); @@ -1055,7 +1055,7 @@ TEST_P(CompressedTextureBCFormatTest, CopyWhole2DArrayTexture) { config.rowsPerImage = 8; config.copyExtent3D = config.textureDescriptor.size; - config.copyExtent3D.depth = kArrayLayerCount; + config.copyExtent3D.depthOrArrayLayers = kArrayLayerCount; for (wgpu::TextureFormat format : utils::kBCFormats) { config.textureDescriptor.format = format; @@ -1084,7 +1084,7 @@ TEST_P(CompressedTextureBCFormatTest, CopyMultiple2DArrayLayers) { constexpr uint32_t kCopyLayerCount = 2; config.copyOrigin3D = {0, 0, kCopyBaseArrayLayer}; config.copyExtent3D = config.textureDescriptor.size; - config.copyExtent3D.depth = kCopyLayerCount; + config.copyExtent3D.depthOrArrayLayers = kCopyLayerCount; for (wgpu::TextureFormat format : utils::kBCFormats) { config.textureDescriptor.format = format; diff --git a/src/tests/end2end/CopyTests.cpp b/src/tests/end2end/CopyTests.cpp index f6d6a3dad3..0c457cb466 100644 --- a/src/tests/end2end/CopyTests.cpp +++ b/src/tests/end2end/CopyTests.cpp @@ -46,7 +46,7 @@ class CopyTests : public DawnTest { static std::vector GetExpectedTextureData(const utils::TextureDataCopyLayout& layout) { uint32_t bytesPerTexelBlock = layout.bytesPerRow / layout.texelBlocksPerRow; std::vector textureData(layout.byteLength); - for (uint32_t layer = 0; layer < layout.mipSize.depth; ++layer) { + for (uint32_t layer = 0; layer < layout.mipSize.depthOrArrayLayers; ++layer) { const uint32_t byteOffsetPerSlice = layout.bytesPerImage * layer; for (uint32_t y = 0; y < layout.mipSize.height; ++y) { for (uint32_t x = 0; x < layout.mipSize.width * bytesPerTexelBlock; ++x) { @@ -64,7 +64,7 @@ class CopyTests : public DawnTest { static std::vector GetExpectedTextureDataRGBA8( const utils::TextureDataCopyLayout& layout) { std::vector textureData(layout.texelBlockCount); - for (uint32_t layer = 0; layer < layout.mipSize.depth; ++layer) { + for (uint32_t layer = 0; layer < layout.mipSize.depthOrArrayLayers; ++layer) { const uint32_t texelIndexOffsetPerSlice = layout.texelBlocksPerImage * layer; for (uint32_t y = 0; y < layout.mipSize.height; ++y) { for (uint32_t x = 0; x < layout.mipSize.width; ++x) { @@ -185,7 +185,7 @@ class CopyTests_T2B : public CopyTests { // Texels in single slice. const uint32_t texelCountInCopyRegion = utils::GetTexelCountInCopyRegion( bufferSpec.bytesPerRow, bufferSpec.rowsPerImage, copySizePerSlice, textureSpec.format); - const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depth; + const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depthOrArrayLayers; std::vector expected(texelCountInCopyRegion); for (uint32_t slice = textureSpec.copyOrigin.z; slice < maxArrayLayer; ++slice) { // Pack the data used to create the upload buffer in the specified copy region to have @@ -207,7 +207,7 @@ class CopyTests_T2B : public CopyTests { << ", " << textureSpec.copyOrigin.y << ", " << textureSpec.copyOrigin.z << "), (" << textureSpec.copyOrigin.x + copySize.width << ", " << textureSpec.copyOrigin.y + copySize.height << ", " - << textureSpec.copyOrigin.z + copySize.depth << ")) from " + << textureSpec.copyOrigin.z + copySize.depthOrArrayLayers << ")) from " << textureSpec.textureSize.width << " x " << textureSpec.textureSize.height << " texture at mip level " << textureSpec.copyLevel << " layer " << slice << " to " << bufferSpec.size << "-byte buffer with offset " << bufferOffset @@ -258,7 +258,7 @@ class CopyTests_B2T : public CopyTests { textureSpec.format, textureSpec.textureSize, textureSpec.copyLevel, bufferSpec.rowsPerImage); - const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depth; + const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depthOrArrayLayers; wgpu::ImageCopyBuffer imageCopyBuffer = utils::CreateImageCopyBuffer( buffer, bufferSpec.offset, bufferSpec.bytesPerRow, bufferSpec.rowsPerImage); @@ -333,7 +333,9 @@ class CopyTests_T2T : public CopyTests { // `level` mip level const utils::TextureDataCopyLayout srcDataCopyLayout = utils::GetTextureDataCopyLayoutForTexture2DAtLevel( - format, {srcSpec.textureSize.width, srcSpec.textureSize.height, copySize.depth}, + format, + {srcSpec.textureSize.width, srcSpec.textureSize.height, + copySize.depthOrArrayLayers}, srcSpec.copyLevel); // Initialize the source texture @@ -358,10 +360,12 @@ class CopyTests_T2T : public CopyTests { encoder.CopyTextureToTexture(&srcImageCopyTexture, &dstImageCopyTexture, ©Size); // Copy the data from the srcSpec.copyOrigin.z-th layer to (srcSpec.copyOrigin.z + - // copySize.depth)-th layer of dstTexture to outputBuffer + // copySize.depthOrArrayLayers)-th layer of dstTexture to outputBuffer const utils::TextureDataCopyLayout dstDataCopyLayout = utils::GetTextureDataCopyLayoutForTexture2DAtLevel( - format, {dstSpec.textureSize.width, dstSpec.textureSize.height, copySize.depth}, + format, + {dstSpec.textureSize.width, dstSpec.textureSize.height, + copySize.depthOrArrayLayers}, dstSpec.copyLevel); wgpu::BufferDescriptor outputBufferDescriptor; outputBufferDescriptor.size = dstDataCopyLayout.byteLength; @@ -384,7 +388,7 @@ class CopyTests_T2T : public CopyTests { bytesPerTexel); std::vector expectedDstDataPerSlice(validDataSizePerDstTextureLayer); - for (uint32_t slice = 0; slice < copySize.depth; ++slice) { + for (uint32_t slice = 0; slice < copySize.depthOrArrayLayers; ++slice) { // For each source texture array slice involved in the copy, emulate the T2T copy // on the CPU side by "copying" the copy data from the "source texture" // (srcTextureCopyData) to the "destination texture" (expectedDstDataPerSlice). diff --git a/src/tests/end2end/CopyTextureForBrowserTests.cpp b/src/tests/end2end/CopyTextureForBrowserTests.cpp index deb3a7002e..17c3fd6b0c 100644 --- a/src/tests/end2end/CopyTextureForBrowserTests.cpp +++ b/src/tests/end2end/CopyTextureForBrowserTests.cpp @@ -36,7 +36,7 @@ class CopyTextureForBrowserTests : public DawnTest { static std::vector GetSourceTextureData(const utils::TextureDataCopyLayout& layout) { std::vector textureData(layout.texelBlockCount); - for (uint32_t layer = 0; layer < layout.mipSize.depth; ++layer) { + for (uint32_t layer = 0; layer < layout.mipSize.depthOrArrayLayers; ++layer) { const uint32_t sliceOffset = layout.texelBlocksPerImage * layer; for (uint32_t y = 0; y < layout.mipSize.height; ++y) { const uint32_t rowOffset = layout.texelBlocksPerRow * y; @@ -141,7 +141,8 @@ class CopyTextureForBrowserTests : public DawnTest { const utils::TextureDataCopyLayout copyLayout = utils::GetTextureDataCopyLayoutForTexture2DAtLevel( kTextureFormat, - {srcSpec.textureSize.width, srcSpec.textureSize.height, copySize.depth}, + {srcSpec.textureSize.width, srcSpec.textureSize.height, + copySize.depthOrArrayLayers}, srcSpec.level); const std::vector textureArrayCopyData = GetSourceTextureData(copyLayout); diff --git a/src/tests/end2end/D3D12ResourceWrappingTests.cpp b/src/tests/end2end/D3D12ResourceWrappingTests.cpp index 47f311bee9..0a703c775b 100644 --- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp +++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp @@ -191,7 +191,7 @@ TEST_P(D3D12SharedHandleValidation, InvalidMipLevelCount) { // Test an error occurs if the descriptor depth isn't 1 TEST_P(D3D12SharedHandleValidation, InvalidDepth) { DAWN_SKIP_TEST_IF(UsesWire()); - baseDawnDescriptor.size.depth = 2; + baseDawnDescriptor.size.depthOrArrayLayers = 2; wgpu::Texture texture; ComPtr d3d11Texture; diff --git a/src/tests/end2end/DeprecatedAPITests.cpp b/src/tests/end2end/DeprecatedAPITests.cpp index 9d69f896fe..e1b8491379 100644 --- a/src/tests/end2end/DeprecatedAPITests.cpp +++ b/src/tests/end2end/DeprecatedAPITests.cpp @@ -172,6 +172,291 @@ TEST_P(DeprecationTests, CreateFence) { EXPECT_DEPRECATION_WARNING(queue.CreateFence()); } +// Test GPUExtent3D.depth deprecation in TextureDescriptor.size +TEST_P(DeprecationTests, GPUExtent3DDepthDeprecationTextureDescriptor) { + wgpu::TextureDescriptor kBaseDesc; + kBaseDesc.usage = wgpu::TextureUsage::Sampled; + kBaseDesc.size.width = 1; + kBaseDesc.size.height = 1; + kBaseDesc.format = wgpu::TextureFormat::RGBA8Unorm; + kBaseDesc.dimension = wgpu::TextureDimension::e2D; + + { + // Valid: default + wgpu::TextureDescriptor desc = kBaseDesc; + wgpu::Texture texture; + texture = device.CreateTexture(&desc); + } + { + // Warning: use deprecated depth but still valid + wgpu::TextureDescriptor desc = kBaseDesc; + desc.mipLevelCount = 2; + desc.size.width = 2; + desc.size.height = 2; + desc.size.depth = 2; + wgpu::Texture texture; + EXPECT_DEPRECATION_WARNING(texture = device.CreateTexture(&desc)); + } + { + // Warning: use deprecated depth + // Error: use deprecated depth and the descriptor is invalid + // because 2D texture with depth == 0 is not allowed + // This is to verify the deprecated depth is picked up by the implementation. + wgpu::TextureDescriptor desc = kBaseDesc; + desc.size.depth = 0; + wgpu::Texture texture; + ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(texture = device.CreateTexture(&desc))); + } + { + // Error: use both deprecated depth and depthOrArrayLayers + wgpu::TextureDescriptor desc = kBaseDesc; + desc.size.depth = 2; + desc.size.depthOrArrayLayers = 2; + wgpu::Texture texture; + ASSERT_DEVICE_ERROR(texture = device.CreateTexture(&desc)); + } + { + // Valid: use updated depthOrArrayLayers + wgpu::TextureDescriptor desc = kBaseDesc; + desc.mipLevelCount = 2; + desc.size.width = 2; + desc.size.height = 2; + desc.size.depthOrArrayLayers = 2; + wgpu::Texture texture; + texture = device.CreateTexture(&desc); + } + { + // Error: use updated depthOrArrayLayers and the descriptor is invalid + // because 2D texture with depthOrArrayLayers == 0 is not allowed + wgpu::TextureDescriptor desc = kBaseDesc; + desc.size.depthOrArrayLayers = 0; + wgpu::Texture texture; + ASSERT_DEVICE_ERROR(texture = device.CreateTexture(&desc)); + } +} + +// Test GPUExtent3D.depth deprecation in CopyBufferToTexture, CopyTextureToBuffer, and +// CopyTextureToTexture +TEST_P(DeprecationTests, GPUExtent3DDepthDeprecationCopy) { + wgpu::BufferDescriptor bufferDesc; + bufferDesc.size = 4 * 256; + bufferDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; + wgpu::Buffer srcBuffer = device.CreateBuffer(&bufferDesc); + + wgpu::TextureDescriptor dstTextureDesc; + dstTextureDesc.usage = wgpu::TextureUsage::CopyDst; + dstTextureDesc.size.width = 4; + dstTextureDesc.size.height = 4; + dstTextureDesc.size.depthOrArrayLayers = 1; + dstTextureDesc.format = wgpu::TextureFormat::RGBA8Unorm; + dstTextureDesc.dimension = wgpu::TextureDimension::e2D; + wgpu::Texture dstTexture = device.CreateTexture(&dstTextureDesc); + + wgpu::TextureDescriptor srcTextureDesc = dstTextureDesc; + srcTextureDesc.usage = wgpu::TextureUsage::CopySrc; + wgpu::Texture srcTexture = device.CreateTexture(&srcTextureDesc); + + wgpu::ImageCopyBuffer imageCopyBuffer = utils::CreateImageCopyBuffer(srcBuffer, 0, 256, 4); + wgpu::ImageCopyTexture imageCopyDstTexture = + utils::CreateImageCopyTexture(dstTexture, 0, {0, 0, 0}, wgpu::TextureAspect::All); + wgpu::ImageCopyTexture imageCopySrcTexture = + utils::CreateImageCopyTexture(srcTexture, 0, {0, 0, 0}, wgpu::TextureAspect::All); + + wgpu::Extent3D kBaseExtent3D; + kBaseExtent3D.width = 4; + kBaseExtent3D.height = 4; + + { + // Valid: default + wgpu::Extent3D extent3D = kBaseExtent3D; + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyBufferToTexture(&imageCopyBuffer, &imageCopyDstTexture, &extent3D); + encoder.CopyTextureToBuffer(&imageCopySrcTexture, &imageCopyBuffer, &extent3D); + encoder.CopyTextureToTexture(&imageCopySrcTexture, &imageCopyDstTexture, &extent3D); + encoder.Finish(); + } + { + // Warning: empty copy use deprecated depth == 0 but still valid + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.width = 0; + extent3D.height = 0; + extent3D.depth = 0; + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + EXPECT_DEPRECATION_WARNING( + encoder.CopyBufferToTexture(&imageCopyBuffer, &imageCopyDstTexture, &extent3D)); + EXPECT_DEPRECATION_WARNING( + encoder.CopyTextureToBuffer(&imageCopySrcTexture, &imageCopyBuffer, &extent3D)); + EXPECT_DEPRECATION_WARNING( + encoder.CopyTextureToTexture(&imageCopySrcTexture, &imageCopyDstTexture, &extent3D)); + encoder.Finish(); + } + { + // Warning: use deprecated depth + // Error: depth > 1 + // This is to verify the deprecated depth is picked up by the implementation. + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.depth = 2; + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + EXPECT_DEPRECATION_WARNING( + encoder.CopyBufferToTexture(&imageCopyBuffer, &imageCopyDstTexture, &extent3D)); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + EXPECT_DEPRECATION_WARNING( + encoder.CopyTextureToBuffer(&imageCopySrcTexture, &imageCopyBuffer, &extent3D)); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToTexture( + &imageCopySrcTexture, &imageCopyDstTexture, &extent3D)); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + } + { + // Error: use both deprecated depth and depthOrArrayLayers + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.width = 0; + extent3D.height = 0; + extent3D.depth = 0; + extent3D.depthOrArrayLayers = 0; + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyBufferToTexture(&imageCopyBuffer, &imageCopyDstTexture, &extent3D); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyTextureToBuffer(&imageCopySrcTexture, &imageCopyBuffer, &extent3D); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyTextureToTexture(&imageCopySrcTexture, &imageCopyDstTexture, &extent3D); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + } + { + // Valid: use updated depthOrArrayLayers + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.width = 0; + extent3D.height = 0; + extent3D.depthOrArrayLayers = 0; + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyBufferToTexture(&imageCopyBuffer, &imageCopyDstTexture, &extent3D); + encoder.CopyTextureToBuffer(&imageCopySrcTexture, &imageCopyBuffer, &extent3D); + encoder.CopyTextureToTexture(&imageCopySrcTexture, &imageCopyDstTexture, &extent3D); + encoder.Finish(); + } + { + // Error: use updated depthOrArrayLayers and is invalid + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.depthOrArrayLayers = 2; + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyBufferToTexture(&imageCopyBuffer, &imageCopyDstTexture, &extent3D); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyTextureToBuffer(&imageCopySrcTexture, &imageCopyBuffer, &extent3D); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + { + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + encoder.CopyTextureToTexture(&imageCopySrcTexture, &imageCopyDstTexture, &extent3D); + ASSERT_DEVICE_ERROR(encoder.Finish()); + } + } +} + +// Test GPUExtent3D.depth deprecation in WriteTexture +TEST_P(DeprecationTests, GPUExtent3DDepthDeprecationWriteTexture) { + wgpu::TextureDescriptor dstTextureDesc; + dstTextureDesc.usage = wgpu::TextureUsage::CopyDst; + dstTextureDesc.size.width = 4; + dstTextureDesc.size.height = 4; + dstTextureDesc.size.depthOrArrayLayers = 1; + dstTextureDesc.format = wgpu::TextureFormat::RGBA8Unorm; + dstTextureDesc.dimension = wgpu::TextureDimension::e2D; + wgpu::Texture dstTexture = device.CreateTexture(&dstTextureDesc); + + size_t dataSize = 4 * 256; + std::vector data(dataSize); + + wgpu::TextureDataLayout textureDataLayout; + textureDataLayout.offset = 0; + textureDataLayout.bytesPerRow = 256; + textureDataLayout.rowsPerImage = 4; + + wgpu::ImageCopyTexture imageCopyDstTexture = + utils::CreateImageCopyTexture(dstTexture, 0, {0, 0, 0}, wgpu::TextureAspect::All); + + wgpu::Extent3D kBaseExtent3D; + kBaseExtent3D.width = 4; + kBaseExtent3D.height = 4; + + { + // Valid: default + wgpu::Extent3D extent3D = kBaseExtent3D; + wgpu::Queue queue = device.GetQueue(); + queue.WriteTexture(&imageCopyDstTexture, data.data(), dataSize, &textureDataLayout, + &extent3D); + } + { + // Warning: use deprecated depth == 0 but still valid + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.width = 0; + extent3D.height = 0; + extent3D.depth = 0; + wgpu::Queue queue = device.GetQueue(); + EXPECT_DEPRECATION_WARNING(queue.WriteTexture(&imageCopyDstTexture, data.data(), dataSize, + &textureDataLayout, &extent3D)); + } + { + // Warning: use deprecated depth + // Error: depth > 1 for 2D textures + // This is to verify the deprecated depth is picked up by the implementation. + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.depth = 2; + wgpu::Queue queue = device.GetQueue(); + ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(queue.WriteTexture( + &imageCopyDstTexture, data.data(), dataSize, &textureDataLayout, &extent3D))); + } + { + // Error: use both deprecated depth and depthOrArrayLayers + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.width = 0; + extent3D.height = 0; + extent3D.depth = 0; + extent3D.depthOrArrayLayers = 0; + wgpu::Queue queue = device.GetQueue(); + ASSERT_DEVICE_ERROR(queue.WriteTexture(&imageCopyDstTexture, data.data(), dataSize, + &textureDataLayout, &extent3D)); + } + { + // Valid: use updated depthOrArrayLayers + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.width = 0; + extent3D.height = 0; + extent3D.depthOrArrayLayers = 0; + wgpu::Queue queue = device.GetQueue(); + queue.WriteTexture(&imageCopyDstTexture, data.data(), dataSize, &textureDataLayout, + &extent3D); + } + { + // Error: use updated depthOrArrayLayers and depthOrArrayLayers > 1 for 2D textures + wgpu::Extent3D extent3D = kBaseExtent3D; + extent3D.depthOrArrayLayers = 2; + wgpu::Queue queue = device.GetQueue(); + ASSERT_DEVICE_ERROR(queue.WriteTexture(&imageCopyDstTexture, data.data(), dataSize, + &textureDataLayout, &extent3D)); + } +} + DAWN_INSTANTIATE_TEST(DeprecationTests, D3D12Backend(), MetalBackend(), diff --git a/src/tests/end2end/DepthStencilStateTests.cpp b/src/tests/end2end/DepthStencilStateTests.cpp index 3696c19680..460f77b879 100644 --- a/src/tests/end2end/DepthStencilStateTests.cpp +++ b/src/tests/end2end/DepthStencilStateTests.cpp @@ -29,7 +29,7 @@ class DepthStencilStateTest : public DawnTest { renderTargetDescriptor.dimension = wgpu::TextureDimension::e2D; renderTargetDescriptor.size.width = kRTSize; renderTargetDescriptor.size.height = kRTSize; - renderTargetDescriptor.size.depth = 1; + renderTargetDescriptor.size.depthOrArrayLayers = 1; renderTargetDescriptor.sampleCount = 1; renderTargetDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; renderTargetDescriptor.mipLevelCount = 1; @@ -43,7 +43,7 @@ class DepthStencilStateTest : public DawnTest { depthDescriptor.dimension = wgpu::TextureDimension::e2D; depthDescriptor.size.width = kRTSize; depthDescriptor.size.height = kRTSize; - depthDescriptor.size.depth = 1; + depthDescriptor.size.depthOrArrayLayers = 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 3e2752fcaa..0ddac92581 100644 --- a/src/tests/end2end/DeviceLostTests.cpp +++ b/src/tests/end2end/DeviceLostTests.cpp @@ -234,7 +234,7 @@ TEST_P(DeviceLostTest, CreateTextureFails) { wgpu::TextureDescriptor descriptor; descriptor.size.width = 4; descriptor.size.height = 4; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.mipLevelCount = 1; descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.usage = wgpu::TextureUsage::RenderAttachment; diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp index d26fb8e1ce..10ebad2596 100644 --- a/src/tests/end2end/IOSurfaceWrappingTests.cpp +++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp @@ -182,7 +182,7 @@ TEST_P(IOSurfaceValidationTests, InvalidMipLevelCount) { // Test an error occurs if the descriptor depth isn't 1 TEST_P(IOSurfaceValidationTests, InvalidDepth) { DAWN_SKIP_TEST_IF(UsesWire()); - descriptor.size.depth = 2; + descriptor.size.depthOrArrayLayers = 2; ASSERT_DEVICE_ERROR(wgpu::Texture texture = WrapIOSurface(&descriptor, defaultIOSurface.get(), 0)); diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index 62e0ae835e..2eeadbbbab 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -101,7 +101,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 = arrayLayerCount; + descriptor.size.depthOrArrayLayers = 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 91fab1094b..e479fee962 100644 --- a/src/tests/end2end/NonzeroTextureCreationTests.cpp +++ b/src/tests/end2end/NonzeroTextureCreationTests.cpp @@ -33,7 +33,7 @@ TEST_P(NonzeroTextureCreationTests, TextureCreationClears) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; @@ -53,7 +53,7 @@ TEST_P(NonzeroTextureCreationTests, Depth32TextureCreationDepthClears) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.mipLevelCount = 1; descriptor.usage = wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc; @@ -75,7 +75,7 @@ TEST_P(NonzeroTextureCreationTests, MipMapClears) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = mipLevels; @@ -99,7 +99,7 @@ TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = arrayLayers; + descriptor.size.depthOrArrayLayers = arrayLayers; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; @@ -125,7 +125,7 @@ TEST_P(NonzeroTextureCreationTests, NonrenderableTextureFormat) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Snorm; descriptor.mipLevelCount = 1; @@ -163,7 +163,7 @@ TEST_P(NonzeroTextureCreationTests, NonRenderableTextureClearWithMultiArrayLayer descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = 2; + descriptor.size.depthOrArrayLayers = 2; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Snorm; descriptor.mipLevelCount = 1; @@ -196,7 +196,7 @@ TEST_P(NonzeroTextureCreationTests, AllSubresourcesFilled) { baseDescriptor.dimension = wgpu::TextureDimension::e2D; baseDescriptor.size.width = kSize; baseDescriptor.size.height = kSize; - baseDescriptor.size.depth = 1; + baseDescriptor.size.depthOrArrayLayers = 1; baseDescriptor.sampleCount = 1; baseDescriptor.format = wgpu::TextureFormat::RGBA8Unorm; baseDescriptor.mipLevelCount = 1; @@ -208,10 +208,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.size.depth = kMaxColorAttachments + 1; + descriptor.size.depthOrArrayLayers = kMaxColorAttachments + 1; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.size.depth; ++i) { + for (uint32_t i = 0; i < descriptor.size.depthOrArrayLayers; ++i) { EXPECT_TEXTURE_RGBA8_EQ(&filled, texture, 0, 0, 1, 1, 0, i); } } @@ -230,11 +230,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.size.depth = kMaxColorAttachments + 1; + descriptor.size.depthOrArrayLayers = kMaxColorAttachments + 1; descriptor.mipLevelCount = 3; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.size.depth; ++i) { + for (uint32_t i = 0; i < descriptor.size.depthOrArrayLayers; ++i) { for (uint32_t j = 0; j < descriptor.mipLevelCount; ++j) { EXPECT_TEXTURE_RGBA8_EQ(&filled, texture, 0, 0, 1, 1, j, i); } @@ -248,7 +248,7 @@ TEST_P(NonzeroTextureCreationTests, NonRenderableAllSubresourcesFilled) { baseDescriptor.dimension = wgpu::TextureDimension::e2D; baseDescriptor.size.width = kSize; baseDescriptor.size.height = kSize; - baseDescriptor.size.depth = 1; + baseDescriptor.size.depthOrArrayLayers = 1; baseDescriptor.sampleCount = 1; baseDescriptor.format = wgpu::TextureFormat::RGBA8Snorm; baseDescriptor.mipLevelCount = 1; @@ -260,10 +260,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.size.depth = kMaxColorAttachments + 1; + descriptor.size.depthOrArrayLayers = kMaxColorAttachments + 1; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.size.depth; ++i) { + for (uint32_t i = 0; i < descriptor.size.depthOrArrayLayers; ++i) { EXPECT_TEXTURE_RGBA8_EQ(&filled, texture, 0, 0, 1, 1, 0, i); } } @@ -282,11 +282,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.size.depth = kMaxColorAttachments + 1; + descriptor.size.depthOrArrayLayers = kMaxColorAttachments + 1; descriptor.mipLevelCount = 3; wgpu::Texture texture = device.CreateTexture(&descriptor); - for (uint32_t i = 0; i < descriptor.size.depth; ++i) { + for (uint32_t i = 0; i < descriptor.size.depthOrArrayLayers; ++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/QueueTests.cpp b/src/tests/end2end/QueueTests.cpp index bd8fd9d760..4f635e9a71 100644 --- a/src/tests/end2end/QueueTests.cpp +++ b/src/tests/end2end/QueueTests.cpp @@ -286,7 +286,7 @@ class QueueWriteTextureTests : public DawnTest { const uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(kTextureFormat); wgpu::Extent3D mipSize = {textureSpec.textureSize.width >> textureSpec.level, textureSpec.textureSize.height >> textureSpec.level, - textureSpec.textureSize.depth}; + textureSpec.textureSize.depthOrArrayLayers}; uint32_t bytesPerRow = dataSpec.bytesPerRow; if (bytesPerRow == wgpu::kCopyStrideUndefined) { bytesPerRow = mipSize.width * bytesPerTexel; @@ -296,7 +296,7 @@ class QueueWriteTextureTests : public DawnTest { dataSpec.rowsPerImage > 0 ? dataSpec.rowsPerImage : mipSize.height; uint32_t bytesPerImage = bytesPerRow * appliedRowsPerImage; - const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depth; + const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depthOrArrayLayers; uint64_t dataOffset = dataSpec.offset; const uint32_t texelCountLastLayer = diff --git a/src/tests/end2end/RenderPassLoadOpTests.cpp b/src/tests/end2end/RenderPassLoadOpTests.cpp index c8bc7ce771..25d9427e22 100644 --- a/src/tests/end2end/RenderPassLoadOpTests.cpp +++ b/src/tests/end2end/RenderPassLoadOpTests.cpp @@ -60,7 +60,7 @@ class RenderPassLoadOpTests : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 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 55eb5cfa61..5d65ae8ca6 100644 --- a/src/tests/end2end/RenderPassTests.cpp +++ b/src/tests/end2end/RenderPassTests.cpp @@ -59,7 +59,7 @@ class RenderPassTest : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = kFormat; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/SamplerFilterAnisotropicTests.cpp b/src/tests/end2end/SamplerFilterAnisotropicTests.cpp index 7dd08de56f..0f5b080bb0 100644 --- a/src/tests/end2end/SamplerFilterAnisotropicTests.cpp +++ b/src/tests/end2end/SamplerFilterAnisotropicTests.cpp @@ -97,7 +97,7 @@ class SamplerFilterAnisotropicTest : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = textureWidthLevel0; descriptor.size.height = textureHeightLevel0; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = mipLevelCount; diff --git a/src/tests/end2end/SamplerTests.cpp b/src/tests/end2end/SamplerTests.cpp index 98551549fc..c3ce811e18 100644 --- a/src/tests/end2end/SamplerTests.cpp +++ b/src/tests/end2end/SamplerTests.cpp @@ -93,7 +93,7 @@ class SamplerTest : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = 2; descriptor.size.height = 2; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/end2end/SubresourceRenderAttachmentTests.cpp b/src/tests/end2end/SubresourceRenderAttachmentTests.cpp index 010376c329..fdcd89194c 100644 --- a/src/tests/end2end/SubresourceRenderAttachmentTests.cpp +++ b/src/tests/end2end/SubresourceRenderAttachmentTests.cpp @@ -121,7 +121,7 @@ class SubresourceRenderAttachmentTest : public DawnTest { renderTargetDesc.dimension = wgpu::TextureDimension::e2D; renderTargetDesc.size.width = kTextureSize; renderTargetDesc.size.height = kTextureSize; - renderTargetDesc.size.depth = kArrayLayerCount; + renderTargetDesc.size.depthOrArrayLayers = kArrayLayerCount; renderTargetDesc.sampleCount = 1; renderTargetDesc.format = format; renderTargetDesc.mipLevelCount = kMipLevelCount; diff --git a/src/tests/end2end/TextureViewTests.cpp b/src/tests/end2end/TextureViewTests.cpp index 1396d6ea86..4a34bd672f 100644 --- a/src/tests/end2end/TextureViewTests.cpp +++ b/src/tests/end2end/TextureViewTests.cpp @@ -37,7 +37,7 @@ namespace { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = arrayLayerCount; + descriptor.size.depthOrArrayLayers = 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 8076c13743..11ab992fbb 100644 --- a/src/tests/end2end/TextureZeroInitTests.cpp +++ b/src/tests/end2end/TextureZeroInitTests.cpp @@ -45,7 +45,7 @@ class TextureZeroInitTest : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kSize; descriptor.size.height = kSize; - descriptor.size.depth = arrayLayerCount; + descriptor.size.depthOrArrayLayers = arrayLayerCount; descriptor.sampleCount = 1; descriptor.format = format; descriptor.mipLevelCount = mipLevelCount; @@ -1425,7 +1425,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferNonRenderableUnaligned) { wgpu::TextureDescriptor descriptor; descriptor.size.width = kUnalignedSize; descriptor.size.height = kUnalignedSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.format = wgpu::TextureFormat::R8Snorm; descriptor.usage = wgpu::TextureUsage::CopySrc; wgpu::Texture texture = device.CreateTexture(&descriptor); diff --git a/src/tests/perf_tests/DrawCallPerf.cpp b/src/tests/perf_tests/DrawCallPerf.cpp index a2cd14e2c3..8000549d27 100644 --- a/src/tests/perf_tests/DrawCallPerf.cpp +++ b/src/tests/perf_tests/DrawCallPerf.cpp @@ -287,7 +287,7 @@ void DrawCallPerf::SetUp() { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kTextureSize; descriptor.size.height = kTextureSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.usage = wgpu::TextureUsage::RenderAttachment; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; diff --git a/src/tests/perf_tests/SubresourceTrackingPerf.cpp b/src/tests/perf_tests/SubresourceTrackingPerf.cpp index 7f32843e4b..0ddf86431e 100644 --- a/src/tests/perf_tests/SubresourceTrackingPerf.cpp +++ b/src/tests/perf_tests/SubresourceTrackingPerf.cpp @@ -64,7 +64,7 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams 1. So there are 6 mipmaps at most: 32 * 8, 16 * 4, 8 * 2, 4 * 1, 2 * // 1, 1 * 1. @@ -261,21 +261,21 @@ namespace { { wgpu::TextureDescriptor descriptor = defaultDescriptor; - descriptor.size.depth = kMaxTextureArrayLayers + 1u; + descriptor.size.depthOrArrayLayers = kMaxTextureArrayLayers + 1u; ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); } // Array layer count less than kMaxTextureArrayLayers is allowed { wgpu::TextureDescriptor descriptor = defaultDescriptor; - descriptor.size.depth = kMaxTextureArrayLayers >> 1; + descriptor.size.depthOrArrayLayers = kMaxTextureArrayLayers >> 1; device.CreateTexture(&descriptor); } // Array layer count equal to kMaxTextureArrayLayers is allowed { wgpu::TextureDescriptor descriptor = defaultDescriptor; - descriptor.size.depth = kMaxTextureArrayLayers; + descriptor.size.depthOrArrayLayers = kMaxTextureArrayLayers; device.CreateTexture(&descriptor); } } @@ -602,7 +602,7 @@ namespace { for (wgpu::TextureFormat format : utils::kBCFormats) { wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); descriptor.format = format; - descriptor.size.depth = 6; + descriptor.size.depthOrArrayLayers = 6; device.CreateTexture(&descriptor); } } @@ -612,7 +612,7 @@ namespace { for (wgpu::TextureFormat format : utils::kBCFormats) { wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); descriptor.format = format; - descriptor.size.depth = 4; + descriptor.size.depthOrArrayLayers = 4; descriptor.dimension = wgpu::TextureDimension::e3D; ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); } diff --git a/src/tests/unittests/validation/TextureViewValidationTests.cpp b/src/tests/unittests/validation/TextureViewValidationTests.cpp index e2f5476a3e..31ad3c159e 100644 --- a/src/tests/unittests/validation/TextureViewValidationTests.cpp +++ b/src/tests/unittests/validation/TextureViewValidationTests.cpp @@ -35,7 +35,7 @@ namespace { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = arrayLayerCount; + descriptor.size.depthOrArrayLayers = 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 27b3c9c711..d4a5ba9068 100644 --- a/src/tests/unittests/validation/ValidationTest.cpp +++ b/src/tests/unittests/validation/ValidationTest.cpp @@ -187,7 +187,7 @@ ValidationTest::DummyRenderPass::DummyRenderPass(const wgpu::Device& device) descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = attachmentFormat; descriptor.mipLevelCount = 1; diff --git a/src/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/tests/white_box/D3D12DescriptorHeapTests.cpp index 41985b1317..cbbe21d331 100644 --- a/src/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/tests/white_box/D3D12DescriptorHeapTests.cpp @@ -73,7 +73,7 @@ class D3D12DescriptorHeapTests : public DawnTest { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = format; descriptor.mipLevelCount = 1; @@ -747,7 +747,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = kRTSize; descriptor.size.height = kRTSize; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::RGBA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/white_box/D3D12ResourceHeapTests.cpp b/src/tests/white_box/D3D12ResourceHeapTests.cpp index 450cb9e08d..b9606ce482 100644 --- a/src/tests/white_box/D3D12ResourceHeapTests.cpp +++ b/src/tests/white_box/D3D12ResourceHeapTests.cpp @@ -54,7 +54,7 @@ TEST_P(D3D12ResourceHeapTests, AlignSmallCompressedTexture) { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = 8; descriptor.size.height = 8; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::BC1RGBAUnorm; descriptor.mipLevelCount = 1; diff --git a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp index 1ab886b9ed..c5b36e677a 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp @@ -225,7 +225,7 @@ namespace dawn_native { namespace vulkan { // Test an error occurs if the descriptor depth isn't 1 TEST_P(VulkanImageWrappingValidationTests, InvalidDepth) { - defaultDescriptor.size.depth = 2; + defaultDescriptor.size.depthOrArrayLayers = 2; ASSERT_DEVICE_ERROR(wgpu::Texture texture = WrapVulkanImage(device, &defaultDescriptor, defaultFd, @@ -770,7 +770,7 @@ namespace dawn_native { namespace vulkan { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = 640; descriptor.size.height = 480; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 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 7df34ab130..9e1656736e 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp @@ -314,7 +314,7 @@ namespace dawn_native { namespace vulkan { // Test an error occurs if the descriptor depth isn't 1 TEST_P(VulkanImageWrappingValidationTests, InvalidDepth) { DAWN_SKIP_TEST_IF(UsesWire()); - defaultDescriptor.size.depth = 2; + defaultDescriptor.size.depthOrArrayLayers = 2; ASSERT_DEVICE_ERROR(wgpu::Texture texture = WrapVulkanImage( device, &defaultDescriptor, defaultFd, defaultAllocationSize, @@ -929,7 +929,7 @@ namespace dawn_native { namespace vulkan { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = 640; descriptor.size.height = 480; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = wgpu::TextureFormat::BGRA8Unorm; descriptor.mipLevelCount = 1; diff --git a/src/utils/TestUtils.cpp b/src/utils/TestUtils.cpp index 323c3c2e04..673ad78732 100644 --- a/src/utils/TestUtils.cpp +++ b/src/utils/TestUtils.cpp @@ -40,7 +40,8 @@ namespace utils { TextureDataCopyLayout layout; layout.mipSize = {textureSizeAtLevel0.width >> mipmapLevel, - textureSizeAtLevel0.height >> mipmapLevel, textureSizeAtLevel0.depth}; + textureSizeAtLevel0.height >> mipmapLevel, + textureSizeAtLevel0.depthOrArrayLayers}; layout.bytesPerRow = GetMinimumBytesPerRow(format, layout.mipSize.width); @@ -83,7 +84,7 @@ namespace utils { ASSERT(copyExtent.height % blockHeight == 0); uint32_t heightInBlocks = copyExtent.height / blockHeight; return RequiredBytesInCopy(bytesPerRow, rowsPerImage, widthInBlocks, heightInBlocks, - copyExtent.depth, blockSize); + copyExtent.depthOrArrayLayers, blockSize); } uint64_t RequiredBytesInCopy(uint64_t bytesPerRow, diff --git a/src/utils/WGPUHelpers.cpp b/src/utils/WGPUHelpers.cpp index 8370c91194..751c4e5c76 100644 --- a/src/utils/WGPUHelpers.cpp +++ b/src/utils/WGPUHelpers.cpp @@ -258,7 +258,7 @@ namespace utils { descriptor.dimension = wgpu::TextureDimension::e2D; descriptor.size.width = width; descriptor.size.height = height; - descriptor.size.depth = 1; + descriptor.size.depthOrArrayLayers = 1; descriptor.sampleCount = 1; descriptor.format = BasicRenderPass::kDefaultColorFormat; descriptor.mipLevelCount = 1;