mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 10:51:35 +00:00
API evolution GPUExtent3D.depth -> depthOrArrayLayers (Step 2)
Still leave deprecated `depth` functional as there are some references in other clients. Using `depth` and `depthOrArrayLayers` at the same time is invalid. Add DeprecatedAPITests. Bug: chromium:1176969 Change-Id: Ia06645e4f3c17588323dd36b11f9f3988b2e3aba Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/44640 Commit-Queue: Shrek Shao <shrekshao@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
a9b211d202
commit
b00de7f8e8
@ -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": {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<CopyBufferToTextureCmd>(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<CopyTextureToBufferCmd>(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<CopyTextureToTextureCmd>(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 {};
|
||||
|
@ -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 &&
|
||||
ASSERT(copySize.depthOrArrayLayers <= 1 || (bytesPerRow != wgpu::kCopyStrideUndefined &&
|
||||
rowsPerImage != wgpu::kCopyStrideUndefined));
|
||||
uint64_t bytesPerImage = Safe32x32(bytesPerRow, rowsPerImage);
|
||||
if (bytesPerImage > std::numeric_limits<uint64_t>::max() / copySize.depth) {
|
||||
if (bytesPerImage > std::numeric_limits<uint64_t>::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,7 +219,8 @@ namespace dawn_native {
|
||||
ASSERT(copyExtent.height % blockInfo.height == 0);
|
||||
uint32_t heightInBlocks = copyExtent.height / blockInfo.height;
|
||||
|
||||
if (copyExtent.depth > 1 && (layout.bytesPerRow == 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<uint64_t>(mipSize.width) ||
|
||||
static_cast<uint64_t>(textureCopy.origin.y) + static_cast<uint64_t>(copySize.height) >
|
||||
static_cast<uint64_t>(mipSize.height) ||
|
||||
static_cast<uint64_t>(textureCopy.origin.z) + static_cast<uint64_t>(copySize.depth) >
|
||||
static_cast<uint64_t>(mipSize.depth)) {
|
||||
static_cast<uint64_t>(textureCopy.origin.z) +
|
||||
static_cast<uint64_t>(copySize.depthOrArrayLayers) >
|
||||
static_cast<uint64_t>(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.");
|
||||
|
@ -1247,10 +1247,12 @@ namespace dawn_native {
|
||||
ResultOrError<Ref<TextureBase>> 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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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<bool>(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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<uint64_t, TextureCopySplits::kMaxTextureCopySplits>
|
||||
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,
|
||||
|
@ -79,7 +79,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
TextureDescriptor textureDescriptor = {};
|
||||
textureDescriptor.usage = static_cast<wgpu::TextureUsage>(descriptor->usage);
|
||||
textureDescriptor.dimension = static_cast<wgpu::TextureDimension>(mDimension);
|
||||
textureDescriptor.size = {mSize.width, mSize.height, mSize.depth};
|
||||
textureDescriptor.size = {mSize.width, mSize.height, mSize.depthOrArrayLayers};
|
||||
textureDescriptor.format = static_cast<wgpu::TextureFormat>(mFormat);
|
||||
textureDescriptor.mipLevelCount = mMipLevelCount;
|
||||
textureDescriptor.sampleCount = mSampleCount;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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<uint64_t, TextureCopySplits::kMaxTextureCopySplits> 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];
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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<NSUInteger>::max()) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<uintptr_t>(
|
||||
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<void*>(static_cast<uintptr_t>(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<void*>(
|
||||
static_cast<uintptr_t>(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);
|
||||
}
|
||||
|
@ -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<const uint8_t*>(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<const uint8_t*>(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,
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<float> 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,
|
||||
|
@ -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;
|
||||
|
@ -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<uint8_t> data(uploadBufferSize, 0);
|
||||
std::vector<uint8_t> 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<RGBA8> 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<RGBA8> FillExpectedData(const wgpu::Extent3D& testRegion,
|
||||
RGBA8 leftColorInBlock,
|
||||
RGBA8 rightColorInBlock) {
|
||||
ASSERT(testRegion.depth == 1);
|
||||
ASSERT(testRegion.depthOrArrayLayers == 1);
|
||||
|
||||
std::vector<RGBA8> 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;
|
||||
|
@ -46,7 +46,7 @@ class CopyTests : public DawnTest {
|
||||
static std::vector<uint8_t> GetExpectedTextureData(const utils::TextureDataCopyLayout& layout) {
|
||||
uint32_t bytesPerTexelBlock = layout.bytesPerRow / layout.texelBlocksPerRow;
|
||||
std::vector<uint8_t> 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<RGBA8> GetExpectedTextureDataRGBA8(
|
||||
const utils::TextureDataCopyLayout& layout) {
|
||||
std::vector<RGBA8> 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<RGBA8> 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<uint8_t> 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).
|
||||
|
@ -36,7 +36,7 @@ class CopyTextureForBrowserTests : public DawnTest {
|
||||
|
||||
static std::vector<RGBA8> GetSourceTextureData(const utils::TextureDataCopyLayout& layout) {
|
||||
std::vector<RGBA8> 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<RGBA8> textureArrayCopyData = GetSourceTextureData(copyLayout);
|
||||
|
@ -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<ID3D11Texture2D> d3d11Texture;
|
||||
|
@ -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<uint8_t> 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(),
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 =
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -64,7 +64,7 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams<SubresourceTrackin
|
||||
mMaterials = device.CreateTexture(&materialDesc);
|
||||
|
||||
wgpu::TextureDescriptor uploadTexDesc = materialDesc;
|
||||
uploadTexDesc.size.depth = 1;
|
||||
uploadTexDesc.size.depthOrArrayLayers = 1;
|
||||
uploadTexDesc.mipLevelCount = 1;
|
||||
uploadTexDesc.usage = wgpu::TextureUsage::CopySrc;
|
||||
mUploadTexture = device.CreateTexture(&uploadTexDesc);
|
||||
|
@ -49,7 +49,8 @@ namespace {
|
||||
const auto& copy = copySplit.copies[i];
|
||||
ASSERT_LE(copy.bufferOffset.x + copy.copySize.width, copy.bufferSize.width);
|
||||
ASSERT_LE(copy.bufferOffset.y + copy.copySize.height, copy.bufferSize.height);
|
||||
ASSERT_LE(copy.bufferOffset.z + copy.copySize.depth, copy.bufferSize.depth);
|
||||
ASSERT_LE(copy.bufferOffset.z + copy.copySize.depthOrArrayLayers,
|
||||
copy.bufferSize.depthOrArrayLayers);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,9 +76,9 @@ namespace {
|
||||
bool overlapY =
|
||||
RangesOverlap(a.textureOffset.y, a.textureOffset.y + a.copySize.height,
|
||||
b.textureOffset.y, b.textureOffset.y + b.copySize.height);
|
||||
bool overlapZ =
|
||||
RangesOverlap(a.textureOffset.z, a.textureOffset.z + a.copySize.depth,
|
||||
b.textureOffset.z, b.textureOffset.z + b.copySize.depth);
|
||||
bool overlapZ = RangesOverlap(
|
||||
a.textureOffset.z, a.textureOffset.z + a.copySize.depthOrArrayLayers,
|
||||
b.textureOffset.z, b.textureOffset.z + b.copySize.depthOrArrayLayers);
|
||||
ASSERT_TRUE(!overlapX || !overlapY || !overlapZ);
|
||||
}
|
||||
}
|
||||
@ -93,7 +94,8 @@ namespace {
|
||||
uint32_t minZ = copySplit.copies[0].textureOffset.z;
|
||||
uint32_t maxX = copySplit.copies[0].textureOffset.x + copySplit.copies[0].copySize.width;
|
||||
uint32_t maxY = copySplit.copies[0].textureOffset.y + copySplit.copies[0].copySize.height;
|
||||
uint32_t maxZ = copySplit.copies[0].textureOffset.z + copySplit.copies[0].copySize.depth;
|
||||
uint32_t maxZ =
|
||||
copySplit.copies[0].textureOffset.z + copySplit.copies[0].copySize.depthOrArrayLayers;
|
||||
|
||||
for (uint32_t i = 1; i < copySplit.count; ++i) {
|
||||
const auto& copy = copySplit.copies[i];
|
||||
@ -102,7 +104,7 @@ namespace {
|
||||
minZ = std::min(minZ, copy.textureOffset.z);
|
||||
maxX = std::max(maxX, copy.textureOffset.x + copy.copySize.width);
|
||||
maxY = std::max(maxY, copy.textureOffset.y + copy.copySize.height);
|
||||
maxZ = std::max(maxZ, copy.textureOffset.z + copy.copySize.depth);
|
||||
maxZ = std::max(maxZ, copy.textureOffset.z + copy.copySize.depthOrArrayLayers);
|
||||
}
|
||||
|
||||
ASSERT_EQ(minX, textureSpec.x);
|
||||
@ -119,7 +121,7 @@ namespace {
|
||||
uint32_t count = 0;
|
||||
for (uint32_t i = 0; i < copySplit.count; ++i) {
|
||||
const auto& copy = copySplit.copies[i];
|
||||
count += copy.copySize.width * copy.copySize.height * copy.copySize.depth;
|
||||
count += copy.copySize.width * copy.copySize.height * copy.copySize.depthOrArrayLayers;
|
||||
}
|
||||
ASSERT_EQ(count, textureSpec.width * textureSpec.height * textureSpec.depth);
|
||||
}
|
||||
@ -192,11 +194,12 @@ namespace {
|
||||
const auto& copy = copySplit.copies[i];
|
||||
os << " " << i << ": Texture at (" << copy.textureOffset.x << ", "
|
||||
<< copy.textureOffset.y << ", " << copy.textureOffset.z << "), size ("
|
||||
<< copy.copySize.width << ", " << copy.copySize.height << ", " << copy.copySize.depth
|
||||
<< ")" << std::endl;
|
||||
<< copy.copySize.width << ", " << copy.copySize.height << ", "
|
||||
<< copy.copySize.depthOrArrayLayers << ")" << std::endl;
|
||||
os << " " << i << ": Buffer at (" << copy.bufferOffset.x << ", " << copy.bufferOffset.y
|
||||
<< ", " << copy.bufferOffset.z << "), footprint (" << copy.bufferSize.width << ", "
|
||||
<< copy.bufferSize.height << ", " << copy.bufferSize.depth << ")" << std::endl;
|
||||
<< copy.bufferSize.height << ", " << copy.bufferSize.depthOrArrayLayers << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class CopyCommandTest : public ValidationTest {
|
||||
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 = format;
|
||||
descriptor.mipLevelCount = mipLevelCount;
|
||||
@ -663,7 +663,7 @@ TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) {
|
||||
ASSERT_DEVICE_ERROR(wgpu::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
||||
|
||||
wgpu::TextureDescriptor errorTextureDescriptor;
|
||||
errorTextureDescriptor.size.depth = 0;
|
||||
errorTextureDescriptor.size.depthOrArrayLayers = 0;
|
||||
ASSERT_DEVICE_ERROR(wgpu::Texture errorTexture = device.CreateTexture(&errorTextureDescriptor));
|
||||
|
||||
wgpu::ImageCopyBuffer errorImageCopyBuffer = utils::CreateImageCopyBuffer(errorBuffer, 0, 0, 0);
|
||||
@ -1252,7 +1252,7 @@ TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) {
|
||||
ASSERT_DEVICE_ERROR(wgpu::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
||||
|
||||
wgpu::TextureDescriptor errorTextureDescriptor;
|
||||
errorTextureDescriptor.size.depth = 0;
|
||||
errorTextureDescriptor.size.depthOrArrayLayers = 0;
|
||||
ASSERT_DEVICE_ERROR(wgpu::Texture errorTexture = device.CreateTexture(&errorTextureDescriptor));
|
||||
|
||||
wgpu::ImageCopyBuffer errorImageCopyBuffer = utils::CreateImageCopyBuffer(errorBuffer, 0, 0, 0);
|
||||
@ -1533,12 +1533,12 @@ TEST_F(CopyCommandTest_T2T, Success) {
|
||||
TestT2TCopy(utils::Expectation::Success, source, 0, {0, 0, 1}, destination, 0, {0, 0, 1},
|
||||
{16, 16, 1});
|
||||
|
||||
// Copy multiple slices (srcImageCopyTexture.arrayLayer + copySize.depth ==
|
||||
// Copy multiple slices (srcImageCopyTexture.arrayLayer + copySize.depthOrArrayLayers ==
|
||||
// srcImageCopyTexture.texture.arrayLayerCount)
|
||||
TestT2TCopy(utils::Expectation::Success, source, 0, {0, 0, 2}, destination, 0, {0, 0, 0},
|
||||
{16, 16, 2});
|
||||
|
||||
// Copy multiple slices (dstImageCopyTexture.arrayLayer + copySize.depth ==
|
||||
// Copy multiple slices (dstImageCopyTexture.arrayLayer + copySize.depthOrArrayLayers ==
|
||||
// dstImageCopyTexture.texture.arrayLayerCount)
|
||||
TestT2TCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, {0, 0, 2},
|
||||
{16, 16, 2});
|
||||
|
@ -38,7 +38,7 @@ namespace {
|
||||
descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||
descriptor.size.width = size.width;
|
||||
descriptor.size.height = size.height;
|
||||
descriptor.size.depth = size.depth;
|
||||
descriptor.size.depthOrArrayLayers = size.depthOrArrayLayers;
|
||||
descriptor.sampleCount = sampleCount;
|
||||
descriptor.format = format;
|
||||
descriptor.mipLevelCount = mipLevelCount;
|
||||
@ -358,7 +358,7 @@ namespace {
|
||||
// Test WriteTexture with texture in error state causes errors.
|
||||
TEST_F(QueueWriteTextureValidationTest, TextureInErrorState) {
|
||||
wgpu::TextureDescriptor errorTextureDescriptor;
|
||||
errorTextureDescriptor.size.depth = 0;
|
||||
errorTextureDescriptor.size.depthOrArrayLayers = 0;
|
||||
ASSERT_DEVICE_ERROR(wgpu::Texture errorTexture =
|
||||
device.CreateTexture(&errorTextureDescriptor));
|
||||
wgpu::ImageCopyTexture errorImageCopyTexture =
|
||||
|
@ -55,7 +55,7 @@ namespace {
|
||||
descriptor.dimension = dimension;
|
||||
descriptor.size.width = width;
|
||||
descriptor.size.height = height;
|
||||
descriptor.size.depth = arrayLayerCount;
|
||||
descriptor.size.depthOrArrayLayers = arrayLayerCount;
|
||||
descriptor.sampleCount = sampleCount;
|
||||
descriptor.format = format;
|
||||
descriptor.mipLevelCount = mipLevelCount;
|
||||
|
@ -238,7 +238,7 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
|
||||
wgpu::TextureDescriptor baseTextureDescriptor;
|
||||
baseTextureDescriptor.size.width = 4;
|
||||
baseTextureDescriptor.size.height = 4;
|
||||
baseTextureDescriptor.size.depth = 1;
|
||||
baseTextureDescriptor.size.depthOrArrayLayers = 1;
|
||||
baseTextureDescriptor.mipLevelCount = 1;
|
||||
baseTextureDescriptor.dimension = wgpu::TextureDimension::e2D;
|
||||
baseTextureDescriptor.usage = wgpu::TextureUsage::RenderAttachment;
|
||||
|
@ -33,7 +33,7 @@ namespace {
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
descriptor.size.width = kWidth;
|
||||
descriptor.size.height = kHeight;
|
||||
descriptor.size.depth = kDefaultDepth;
|
||||
descriptor.size.depthOrArrayLayers = kDefaultDepth;
|
||||
descriptor.mipLevelCount = kDefaultMipLevels;
|
||||
descriptor.sampleCount = kDefaultSampleCount;
|
||||
descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||
@ -109,7 +109,7 @@ namespace {
|
||||
{
|
||||
wgpu::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.sampleCount = 4;
|
||||
descriptor.size.depth = 2;
|
||||
descriptor.size.depthOrArrayLayers = 2;
|
||||
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
@ -217,7 +217,7 @@ namespace {
|
||||
wgpu::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.size.width = 32;
|
||||
descriptor.size.height = 8;
|
||||
descriptor.size.depth = 64;
|
||||
descriptor.size.depthOrArrayLayers = 64;
|
||||
descriptor.dimension = wgpu::TextureDimension::e3D;
|
||||
// Non square mip map halves width, height and depth until a 1x1x1 dimension for a 3D
|
||||
// texture. So there are 7 mipmaps at most: 32 * 8 * 64, 16 * 4 * 32, 8 * 2 * 16,
|
||||
@ -231,7 +231,7 @@ namespace {
|
||||
wgpu::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.size.width = 32;
|
||||
descriptor.size.height = 8;
|
||||
descriptor.size.depth = 64;
|
||||
descriptor.size.depthOrArrayLayers = 64;
|
||||
// Non square mip map halves width and height until a 1x1 dimension for a 2D texture,
|
||||
// even its depth > 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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user