Deprecate TextureCopyView::arrayLayer -> origin.z

All existing tests and samples are updated and deprecation tests added.

CommandEncoder still encodes using arrayLayers so the backends are
unchanged. They will be handled in a follow-up CL.

Bug: dawn:22

Change-Id: Ib5346b46eb04d97349cab8f32ef8da5034726ca8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23104
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Corentin Wallez 2020-06-16 03:05:17 +00:00 committed by Commit Bot service account
parent cf1fdf413c
commit 984493d0ac
19 changed files with 472 additions and 346 deletions

View File

@ -75,7 +75,7 @@ void initTextures() {
device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, 4 * 1024, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {1024, 1024, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -46,30 +46,26 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Copy mipLevel out of range");
}
if (static_cast<uint64_t>(textureCopy.arrayLayer) +
static_cast<uint64_t>(copySize.depth) >
static_cast<uint64_t>(texture->GetArrayLayers())) {
return DAWN_VALIDATION_ERROR("Copy arrayLayer out of range");
}
Extent3D extent = texture->GetMipLevelPhysicalSize(textureCopy.mipLevel);
Extent3D mipSize = texture->GetMipLevelPhysicalSize(textureCopy.mipLevel);
// 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();
// All texture dimensions are in uint32_t so by doing checks in uint64_t we avoid
// overflows.
if (static_cast<uint64_t>(textureCopy.origin.x) +
static_cast<uint64_t>(copySize.width) >
static_cast<uint64_t>(extent.width) ||
static_cast<uint64_t>(mipSize.width) ||
static_cast<uint64_t>(textureCopy.origin.y) +
static_cast<uint64_t>(copySize.height) >
static_cast<uint64_t>(extent.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)) {
return DAWN_VALIDATION_ERROR("Copy would touch outside of the texture");
}
// TODO(cwallez@chromium.org): Check the depth bound differently for 3D textures.
if (textureCopy.origin.z != 0) {
return DAWN_VALIDATION_ERROR("No support for z != 0 for now");
}
return {};
}
@ -147,8 +143,8 @@ namespace dawn_native {
ASSERT(src.texture->GetDimension() == wgpu::TextureDimension::e2D &&
dst.texture->GetDimension() == wgpu::TextureDimension::e2D);
if (dst.origin.x != 0 || dst.origin.y != 0 || dst.origin.z != 0 ||
srcSize.width != copySize.width || srcSize.height != copySize.height) {
if (dst.origin.x != 0 || dst.origin.y != 0 || srcSize.width != copySize.width ||
srcSize.height != copySize.height) {
return DAWN_VALIDATION_ERROR(
"The entire subresource must be copied when using a depth/stencil texture or "
"when samples are greater than 1.");
@ -186,7 +182,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.arrayLayer, dst.arrayLayer, copySize.depth)) {
if (IsRangeOverlapped(src.origin.z, dst.origin.z, copySize.depth)) {
return DAWN_VALIDATION_ERROR(
"Copy subresources cannot be overlapped when copying within the same "
"texture.");
@ -497,6 +493,25 @@ namespace dawn_native {
return {};
}
ResultOrError<TextureCopyView> FixTextureCopyView(DeviceBase* device,
const TextureCopyView* view) {
TextureCopyView fixedView = *view;
if (view->arrayLayer != 0) {
if (view->origin.z != 0) {
return DAWN_VALIDATION_ERROR("arrayLayer and origin.z cannot both be != 0");
} else {
fixedView.origin.z = fixedView.arrayLayer;
fixedView.arrayLayer = 1;
device->EmitDeprecationWarning(
"wgpu::TextureCopyView::arrayLayer is deprecated in favor of "
"::origin::z");
}
}
return fixedView;
}
} // namespace
CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor*)
@ -657,6 +672,12 @@ namespace dawn_native {
const TextureCopyView* destination,
const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
// TODO(dawn:22): Remove once migration from GPUTextureCopyView.arrayLayer to
// GPUTextureCopyView.origin.z is done.
TextureCopyView fixedDest;
DAWN_TRY_ASSIGN(fixedDest, FixTextureCopyView(GetDevice(), destination));
destination = &fixedDest;
// Validate objects before doing the defaulting.
if (GetDevice()->IsValidationEnabled()) {
DAWN_TRY(GetDevice()->ValidateObject(source->buffer));
@ -711,6 +732,10 @@ namespace dawn_native {
copy->destination.mipLevel = destination->mipLevel;
copy->destination.arrayLayer = destination->arrayLayer;
// TODO(cwallez@chromium.org): Make backends use origin.z instead of arrayLayer
copy->destination.arrayLayer = copy->destination.origin.z;
copy->destination.origin.z = 0;
return {};
});
}
@ -719,6 +744,12 @@ namespace dawn_native {
const BufferCopyView* destination,
const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
// TODO(dawn:22): Remove once migration from GPUTextureCopyView.arrayLayer to
// GPUTextureCopyView.origin.z is done.
TextureCopyView fixedSrc;
DAWN_TRY_ASSIGN(fixedSrc, FixTextureCopyView(GetDevice(), source));
source = &fixedSrc;
// Validate objects before doing the defaulting.
if (GetDevice()->IsValidationEnabled()) {
DAWN_TRY(GetDevice()->ValidateObject(source->texture));
@ -771,6 +802,10 @@ namespace dawn_native {
copy->destination.bytesPerRow = destination->bytesPerRow;
copy->destination.rowsPerImage = defaultedRowsPerImage;
// TODO(cwallez@chromium.org): Make backends use origin.z instead of arrayLayer
copy->source.arrayLayer = copy->source.origin.z;
copy->source.origin.z = 0;
return {};
});
}
@ -779,6 +814,15 @@ namespace dawn_native {
const TextureCopyView* destination,
const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
// TODO(dawn:22): Remove once migration from GPUTextureCopyView.arrayLayer to
// GPUTextureCopyView.origin.z is done.
TextureCopyView fixedSrc;
DAWN_TRY_ASSIGN(fixedSrc, FixTextureCopyView(GetDevice(), source));
source = &fixedSrc;
TextureCopyView fixedDest;
DAWN_TRY_ASSIGN(fixedDest, FixTextureCopyView(GetDevice(), destination));
destination = &fixedDest;
if (GetDevice()->IsValidationEnabled()) {
DAWN_TRY(GetDevice()->ValidateObject(source->texture));
DAWN_TRY(GetDevice()->ValidateObject(destination->texture));
@ -814,6 +858,12 @@ namespace dawn_native {
copy->destination.arrayLayer = destination->arrayLayer;
copy->copySize = *copySize;
// TODO(cwallez@chromium.org): Make backends use origin.z instead of arrayLayer
copy->source.arrayLayer = copy->source.origin.z;
copy->source.origin.z = 0;
copy->destination.arrayLayer = copy->destination.origin.z;
copy->destination.origin.z = 0;
return {};
});
}

View File

@ -932,7 +932,7 @@ std::ostringstream& DawnTestBase::AddTextureExpectation(const char* file,
// We need to enqueue the copy immediately because by the time we resolve the expectation,
// the texture might have been modified.
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(texture, level, slice, {x, y, 0});
utils::CreateTextureCopyView(texture, level, {x, y, slice});
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(readback.buffer, readback.offset, bytesPerRow, 0);
wgpu::Extent3D copySize = {width, height, 1};

View File

@ -305,7 +305,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, widthInBytes, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {width, height, 1};
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);

View File

@ -91,9 +91,12 @@ class CompressedTextureBCFormatTest : public DawnTest {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, copyConfig.bufferOffset,
copyConfig.bytesPerRowAlignment, copyConfig.rowsPerImage);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(bcCompressedTexture, copyConfig.viewMipmapLevel,
copyConfig.viewArrayLayer, copyConfig.copyOrigin3D);
ASSERT(copyConfig.copyOrigin3D.z == 0);
wgpu::Origin3D copyOrigin = copyConfig.copyOrigin3D;
copyOrigin.z = copyConfig.viewArrayLayer;
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(
bcCompressedTexture, copyConfig.viewMipmapLevel, copyOrigin);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copyConfig.copyExtent3D);
@ -237,12 +240,17 @@ class CompressedTextureBCFormatTest : public DawnTest {
wgpu::Texture dstTexture,
CopyConfig srcConfig,
CopyConfig dstConfig) {
ASSERT(srcConfig.copyOrigin3D.z == 0);
wgpu::Origin3D srcCopyOrigin = srcConfig.copyOrigin3D;
srcCopyOrigin.z = srcConfig.viewArrayLayer;
wgpu::TextureCopyView textureCopyViewSrc =
utils::CreateTextureCopyView(srcTexture, srcConfig.viewMipmapLevel,
srcConfig.viewArrayLayer, srcConfig.copyOrigin3D);
utils::CreateTextureCopyView(srcTexture, srcConfig.viewMipmapLevel, srcCopyOrigin);
ASSERT(dstConfig.copyOrigin3D.z == 0);
wgpu::Origin3D dstCopyOrigin = dstConfig.copyOrigin3D;
dstCopyOrigin.z = dstConfig.viewArrayLayer;
wgpu::TextureCopyView textureCopyViewDst =
utils::CreateTextureCopyView(dstTexture, dstConfig.viewMipmapLevel,
dstConfig.viewArrayLayer, dstConfig.copyOrigin3D);
utils::CreateTextureCopyView(dstTexture, dstConfig.viewMipmapLevel, dstCopyOrigin);
encoder.CopyTextureToTexture(&textureCopyViewSrc, &textureCopyViewDst,
&dstConfig.copyExtent3D);
}
@ -631,9 +639,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyIntoSubresourceWithPhysicalSizeNotEqua
srcConfig.textureDescriptor.usage =
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst;
wgpu::Texture bcTextureSrc = CreateTextureWithCompressedData(srcConfig);
wgpu::TextureCopyView textureCopyViewSrc =
utils::CreateTextureCopyView(bcTextureSrc, srcConfig.viewMipmapLevel,
srcConfig.viewArrayLayer, srcConfig.copyOrigin3D);
wgpu::TextureCopyView textureCopyViewSrc = utils::CreateTextureCopyView(
bcTextureSrc, srcConfig.viewMipmapLevel, srcConfig.copyOrigin3D);
// Create bcTexture and copy from the content in bcTextureSrc into it.
dstConfig.textureDescriptor.format = format;

View File

@ -109,7 +109,7 @@ class CopyTests_T2B : public CopyTests {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(uploadBuffer, 0, bytesPerRow, 0);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(texture, textureSpec.level, slice, {0, 0, 0});
utils::CreateTextureCopyView(texture, textureSpec.level, {0, 0, slice});
wgpu::Extent3D copySize = {width, height, 1};
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
}
@ -131,7 +131,7 @@ class CopyTests_T2B : public CopyTests {
// Copy the region [(`x`, `y`), (`x + copyWidth, `y + copyWidth`)] from the `level`
// mip into the buffer at `offset + bufferSpec.size * slice` and `bytesPerRow`
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(
texture, textureSpec.level, slice, {textureSpec.x, textureSpec.y, 0});
texture, textureSpec.level, {textureSpec.x, textureSpec.y, slice});
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(buffer, bufferOffset, bufferSpec.bytesPerRow, 0);
wgpu::Extent3D copySize = {textureSpec.copyWidth, textureSpec.copyHeight, 1};
@ -229,7 +229,7 @@ protected:
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(uploadBuffer, 0, bytesPerRow, 0);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(texture, textureSpec.level, 0, {0, 0, 0});
utils::CreateTextureCopyView(texture, textureSpec.level, {0, 0, 0});
wgpu::Extent3D copySize = {width, height, 1};
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
}
@ -240,7 +240,7 @@ protected:
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(buffer, bufferSpec.offset, bufferSpec.bytesPerRow, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(
texture, textureSpec.level, 0, {textureSpec.x, textureSpec.y, 0});
texture, textureSpec.level, {textureSpec.x, textureSpec.y, 0});
wgpu::Extent3D copySize = {textureSpec.copyWidth, textureSpec.copyHeight, 1};
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
}
@ -345,7 +345,7 @@ class CopyTests_T2T : public CopyTests {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(uploadBuffer, 0, bytesPerRow, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(
srcTexture, srcSpec.level, srcSpec.baseArrayLayer + slice, {0, 0, 0});
srcTexture, srcSpec.level, {0, 0, srcSpec.baseArrayLayer + slice});
wgpu::Extent3D bufferCopySize = {width, height, 1};
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &bufferCopySize);
@ -353,9 +353,9 @@ class CopyTests_T2T : public CopyTests {
// Perform the texture to texture copy
wgpu::TextureCopyView srcTextureCopyView = utils::CreateTextureCopyView(
srcTexture, srcSpec.level, srcSpec.baseArrayLayer, {srcSpec.x, srcSpec.y, 0});
srcTexture, srcSpec.level, {srcSpec.x, srcSpec.y, srcSpec.baseArrayLayer});
wgpu::TextureCopyView dstTextureCopyView = utils::CreateTextureCopyView(
dstTexture, dstSpec.level, dstSpec.baseArrayLayer, {dstSpec.x, dstSpec.y, 0});
dstTexture, dstSpec.level, {dstSpec.x, dstSpec.y, dstSpec.baseArrayLayer});
wgpu::Extent3D copySize = {copy.width, copy.height, copy.arrayLayerCount};
encoder.CopyTextureToTexture(&srcTextureCopyView, &dstTextureCopyView, &copySize);

View File

@ -138,3 +138,116 @@ DAWN_INSTANTIATE_TEST(DeprecationTests,
NullBackend(),
OpenGLBackend(),
VulkanBackend());
class TextureCopyViewArrayLayerDeprecationTests : public DeprecationTests {
protected:
wgpu::TextureCopyView MakeOldTextureCopyView() {
wgpu::TextureDescriptor desc;
desc.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst;
desc.dimension = wgpu::TextureDimension::e2D;
desc.size = {1, 1, 2};
desc.format = wgpu::TextureFormat::RGBA8Unorm;
wgpu::TextureCopyView copy;
copy.texture = device.CreateTexture(&desc);
copy.arrayLayer = 1;
copy.origin = {0, 0, 0};
return copy;
}
wgpu::TextureCopyView MakeNewTextureCopyView() {
wgpu::TextureCopyView copy = MakeOldTextureCopyView();
copy.arrayLayer = 0;
copy.origin.z = 1;
return copy;
}
wgpu::TextureCopyView MakeErrorTextureCopyView() {
wgpu::TextureCopyView copy = MakeOldTextureCopyView();
copy.origin.z = 1;
return copy;
}
wgpu::BufferCopyView MakeBufferCopyView() const {
wgpu::BufferDescriptor desc;
desc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
desc.size = 4;
wgpu::BufferCopyView copy;
copy.buffer = device.CreateBuffer(&desc);
copy.bytesPerRow = kTextureBytesPerRowAlignment;
return copy;
}
wgpu::Extent3D copySize = {1, 1, 1};
};
// Test that using TextureCopyView::arrayLayer emits a warning.
TEST_P(TextureCopyViewArrayLayerDeprecationTests, DeprecationWarning) {
wgpu::TextureCopyView texOldCopy = MakeOldTextureCopyView();
wgpu::TextureCopyView texNewCopy = MakeNewTextureCopyView();
wgpu::BufferCopyView bufCopy = MakeBufferCopyView();
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
EXPECT_DEPRECATION_WARNING(encoder.CopyBufferToTexture(&bufCopy, &texOldCopy, &copySize));
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToTexture(&texNewCopy, &texOldCopy, &copySize));
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToBuffer(&texOldCopy, &bufCopy, &copySize));
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToTexture(&texOldCopy, &texNewCopy, &copySize));
wgpu::CommandBuffer command = encoder.Finish();
queue.Submit(1, &command);
}
// Test that using both TextureCopyView::arrayLayer and origin.z is an error.
TEST_P(TextureCopyViewArrayLayerDeprecationTests, BothArrayLayerAndOriginZIsError) {
wgpu::TextureCopyView texErrorCopy = MakeErrorTextureCopyView();
wgpu::TextureCopyView texNewCopy = MakeNewTextureCopyView();
wgpu::BufferCopyView bufCopy = MakeBufferCopyView();
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToTexture(&bufCopy, &texErrorCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToTexture(&texNewCopy, &texErrorCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToBuffer(&texErrorCopy, &bufCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToTexture(&texErrorCopy, &texNewCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Test that using TextureCopyView::arrayLayer is correctly taken into account
TEST_P(TextureCopyViewArrayLayerDeprecationTests, StateTracking) {
wgpu::TextureCopyView texOOBCopy = MakeErrorTextureCopyView();
texOOBCopy.arrayLayer = 2; // Oh no, it is OOB!
wgpu::TextureCopyView texNewCopy = MakeNewTextureCopyView();
wgpu::BufferCopyView bufCopy = MakeBufferCopyView();
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToTexture(&bufCopy, &texOOBCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToTexture(&texNewCopy, &texOOBCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToBuffer(&texOOBCopy, &bufCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToTexture(&texOOBCopy, &texNewCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
}
DAWN_INSTANTIATE_TEST(TextureCopyViewArrayLayerDeprecationTests,
D3D12Backend(),
MetalBackend(),
NullBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -137,7 +137,7 @@ TEST_P(NonzeroTextureCreationTests, NonrenderableTextureFormat) {
device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, kSize * 4, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -170,7 +170,7 @@ TEST_P(NonzeroTextureCreationTests, NonRenderableTextureClearWithMultiArrayLayer
device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, kSize * 4, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 1, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 1});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -105,8 +105,7 @@ protected:
wgpu::Buffer stagingBuffer =
utils::CreateBufferFromData(device, data, sizeof(data), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 256, 0);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {2, 2, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -473,7 +473,7 @@ class StorageTextureTests : public DawnTest {
wgpu::TextureCopyView textureCopyView;
textureCopyView.texture = outputTexture;
textureCopyView.arrayLayer = layer;
textureCopyView.origin.z = layer;
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copyExtent);
}
@ -652,7 +652,7 @@ class StorageTextureTests : public DawnTest {
for (uint32_t layer = 0; layer < arrayLayerCount; ++layer) {
wgpu::TextureCopyView textureCopyView;
textureCopyView.texture = writeonlyStorageTexture;
textureCopyView.arrayLayer = layer;
textureCopyView.origin.z = layer;
const uint64_t bufferOffset = kTextureBytesPerRowAlignment * kHeight * layer;
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(

View File

@ -269,7 +269,7 @@ class TextureFormatTest : public DawnTest {
{
wgpu::BufferCopyView bufferView = utils::CreateBufferCopyView(uploadBuffer, 0, 256, 0);
wgpu::TextureCopyView textureView =
utils::CreateTextureCopyView(sampleTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(sampleTexture, 0, {0, 0, 0});
wgpu::Extent3D extent{width, 1, 1};
encoder.CopyBufferToTexture(&bufferView, &textureView, &extent);
}
@ -285,7 +285,7 @@ class TextureFormatTest : public DawnTest {
wgpu::BufferCopyView bufferView =
utils::CreateBufferCopyView(readbackBuffer, 0, 256, 0);
wgpu::TextureCopyView textureView =
utils::CreateTextureCopyView(renderTarget, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(renderTarget, 0, {0, 0, 0});
wgpu::Extent3D extent{width, 1, 1};
encoder.CopyTextureToBuffer(&textureView, &bufferView, &extent);
}

View File

@ -136,7 +136,7 @@ protected:
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, kTextureBytesPerRowAlignment, 0);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(mTexture, level, layer, {0, 0, 0});
utils::CreateTextureCopyView(mTexture, level, {0, 0, layer});
wgpu::Extent3D copySize = {texWidth, texHeight, 1};
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
}

View File

@ -232,7 +232,7 @@ TEST_P(TextureZeroInitTest, CopyBufferToTexture) {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, kSize * sizeof(uint32_t), 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -263,7 +263,7 @@ TEST_P(TextureZeroInitTest, CopyBufferToTextureHalf) {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, kSize * sizeof(uint16_t), 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize / 2, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -289,7 +289,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
wgpu::Texture srcTexture = device.CreateTexture(&srcDescriptor);
wgpu::TextureCopyView srcTextureCopyView =
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(srcTexture, 0, {0, 0, 0});
wgpu::TextureDescriptor dstDescriptor =
CreateTextureDescriptor(1, 1,
@ -299,7 +299,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
wgpu::Texture dstTexture = device.CreateTexture(&dstDescriptor);
wgpu::TextureCopyView dstTextureCopyView =
utils::CreateTextureCopyView(dstTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(dstTexture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize, kSize, 1};
@ -335,7 +335,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, kSize * kFormatBlockByteSize, 0);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(srcTexture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
@ -344,7 +344,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
}
wgpu::TextureCopyView srcTextureCopyView =
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(srcTexture, 0, {0, 0, 0});
wgpu::TextureDescriptor dstDescriptor =
CreateTextureDescriptor(1, 1,
@ -354,7 +354,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
wgpu::Texture dstTexture = device.CreateTexture(&dstDescriptor);
wgpu::TextureCopyView dstTextureCopyView =
utils::CreateTextureCopyView(dstTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(dstTexture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize / 2, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -647,7 +647,7 @@ TEST_P(TextureZeroInitTest, NonRenderableTextureClear) {
device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, bytesPerRow, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -678,7 +678,7 @@ TEST_P(TextureZeroInitTest, NonRenderableTextureClearUnalignedSize) {
wgpu::Buffer bufferDst = utils::CreateBufferFromData(
device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, bytesPerRow, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kUnalignedSize, kUnalignedSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -708,7 +708,7 @@ TEST_P(TextureZeroInitTest, NonRenderableTextureClearWithMultiArrayLayers) {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(bufferDst, 0, kSize * kFormatBlockByteSize, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 1, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 1});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -746,7 +746,7 @@ TEST_P(TextureZeroInitTest, RenderPassStoreOpClear) {
device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, kSize * kFormatBlockByteSize, 0);
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
@ -895,7 +895,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedMip) {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, mipSize * kFormatBlockByteSize, 0);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(sampleTexture, 1, 0, {0, 0, 0});
utils::CreateTextureCopyView(sampleTexture, 1, {0, 0, 0});
wgpu::Extent3D copySize = {mipSize, mipSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
@ -973,7 +973,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedArrayLayer) {
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(stagingBuffer, 0, kSize * kFormatBlockByteSize, 0);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(sampleTexture, 0, 1, {0, 0, 0});
utils::CreateTextureCopyView(sampleTexture, 0, {0, 0, 1});
wgpu::Extent3D copySize = {kSize, kSize, 1};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize);
@ -1052,8 +1052,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferNonRenderableUnaligned) {
bufferDesc.usage = wgpu::BufferUsage::CopyDst;
wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(buffer, 0, bytesPerRow, 0);
wgpu::Extent3D copySize = {kUnalignedSize, kUnalignedSize, 1};

View File

@ -1316,8 +1316,8 @@ namespace {
wgpu::TextureView view0 = texture0.CreateView();
wgpu::TextureView view1 = texture1.CreateView();
wgpu::TextureCopyView srcView = utils::CreateTextureCopyView(texture0, 0, 0, {0, 0, 0});
wgpu::TextureCopyView dstView = utils::CreateTextureCopyView(texture1, 0, 0, {0, 0, 0});
wgpu::TextureCopyView srcView = utils::CreateTextureCopyView(texture0, 0, {0, 0, 0});
wgpu::TextureCopyView dstView = utils::CreateTextureCopyView(texture1, 0, {0, 0, 0});
wgpu::Extent3D copySize = {1, 1, 1};
// Use the texture as both copy dst and output attachment in render pass

View File

@ -808,7 +808,7 @@ namespace dawn_native { namespace vulkan {
wgpu::BufferCopyView copySrc =
utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0);
wgpu::TextureCopyView copyDst =
utils::CreateTextureCopyView(wrappedTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(wrappedTexture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {width, height, 1};
wgpu::CommandEncoder encoder = secondDevice.CreateCommandEncoder();
@ -832,7 +832,7 @@ namespace dawn_native { namespace vulkan {
wgpu::Buffer copyDstBuffer = device.CreateBuffer(&copyDesc);
{
wgpu::TextureCopyView copySrc =
utils::CreateTextureCopyView(nextWrappedTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(nextWrappedTexture, 0, {0, 0, 0});
wgpu::BufferCopyView copyDst =
utils::CreateBufferCopyView(copyDstBuffer, 0, bytesPerRow, 0);

View File

@ -986,7 +986,7 @@ namespace dawn_native { namespace vulkan {
wgpu::BufferCopyView copySrc =
utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0);
wgpu::TextureCopyView copyDst =
utils::CreateTextureCopyView(wrappedTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(wrappedTexture, 0, {0, 0, 0});
wgpu::Extent3D copySize = {width, height, 1};
wgpu::CommandEncoder encoder = secondDevice.CreateCommandEncoder();
@ -1010,7 +1010,7 @@ namespace dawn_native { namespace vulkan {
wgpu::Buffer copyDstBuffer = device.CreateBuffer(&copyDesc);
{
wgpu::TextureCopyView copySrc =
utils::CreateTextureCopyView(nextWrappedTexture, 0, 0, {0, 0, 0});
utils::CreateTextureCopyView(nextWrappedTexture, 0, {0, 0, 0});
wgpu::BufferCopyView copyDst =
utils::CreateBufferCopyView(copyDstBuffer, 0, bytesPerRow, 0);

View File

@ -276,12 +276,10 @@ namespace utils {
wgpu::TextureCopyView CreateTextureCopyView(wgpu::Texture texture,
uint32_t mipLevel,
uint32_t arrayLayer,
wgpu::Origin3D origin) {
wgpu::TextureCopyView textureCopyView;
textureCopyView.texture = texture;
textureCopyView.mipLevel = mipLevel;
textureCopyView.arrayLayer = arrayLayer;
textureCopyView.origin = origin;
return textureCopyView;

View File

@ -53,7 +53,6 @@ namespace utils {
uint32_t rowsPerImage);
wgpu::TextureCopyView CreateTextureCopyView(wgpu::Texture texture,
uint32_t level,
uint32_t slice,
wgpu::Origin3D origin);
struct ComboRenderPassDescriptor : public wgpu::RenderPassDescriptor {