Remove deprecated array layer descriptor members

- wgpu::TextureDescriptor::arrayLayerCount
 - wgpu::TextureCopyView::arrayLayer

Bug: dawn:22

Change-Id: I41a8b50c667f28c2496e0ad2e1d4ca655bf6c154
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26700
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2020-08-13 14:38:48 +00:00 committed by Commit Bot service account
parent 2b1c0b0e92
commit e236f7df27
13 changed files with 0 additions and 309 deletions

View File

@ -1591,7 +1591,6 @@
"members": [
{"name": "texture", "type": "texture"},
{"name": "mip level", "type": "uint32_t", "default": "0"},
{"name": "array layer", "type": "uint32_t", "default": "0"},
{"name": "origin", "type": "origin 3D"},
{"name": "aspect", "type": "texture aspect", "default": "all"}
]
@ -1613,7 +1612,6 @@
{"name": "usage", "type": "texture usage"},
{"name": "dimension", "type": "texture dimension", "default": "2D"},
{"name": "size", "type": "extent 3D"},
{"name": "array layer count", "type": "uint32_t", "default": "1"},
{"name": "format", "type": "texture format"},
{"name": "mip level count", "type": "uint32_t", "default": 1},
{"name": "sample count", "type": "uint32_t", "default": 1}

View File

@ -668,12 +668,6 @@ namespace dawn_native {
const TextureCopyView* destination,
const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
// TODO(crbug.com/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;
// TODO(crbug.com/dawn/22): Remove once migration to .layout is done.
BufferCopyView fixedSource;
DAWN_TRY_ASSIGN(fixedSource, FixBufferCopyView(GetDevice(), source));
@ -738,12 +732,6 @@ namespace dawn_native {
const BufferCopyView* destination,
const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
// TODO(crbug.com/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;
// TODO(crbug.com/dawn/22): Remove once migration to .layout is done.
BufferCopyView fixedDst;
DAWN_TRY_ASSIGN(fixedDst, FixBufferCopyView(GetDevice(), destination));
@ -805,15 +793,6 @@ namespace dawn_native {
const TextureCopyView* destination,
const Extent3D* copySize) {
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
// TODO(crbug.com/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));

View File

@ -1030,13 +1030,6 @@ namespace dawn_native {
ResultOrError<Ref<TextureBase>> DeviceBase::CreateTextureInternal(
const TextureDescriptor* descriptor) {
DAWN_TRY(ValidateIsAlive());
// TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to
// GPUTextureDescriptor.size.depth is done.
TextureDescriptor fixedDescriptor;
DAWN_TRY_ASSIGN(fixedDescriptor, FixTextureDescriptor(this, descriptor));
descriptor = &fixedDescriptor;
if (IsValidationEnabled()) {
DAWN_TRY(ValidateTextureDescriptor(this, descriptor));
}

View File

@ -146,12 +146,6 @@ namespace dawn_native {
size_t dataSize,
const TextureDataLayout* dataLayout,
const Extent3D* writeSize) {
// TODO(crbug.com/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;
DAWN_TRY(ValidateWriteTexture(destination, dataSize, dataLayout, writeSize));
if (writeSize->width == 0 || writeSize->height == 0 || writeSize->depth == 0) {

View File

@ -333,25 +333,6 @@ namespace dawn_native {
return desc;
}
ResultOrError<TextureDescriptor> FixTextureDescriptor(DeviceBase* device,
const TextureDescriptor* desc) {
TextureDescriptor fixedDesc = *desc;
if (desc->arrayLayerCount >= 2) {
if (desc->size.depth != 1) {
return DAWN_VALIDATION_ERROR("arrayLayerCount and size.depth cannot both be set.");
} else {
fixedDesc.size.depth = fixedDesc.arrayLayerCount;
fixedDesc.arrayLayerCount = 1;
device->EmitDeprecationWarning(
"wgpu::TextureDescriptor::arrayLayerCount is deprecated in favor of "
"::size::depth");
}
}
return {std::move(fixedDesc)};
}
bool IsValidSampleCount(uint32_t sampleCount) {
switch (sampleCount) {
case 1:
@ -696,23 +677,4 @@ namespace dawn_native {
return mRange;
}
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 dawn_native

View File

@ -64,11 +64,6 @@ namespace dawn_native {
const TextureBase* texture,
const TextureViewDescriptor* descriptor);
// TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to
// GPUTextureDescriptor.size.depth is done.
ResultOrError<TextureDescriptor> FixTextureDescriptor(DeviceBase* device,
const TextureDescriptor* desc);
bool IsValidSampleCount(uint32_t sampleCount);
static constexpr wgpu::TextureUsage kReadOnlyTextureUsages =
@ -189,9 +184,6 @@ namespace dawn_native {
SubresourceRange mRange;
};
ResultOrError<TextureCopyView> FixTextureCopyView(DeviceBase* device,
const TextureCopyView* view);
} // namespace dawn_native
#endif // DAWNNATIVE_TEXTURE_H_

View File

@ -394,12 +394,6 @@ namespace dawn_native { namespace d3d12 {
const TextureDescriptor* textureDescriptor =
reinterpret_cast<const TextureDescriptor*>(descriptor->cTextureDescriptor);
// TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to
// GPUTextureDescriptor.size.depth is done.
TextureDescriptor fixedDescriptor;
DAWN_TRY_ASSIGN(fixedDescriptor, FixTextureDescriptor(device, textureDescriptor));
textureDescriptor = &fixedDescriptor;
Ref<Texture> dawnTexture =
AcquireRef(new Texture(device, textureDescriptor, TextureState::OwnedExternal));
DAWN_TRY(dawnTexture->InitializeAsExternalTexture(textureDescriptor, sharedHandle,

View File

@ -325,14 +325,6 @@ namespace dawn_native { namespace metal {
const TextureDescriptor* textureDescriptor =
reinterpret_cast<const TextureDescriptor*>(descriptor->cTextureDescriptor);
// TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to
// GPUTextureDescriptor.size.depth is done.
TextureDescriptor fixedDescriptor;
if (ConsumedError(FixTextureDescriptor(this, textureDescriptor), &fixedDescriptor)) {
return nullptr;
}
textureDescriptor = &fixedDescriptor;
if (ConsumedError(ValidateTextureDescriptor(this, textureDescriptor))) {
return nullptr;
}

View File

@ -661,12 +661,6 @@ namespace dawn_native { namespace vulkan {
const TextureDescriptor* textureDescriptor =
reinterpret_cast<const TextureDescriptor*>(descriptor->cTextureDescriptor);
// TODO(dawn:22): Remove once migration from GPUTextureDescriptor.arrayLayerCount to
// GPUTextureDescriptor.size.depth is done.
TextureDescriptor fixedDescriptor;
DAWN_TRY_ASSIGN(fixedDescriptor, FixTextureDescriptor(this, textureDescriptor));
textureDescriptor = &fixedDescriptor;
// Check services support this combination of handle type / image info
if (!mExternalSemaphoreService->Supported()) {
return DAWN_VALIDATION_ERROR("External semaphore usage not supported");

View File

@ -82,70 +82,6 @@ TEST_P(DeprecationTests, SetSubDataStillWorks) {
EXPECT_BUFFER_U32_EQ(data, buffer, 0);
}
// Test that using TextureDescriptor::arrayLayerCount emits a warning.
TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountDeprecated) {
wgpu::TextureDescriptor desc;
desc.usage = wgpu::TextureUsage::Sampled;
desc.dimension = wgpu::TextureDimension::e2D;
desc.size = {1, 1, 1};
desc.arrayLayerCount = 2;
desc.format = wgpu::TextureFormat::RGBA8Unorm;
desc.mipLevelCount = 1;
desc.sampleCount = 1;
EXPECT_DEPRECATION_WARNING(device.CreateTexture(&desc));
}
// Test that using both TextureDescriptor::arrayLayerCount and size.depth triggers an error.
TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountAndDepthSizeIsError) {
wgpu::TextureDescriptor desc;
desc.usage = wgpu::TextureUsage::Sampled;
desc.dimension = wgpu::TextureDimension::e2D;
desc.size = {1, 1, 2};
desc.arrayLayerCount = 2;
desc.format = wgpu::TextureFormat::RGBA8Unorm;
desc.mipLevelCount = 1;
desc.sampleCount = 1;
ASSERT_DEVICE_ERROR(device.CreateTexture(&desc));
}
// Test that TextureDescriptor::arrayLayerCount does correct state tracking.
TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountStateTracking) {
wgpu::TextureDescriptor desc;
desc.usage = wgpu::TextureUsage::Sampled;
desc.dimension = wgpu::TextureDimension::e2D;
desc.size = {1, 1, 1};
desc.arrayLayerCount = 2;
desc.format = wgpu::TextureFormat::RGBA8Unorm;
desc.mipLevelCount = 1;
desc.sampleCount = 1;
wgpu::Texture texture;
EXPECT_DEPRECATION_WARNING(texture = device.CreateTexture(&desc));
wgpu::TextureViewDescriptor viewDesc;
viewDesc.dimension = wgpu::TextureViewDimension::e2DArray;
viewDesc.arrayLayerCount = 2;
texture.CreateView(&viewDesc);
viewDesc.arrayLayerCount = 3;
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDesc));
}
// Test that using TextureDescriptor::arrayLayerCount = 0 is allowed
TEST_P(DeprecationTests, TextureDescriptorArrayLayerCountZero) {
wgpu::TextureDescriptor desc;
desc.usage = wgpu::TextureUsage::Sampled;
desc.dimension = wgpu::TextureDimension::e2D;
desc.size = {1, 1, 1};
desc.arrayLayerCount = 0;
desc.format = wgpu::TextureFormat::RGBA8Unorm;
desc.mipLevelCount = 1;
desc.sampleCount = 1;
device.CreateTexture(&desc);
}
DAWN_INSTANTIATE_TEST(DeprecationTests,
D3D12Backend(),
MetalBackend(),
@ -153,141 +89,6 @@ DAWN_INSTANTIATE_TEST(DeprecationTests,
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.layout.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);
// 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.
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());
// 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 = MakeOldTextureCopyView();
texOOBCopy.arrayLayer = 2; // Oh no, it is OOB!
wgpu::TextureCopyView texNewCopy = MakeNewTextureCopyView();
wgpu::BufferCopyView bufCopy = MakeBufferCopyView();
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
EXPECT_DEPRECATION_WARNING(encoder.CopyBufferToTexture(&bufCopy, &texOOBCopy, &copySize));
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToTexture(&texNewCopy, &texOOBCopy, &copySize));
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToBuffer(&texOOBCopy, &bufCopy, &copySize));
ASSERT_DEVICE_ERROR(encoder.Finish());
encoder = device.CreateCommandEncoder();
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,
D3D12Backend(),
MetalBackend(),
NullBackend(),
OpenGLBackend(),
VulkanBackend());
class BufferCopyViewDeprecationTests : public DeprecationTests {
protected:
wgpu::TextureCopyView MakeTextureCopyView() {
@ -299,7 +100,6 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
wgpu::TextureCopyView copy;
copy.texture = device.CreateTexture(&desc);
copy.arrayLayer = 0;
copy.origin = {0, 0, 1};
return copy;
}

View File

@ -66,7 +66,6 @@ class D3D12DescriptorHeapTests : public DawnTest {
descriptor.size.width = width;
descriptor.size.height = height;
descriptor.size.depth = 1;
descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1;
descriptor.format = format;
descriptor.mipLevelCount = 1;
@ -732,7 +731,6 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
descriptor.size.width = kRTSize;
descriptor.size.height = kRTSize;
descriptor.size.depth = 1;
descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1;
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
descriptor.mipLevelCount = 1;

View File

@ -50,7 +50,6 @@ TEST_P(D3D12SmallTextureTests, AlignSmallCompressedTexture) {
descriptor.size.width = 8;
descriptor.size.height = 8;
descriptor.size.depth = 1;
descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1;
descriptor.format = wgpu::TextureFormat::BC1RGBAUnorm;
descriptor.mipLevelCount = 1;

View File

@ -373,7 +373,6 @@ namespace dawn_native { namespace vulkan {
defaultDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
defaultDescriptor.size = {1, 1, 1};
defaultDescriptor.sampleCount = 1;
defaultDescriptor.arrayLayerCount = 1;
defaultDescriptor.mipLevelCount = 1;
defaultDescriptor.usage = wgpu::TextureUsage::OutputAttachment |
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst;
@ -432,13 +431,11 @@ namespace dawn_native { namespace vulkan {
wgpu::TextureCopyView copySrc;
copySrc.texture = source;
copySrc.mipLevel = 0;
copySrc.arrayLayer = 0;
copySrc.origin = {0, 0, 0};
wgpu::TextureCopyView copyDst;
copyDst.texture = destination;
copyDst.mipLevel = 0;
copyDst.arrayLayer = 0;
copyDst.origin = {0, 0, 0};
wgpu::Extent3D copySize = {1, 1, 1};
@ -918,7 +915,6 @@ namespace dawn_native { namespace vulkan {
descriptor.size.width = 640;
descriptor.size.height = 480;
descriptor.size.depth = 1;
descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1;
descriptor.format = wgpu::TextureFormat::BGRA8Unorm;
descriptor.mipLevelCount = 1;