Remove deprecated API surface, Pt. 1

- Remove Device.getDefaultQueue()
 - Remove Extent3D.depth
 - Remove setIndexBufferWithFormat
 - Remove TextureUsage::OutputAttachment

Change-Id: If1c39b5630c88c3b87b37e317aafe7442419f7d0
Bug: dawn:22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/50700
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Brandon Jones 2021-05-13 17:51:23 +00:00 committed by Commit Bot service account
parent 82ba34a941
commit 76e5a9f6dd
16 changed files with 44 additions and 442 deletions

View File

@ -814,10 +814,6 @@
"name": "get queue",
"returns": "queue"
},
{
"name": "get default queue",
"returns": "queue"
},
{
"name": "create external texture",
"returns": "external texture",
@ -935,8 +931,7 @@
"members": [
{"name": "width", "type": "uint32_t"},
{"name": "height", "type": "uint32_t", "default": 1},
{"name": "depth or array layers", "type": "uint32_t", "default": 1},
{"name": "depth", "type": "uint32_t", "default": 1}
{"name": "depth or array layers", "type": "uint32_t", "default": 1}
]
},
"external texture": {
@ -1386,15 +1381,6 @@
{"name": "size", "type": "uint64_t", "default": "0"}
]
},
{
"name": "set index buffer with format",
"args": [
{"name": "buffer", "type": "buffer"},
{"name": "format", "type": "index format"},
{"name": "offset", "type": "uint64_t", "default": "0"},
{"name": "size", "type": "uint64_t", "default": "0"}
]
},
{
"name": "finish",
"returns": "render bundle",
@ -1604,15 +1590,6 @@
{"name": "size", "type": "uint64_t", "default": "0"}
]
},
{
"name": "set index buffer with format",
"args": [
{"name": "buffer", "type": "buffer"},
{"name": "format", "type": "index format"},
{"name": "offset", "type": "uint64_t", "default": "0"},
{"name": "size", "type": "uint64_t", "default": "0"}
]
},
{
"name": "begin occlusion query",
"args": [
@ -2094,7 +2071,6 @@
{"value": 2, "name": "copy dst"},
{"value": 4, "name": "sampled"},
{"value": 8, "name": "storage"},
{"value": 16, "name": "output attachment"},
{"value": 16, "name": "render attachment"},
{"value": 32, "name": "present"}
]

View File

@ -653,14 +653,11 @@ 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, fixedCopySize));
DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *destination, *copySize));
DAWN_TRY(ValidateCanUseAs(destination->texture, wgpu::TextureUsage::CopyDst));
DAWN_TRY(ValidateTextureSampleCountInBufferCopyCommands(destination->texture));
@ -669,26 +666,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(GetDevice(), *destination, fixedCopySize));
DAWN_TRY(ValidateTextureCopyRange(GetDevice(), *destination, *copySize));
}
const TexelBlockInfo& blockInfo =
destination->texture->GetFormat().GetAspectInfo(destination->aspect).block;
TextureDataLayout srcLayout = FixUpDeprecatedTextureDataLayoutOptions(
GetDevice(), source->layout, blockInfo, fixedCopySize);
GetDevice(), source->layout, blockInfo, *copySize);
if (GetDevice()->IsValidationEnabled()) {
DAWN_TRY(ValidateLinearTextureCopyOffset(srcLayout, blockInfo));
DAWN_TRY(ValidateLinearTextureData(srcLayout, source->buffer->GetSize(), blockInfo,
fixedCopySize));
*copySize));
mTopLevelBuffers.insert(source->buffer);
mTopLevelTextures.insert(destination->texture);
}
ApplyDefaultTextureDataLayoutOptions(&srcLayout, blockInfo, fixedCopySize);
ApplyDefaultTextureDataLayoutOptions(&srcLayout, blockInfo, *copySize);
// Skip noop copies.
if (fixedCopySize.width != 0 && fixedCopySize.height != 0 &&
fixedCopySize.depthOrArrayLayers != 0) {
if (copySize->width != 0 && copySize->height != 0 &&
copySize->depthOrArrayLayers != 0) {
// Record the copy command.
CopyBufferToTextureCmd* copy =
allocator->Allocate<CopyBufferToTextureCmd>(Command::CopyBufferToTexture);
@ -701,7 +698,7 @@ namespace dawn_native {
copy->destination.mipLevel = destination->mipLevel;
copy->destination.aspect =
ConvertAspect(destination->texture->GetFormat(), destination->aspect);
copy->copySize = fixedCopySize;
copy->copySize = *copySize;
}
return {};
@ -712,11 +709,8 @@ 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, fixedCopySize));
DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *source, *copySize));
DAWN_TRY(ValidateCanUseAs(source->texture, wgpu::TextureUsage::CopySrc));
DAWN_TRY(ValidateTextureSampleCountInBufferCopyCommands(source->texture));
DAWN_TRY(ValidateTextureDepthStencilToBufferCopyRestrictions(*source));
@ -728,26 +722,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(GetDevice(), *source, fixedCopySize));
DAWN_TRY(ValidateTextureCopyRange(GetDevice(), *source, *copySize));
}
const TexelBlockInfo& blockInfo =
source->texture->GetFormat().GetAspectInfo(source->aspect).block;
TextureDataLayout dstLayout = FixUpDeprecatedTextureDataLayoutOptions(
GetDevice(), destination->layout, blockInfo, fixedCopySize);
GetDevice(), destination->layout, blockInfo, *copySize);
if (GetDevice()->IsValidationEnabled()) {
DAWN_TRY(ValidateLinearTextureCopyOffset(dstLayout, blockInfo));
DAWN_TRY(ValidateLinearTextureData(dstLayout, destination->buffer->GetSize(),
blockInfo, fixedCopySize));
blockInfo, *copySize));
mTopLevelTextures.insert(source->texture);
mTopLevelBuffers.insert(destination->buffer);
}
ApplyDefaultTextureDataLayoutOptions(&dstLayout, blockInfo, fixedCopySize);
ApplyDefaultTextureDataLayoutOptions(&dstLayout, blockInfo, *copySize);
// Skip noop copies.
if (fixedCopySize.width != 0 && fixedCopySize.height != 0 &&
fixedCopySize.depthOrArrayLayers != 0) {
if (copySize->width != 0 && copySize->height != 0 &&
copySize->depthOrArrayLayers != 0) {
// Record the copy command.
CopyTextureToBufferCmd* copy =
allocator->Allocate<CopyTextureToBufferCmd>(Command::CopyTextureToBuffer);
@ -759,7 +753,7 @@ namespace dawn_native {
copy->destination.offset = dstLayout.offset;
copy->destination.bytesPerRow = dstLayout.bytesPerRow;
copy->destination.rowsPerImage = dstLayout.rowsPerImage;
copy->copySize = fixedCopySize;
copy->copySize = *copySize;
}
return {};
@ -770,20 +764,18 @@ 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, fixedCopySize));
DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *destination, fixedCopySize));
DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *source, *copySize));
DAWN_TRY(ValidateImageCopyTexture(GetDevice(), *destination, *copySize));
DAWN_TRY(
ValidateTextureToTextureCopyRestrictions(*source, *destination, fixedCopySize));
ValidateTextureToTextureCopyRestrictions(*source, *destination, *copySize));
DAWN_TRY(ValidateTextureCopyRange(GetDevice(), *source, fixedCopySize));
DAWN_TRY(ValidateTextureCopyRange(GetDevice(), *destination, fixedCopySize));
DAWN_TRY(ValidateTextureCopyRange(GetDevice(), *source, *copySize));
DAWN_TRY(ValidateTextureCopyRange(GetDevice(), *destination, *copySize));
DAWN_TRY(ValidateCanUseAs(source->texture, wgpu::TextureUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(destination->texture, wgpu::TextureUsage::CopyDst));
@ -793,8 +785,8 @@ namespace dawn_native {
}
// Skip noop copies.
if (fixedCopySize.width != 0 && fixedCopySize.height != 0 &&
fixedCopySize.depthOrArrayLayers != 0) {
if (copySize->width != 0 && copySize->height != 0 &&
copySize->depthOrArrayLayers != 0) {
CopyTextureToTextureCmd* copy =
allocator->Allocate<CopyTextureToTextureCmd>(Command::CopyTextureToTexture);
copy->source.texture = source->texture;
@ -806,7 +798,7 @@ namespace dawn_native {
copy->destination.mipLevel = destination->mipLevel;
copy->destination.aspect =
ConvertAspect(destination->texture->GetFormat(), destination->aspect);
copy->copySize = fixedCopySize;
copy->copySize = *copySize;
}
return {};

View File

@ -455,8 +455,8 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Source texture must have sampled usage");
}
if (!(dst.texture->GetUsage() & wgpu::TextureUsage::OutputAttachment)) {
return DAWN_VALIDATION_ERROR("Dest texture must have outputAttachment usage");
if (!(dst.texture->GetUsage() & wgpu::TextureUsage::RenderAttachment)) {
return DAWN_VALIDATION_ERROR("Dest texture must have RenderAttachment usage");
}
return ValidateTextureToTextureCopyCommonRestrictions(src, dst, copySize);

View File

@ -985,12 +985,6 @@ namespace dawn_native {
return mQueue.Get();
}
QueueBase* DeviceBase::APIGetDefaultQueue() {
EmitDeprecationWarning(
"Device::GetDefaultQueue is deprecated, use Device::GetQueue() instead");
return APIGetQueue();
}
ExternalTextureBase* DeviceBase::APICreateExternalTexture(
const ExternalTextureDescriptor* descriptor) {
Ref<ExternalTextureBase> result = nullptr;
@ -1305,12 +1299,10 @@ namespace dawn_native {
ResultOrError<Ref<TextureBase>> DeviceBase::CreateTexture(const TextureDescriptor* descriptor) {
DAWN_TRY(ValidateIsAlive());
TextureDescriptor fixedDescriptor = *descriptor;
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(this, &(fixedDescriptor.size)));
if (IsValidationEnabled()) {
DAWN_TRY(ValidateTextureDescriptor(this, &fixedDescriptor));
DAWN_TRY(ValidateTextureDescriptor(this, descriptor));
}
return CreateTextureImpl(&fixedDescriptor);
return CreateTextureImpl(descriptor);
}
ResultOrError<Ref<TextureViewBase>> DeviceBase::CreateTextureView(

View File

@ -200,8 +200,6 @@ namespace dawn_native {
// For Dawn Wire
BufferBase* APICreateErrorBuffer();
// TODO(dawn:22): Remove once the deprecation period is finished.
QueueBase* APIGetDefaultQueue();
QueueBase* APIGetQueue();
void APIInjectError(wgpu::ErrorType type, const char* message);

View File

@ -315,21 +315,17 @@ namespace dawn_native {
size_t dataSize,
const TextureDataLayout* dataLayout,
const Extent3D* writeSize) {
Extent3D fixedWriteSize = *writeSize;
DAWN_TRY(FixUpDeprecatedGPUExtent3DDepth(GetDevice(), &fixedWriteSize));
DAWN_TRY(ValidateWriteTexture(destination, dataSize, dataLayout, writeSize));
DAWN_TRY(ValidateWriteTexture(destination, dataSize, dataLayout, &fixedWriteSize));
if (fixedWriteSize.width == 0 || fixedWriteSize.height == 0 ||
fixedWriteSize.depthOrArrayLayers == 0) {
if (writeSize->width == 0 || writeSize->height == 0 || writeSize->depthOrArrayLayers == 0) {
return {};
}
const TexelBlockInfo& blockInfo =
destination->texture->GetFormat().GetAspectInfo(destination->aspect).block;
TextureDataLayout layout = *dataLayout;
ApplyDefaultTextureDataLayoutOptions(&layout, blockInfo, fixedWriteSize);
return WriteTextureImpl(*destination, data, layout, fixedWriteSize);
ApplyDefaultTextureDataLayoutOptions(&layout, blockInfo, *writeSize);
return WriteTextureImpl(*destination, data, layout, *writeSize);
}
MaybeError QueueBase::WriteTextureImpl(const ImageCopyTexture& destination,
@ -389,14 +385,12 @@ 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, &fixedCopySize,
options));
DAWN_TRY(
ValidateCopyTextureForBrowser(GetDevice(), source, destination, copySize, options));
}
return DoCopyTextureForBrowser(GetDevice(), source, destination, &fixedCopySize, options);
return DoCopyTextureForBrowser(GetDevice(), source, destination, copySize, options);
}
MaybeError QueueBase::ValidateSubmit(uint32_t commandCount,

View File

@ -203,16 +203,6 @@ namespace dawn_native {
});
}
void RenderEncoderBase::APISetIndexBufferWithFormat(BufferBase* buffer,
wgpu::IndexFormat format,
uint64_t offset,
uint64_t size) {
GetDevice()->EmitDeprecationWarning(
"RenderEncoderBase::SetIndexBufferWithFormat is deprecated. Use "
"RenderEncoderBase::SetIndexBuffer instead.");
APISetIndexBuffer(buffer, format, offset, size);
}
void RenderEncoderBase::APISetIndexBuffer(BufferBase* buffer,
wgpu::IndexFormat format,
uint64_t offset,

View File

@ -49,10 +49,6 @@ namespace dawn_native {
wgpu::IndexFormat format,
uint64_t offset,
uint64_t size);
void APISetIndexBufferWithFormat(BufferBase* buffer,
wgpu::IndexFormat format,
uint64_t offset,
uint64_t size);
void APISetBindGroup(uint32_t groupIndex,
BindGroupBase* group,

View File

@ -248,26 +248,6 @@ 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->nextInChain != nullptr) {

View File

@ -39,8 +39,6 @@ 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;

View File

@ -1699,7 +1699,7 @@ TEST_P(CopyTests_T2B, CopyOneRowWithDepth32Float) {
wgpu::TextureDescriptor textureDescriptor;
textureDescriptor.format = kFormat;
textureDescriptor.size = {kPixelsPerRow, 1, 1};
textureDescriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::OutputAttachment;
textureDescriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment;
wgpu::Texture texture = device.CreateTexture(&textureDescriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -287,7 +287,7 @@ class CopyTextureForBrowserTests : public DawnTest {
dstDescriptor.format = dstSpec.format;
dstDescriptor.mipLevelCount = dstSpec.level + 1;
dstDescriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled |
wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc;
dstTexture = device.CreateTexture(&dstDescriptor);
if (testSubRectCopy) {

View File

@ -35,22 +35,6 @@ class DeprecationTests : public DawnTest {
}
};
// Test that SetIndexBufferWithFormat is deprecated.
TEST_P(DeprecationTests, SetIndexBufferWithFormat) {
wgpu::BufferDescriptor bufferDesc;
bufferDesc.size = 4;
bufferDesc.usage = wgpu::BufferUsage::Index;
wgpu::Buffer indexBuffer = device.CreateBuffer(&bufferDesc);
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
EXPECT_DEPRECATION_WARNING(
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32));
pass.EndPass();
}
// Test that SetBlendColor is deprecated.
TEST_P(DeprecationTests, SetSetBlendColor) {
wgpu::Color blendColor{1.0, 0.0, 0.0, 1.0};
@ -204,309 +188,11 @@ TEST_P(DeprecationTests, BindGroupLayoutEntryViewDimensionDefaulting) {
}
}
// Test Device::GetDefaultQueue deprecation.
TEST_P(DeprecationTests, GetDefaultQueueDeprecation) {
// Using GetDefaultQueue emits a warning.
wgpu::Queue deprecatedQueue;
EXPECT_DEPRECATION_WARNING(deprecatedQueue = device.GetDefaultQueue());
// Using GetQueue doesn't emit a warning.
wgpu::Queue queue = device.GetQueue();
// Both objects are the same, even with dawn_wire.
EXPECT_EQ(deprecatedQueue.Get(), queue.Get());
}
// Test that fences are deprecated.
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(),

View File

@ -244,7 +244,7 @@ class DepthStencilSamplingTest : public DawnTest {
wgpu::Texture CreateInputTexture(wgpu::TextureFormat format) {
wgpu::TextureDescriptor inputTextureDesc;
inputTextureDesc.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::OutputAttachment;
inputTextureDesc.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::RenderAttachment;
inputTextureDesc.size = {1, 1, 1};
inputTextureDesc.format = format;
return device.CreateTexture(&inputTextureDesc);
@ -253,7 +253,7 @@ class DepthStencilSamplingTest : public DawnTest {
wgpu::Texture CreateOutputTexture(wgpu::TextureFormat format) {
wgpu::TextureDescriptor outputTextureDesc;
outputTextureDesc.usage =
wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc;
outputTextureDesc.size = {1, 1, 1};
outputTextureDesc.format = format;
return device.CreateTexture(&outputTextureDesc);

View File

@ -69,17 +69,17 @@ class SwapChainValidationTests : public DawnTest {
wgpu::SwapChainDescriptor goodDescriptor;
wgpu::SwapChainDescriptor badDescriptor;
// Checks that an RenderAttachment view is an error by trying to create a render pass on it.
// Checks that a RenderAttachment view is an error by trying to create a render pass on it.
void CheckTextureViewIsError(wgpu::TextureView view) {
CheckTextureView(view, true, false);
}
// Checks that an RenderAttachment view is an error by trying to submit a render pass on it.
// Checks that a RenderAttachment view is an error by trying to submit a render pass on it.
void CheckTextureViewIsDestroyed(wgpu::TextureView view) {
CheckTextureView(view, false, true);
}
// Checks that an OutputAttachment view is valid by submitting a render pass on it.
// Checks that a RenderAttachment view is valid by submitting a render pass on it.
void CheckTextureViewIsValid(wgpu::TextureView view) {
CheckTextureView(view, false, false);
}

View File

@ -21,7 +21,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;