Fixing a deprecated arrayLayer value inside Queue::WriteTexture

Chromium always sends arrayLayer instead of origin.depth since
the migration hasn't been finished yet. This wasn't caught
in Dawn's testing since we are using origin.depth everywhere.

Bug: dawn:483
Change-Id: I13b1ccfb016eea01a3291ca439457db09966e9a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26160
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Tomek Ponitka <tommek@google.com>
This commit is contained in:
Tomek Ponitka
2020-08-03 09:11:52 +00:00
committed by Commit Bot service account
parent 8c201dfadc
commit eac38cfbc1
5 changed files with 56 additions and 24 deletions

View File

@@ -207,9 +207,17 @@ TEST_P(TextureCopyViewArrayLayerDeprecationTests, DeprecationWarning) {
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);
// TODO(dawn:483): Add other backends after implementing WriteTexture in them.
if (IsMetal() || IsVulkan()) {
std::vector<uint32_t> data = {1};
EXPECT_DEPRECATION_WARNING(
queue.WriteTexture(&texOldCopy, data.data(), 4, &bufCopy.layout, &copySize));
}
}
// Test that using both TextureCopyView::arrayLayer and origin.z is an error.
@@ -233,30 +241,44 @@ TEST_P(TextureCopyViewArrayLayerDeprecationTests, BothArrayLayerAndOriginZIsErro
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToTexture(&texErrorCopy, &texNewCopy, &copySize);
ASSERT_DEVICE_ERROR(encoder.Finish());
// TODO(dawn:483): Add other backends after implementing WriteTexture in them.
if (IsMetal() || IsVulkan()) {
std::vector<uint32_t> data = {1};
ASSERT_DEVICE_ERROR(
queue.WriteTexture(&texErrorCopy, data.data(), 4, &bufCopy.layout, &copySize));
}
}
// Test that using TextureCopyView::arrayLayer is correctly taken into account
TEST_P(TextureCopyViewArrayLayerDeprecationTests, StateTracking) {
wgpu::TextureCopyView texOOBCopy = MakeErrorTextureCopyView();
wgpu::TextureCopyView texOOBCopy = MakeOldTextureCopyView();
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);
EXPECT_DEPRECATION_WARNING(encoder.CopyBufferToTexture(&bufCopy, &texOOBCopy, &copySize));
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToTexture(&texNewCopy, &texOOBCopy, &copySize);
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToTexture(&texNewCopy, &texOOBCopy, &copySize));
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToBuffer(&texOOBCopy, &bufCopy, &copySize);
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToBuffer(&texOOBCopy, &bufCopy, &copySize));
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
encoder.CopyTextureToTexture(&texOOBCopy, &texNewCopy, &copySize);
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToTexture(&texOOBCopy, &texNewCopy, &copySize));
ASSERT_DEVICE_ERROR(encoder.Finish());
// TODO(dawn:483): Add other backends after implementing WriteTexture in them.
if (IsMetal() || IsVulkan()) {
std::vector<uint32_t> data = {1};
EXPECT_DEPRECATION_WARNING(ASSERT_DEVICE_ERROR(
queue.WriteTexture(&texOOBCopy, data.data(), 4, &bufCopy.layout, &copySize)));
}
}
DAWN_INSTANTIATE_TEST(TextureCopyViewArrayLayerDeprecationTests,