Remove deprecated wgpu::BufferCopyView members
Bug: dawn:22 Change-Id: Iec26e9945443411a8f322a80d7e63c96c74f3508 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26702 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
d315022be5
commit
24b5971b84
|
@ -228,10 +228,7 @@
|
||||||
"extensible": true,
|
"extensible": true,
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "layout", "type": "texture data layout"},
|
{"name": "layout", "type": "texture data layout"},
|
||||||
{"name": "buffer", "type": "buffer"},
|
{"name": "buffer", "type": "buffer"}
|
||||||
{"name": "offset", "type": "uint64_t", "default": 0},
|
|
||||||
{"name": "bytes per row", "type": "uint32_t"},
|
|
||||||
{"name": "rows per image", "type": "uint32_t", "default": 0}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"buffer descriptor": {
|
"buffer descriptor": {
|
||||||
|
|
|
@ -437,35 +437,6 @@ namespace dawn_native {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<BufferCopyView> FixBufferCopyView(DeviceBase* device,
|
|
||||||
const BufferCopyView* view) {
|
|
||||||
BufferCopyView fixedView = *view;
|
|
||||||
|
|
||||||
TextureDataLayout& layout = fixedView.layout;
|
|
||||||
if (layout.offset != 0 || layout.bytesPerRow != 0 || layout.rowsPerImage != 0) {
|
|
||||||
// Using non-deprecated path
|
|
||||||
if (fixedView.offset != 0 || fixedView.bytesPerRow != 0 ||
|
|
||||||
fixedView.rowsPerImage != 0) {
|
|
||||||
return DAWN_VALIDATION_ERROR(
|
|
||||||
"WGPUBufferCopyView.offset/bytesPerRow/rowsPerImage is deprecated; use "
|
|
||||||
"only WGPUBufferCopyView.layout");
|
|
||||||
}
|
|
||||||
} else if (fixedView.offset != 0 || fixedView.bytesPerRow != 0 ||
|
|
||||||
fixedView.rowsPerImage != 0) {
|
|
||||||
device->EmitDeprecationWarning(
|
|
||||||
"WGPUBufferCopyView.offset/bytesPerRow/rowsPerImage is deprecated; use "
|
|
||||||
"WGPUBufferCopyView.layout");
|
|
||||||
|
|
||||||
layout.offset = fixedView.offset;
|
|
||||||
layout.bytesPerRow = fixedView.bytesPerRow;
|
|
||||||
layout.rowsPerImage = fixedView.rowsPerImage;
|
|
||||||
fixedView.offset = 0;
|
|
||||||
fixedView.bytesPerRow = 0;
|
|
||||||
fixedView.rowsPerImage = 0;
|
|
||||||
}
|
|
||||||
return fixedView;
|
|
||||||
}
|
|
||||||
|
|
||||||
MaybeError ValidateQuerySetResolve(const QuerySetBase* querySet,
|
MaybeError ValidateQuerySetResolve(const QuerySetBase* querySet,
|
||||||
uint32_t firstQuery,
|
uint32_t firstQuery,
|
||||||
uint32_t queryCount,
|
uint32_t queryCount,
|
||||||
|
@ -668,11 +639,6 @@ namespace dawn_native {
|
||||||
const TextureCopyView* destination,
|
const TextureCopyView* destination,
|
||||||
const Extent3D* copySize) {
|
const Extent3D* copySize) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
// TODO(crbug.com/dawn/22): Remove once migration to .layout is done.
|
|
||||||
BufferCopyView fixedSource;
|
|
||||||
DAWN_TRY_ASSIGN(fixedSource, FixBufferCopyView(GetDevice(), source));
|
|
||||||
source = &fixedSource;
|
|
||||||
|
|
||||||
if (GetDevice()->IsValidationEnabled()) {
|
if (GetDevice()->IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateBufferCopyView(GetDevice(), *source));
|
DAWN_TRY(ValidateBufferCopyView(GetDevice(), *source));
|
||||||
DAWN_TRY(ValidateCanUseAs(source->buffer, wgpu::BufferUsage::CopySrc));
|
DAWN_TRY(ValidateCanUseAs(source->buffer, wgpu::BufferUsage::CopySrc));
|
||||||
|
@ -732,11 +698,6 @@ namespace dawn_native {
|
||||||
const BufferCopyView* destination,
|
const BufferCopyView* destination,
|
||||||
const Extent3D* copySize) {
|
const Extent3D* copySize) {
|
||||||
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
mEncodingContext.TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||||
// TODO(crbug.com/dawn/22): Remove once migration to .layout is done.
|
|
||||||
BufferCopyView fixedDst;
|
|
||||||
DAWN_TRY_ASSIGN(fixedDst, FixBufferCopyView(GetDevice(), destination));
|
|
||||||
destination = &fixedDst;
|
|
||||||
|
|
||||||
if (GetDevice()->IsValidationEnabled()) {
|
if (GetDevice()->IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateTextureCopyView(GetDevice(), *source));
|
DAWN_TRY(ValidateTextureCopyView(GetDevice(), *source));
|
||||||
DAWN_TRY(ValidateCanUseAs(source->texture, wgpu::TextureUsage::CopySrc));
|
DAWN_TRY(ValidateCanUseAs(source->texture, wgpu::TextureUsage::CopySrc));
|
||||||
|
|
|
@ -473,10 +473,6 @@ namespace dawn_native {
|
||||||
|
|
||||||
MaybeError ValidateBufferCopyView(DeviceBase const* device,
|
MaybeError ValidateBufferCopyView(DeviceBase const* device,
|
||||||
const BufferCopyView& bufferCopyView) {
|
const BufferCopyView& bufferCopyView) {
|
||||||
// Should have already been fixed up to not use deprecated fields.
|
|
||||||
ASSERT(bufferCopyView.offset == 0 && bufferCopyView.bytesPerRow == 0 &&
|
|
||||||
bufferCopyView.rowsPerImage == 0);
|
|
||||||
|
|
||||||
DAWN_TRY(device->ValidateObject(bufferCopyView.buffer));
|
DAWN_TRY(device->ValidateObject(bufferCopyView.buffer));
|
||||||
if (bufferCopyView.layout.bytesPerRow % kTextureBytesPerRowAlignment != 0) {
|
if (bufferCopyView.layout.bytesPerRow % kTextureBytesPerRowAlignment != 0) {
|
||||||
return DAWN_VALIDATION_ERROR("bytesPerRow must be a multiple of 256");
|
return DAWN_VALIDATION_ERROR("bytesPerRow must be a multiple of 256");
|
||||||
|
|
|
@ -1119,7 +1119,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
|
||||||
utils::CreateBufferFromData(device, wgpu::BufferUsage::CopySrc, {expectedValue});
|
utils::CreateBufferFromData(device, wgpu::BufferUsage::CopySrc, {expectedValue});
|
||||||
wgpu::BufferCopyView bufferCopyView = {};
|
wgpu::BufferCopyView bufferCopyView = {};
|
||||||
bufferCopyView.buffer = textureData;
|
bufferCopyView.buffer = textureData;
|
||||||
bufferCopyView.bytesPerRow = 256;
|
bufferCopyView.layout.bytesPerRow = 256;
|
||||||
|
|
||||||
wgpu::TextureCopyView textureCopyView = {};
|
wgpu::TextureCopyView textureCopyView = {};
|
||||||
textureCopyView.texture = texture;
|
textureCopyView.texture = texture;
|
||||||
|
|
|
@ -82,96 +82,3 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
|
||||||
|
|
||||||
wgpu::Extent3D copySize = {1, 1, 1};
|
wgpu::Extent3D copySize = {1, 1, 1};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test that using BufferCopyView::{offset,bytesPerRow,rowsPerImage} emits a warning.
|
|
||||||
TEST_P(BufferCopyViewDeprecationTests, DeprecationWarning) {
|
|
||||||
wgpu::BufferDescriptor desc;
|
|
||||||
desc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
|
||||||
desc.size = 8;
|
|
||||||
wgpu::Buffer buffer = device.CreateBuffer(&desc);
|
|
||||||
|
|
||||||
wgpu::TextureCopyView texCopy = MakeTextureCopyView();
|
|
||||||
|
|
||||||
{
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
||||||
wgpu::BufferCopyView bufCopy = {};
|
|
||||||
bufCopy.buffer = buffer;
|
|
||||||
bufCopy.offset = 4;
|
|
||||||
EXPECT_DEPRECATION_WARNING(encoder.CopyBufferToTexture(&bufCopy, &texCopy, ©Size));
|
|
||||||
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToBuffer(&texCopy, &bufCopy, ©Size));
|
|
||||||
wgpu::CommandBuffer command = encoder.Finish();
|
|
||||||
queue.Submit(1, &command);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
||||||
wgpu::BufferCopyView bufCopy = {};
|
|
||||||
bufCopy.buffer = buffer;
|
|
||||||
bufCopy.bytesPerRow = 128;
|
|
||||||
EXPECT_DEPRECATION_WARNING(encoder.CopyBufferToTexture(&bufCopy, &texCopy, ©Size));
|
|
||||||
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToBuffer(&texCopy, &bufCopy, ©Size));
|
|
||||||
// Since bytesPerRow is not 256-aligned.
|
|
||||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
||||||
wgpu::BufferCopyView bufCopy = {};
|
|
||||||
bufCopy.buffer = buffer;
|
|
||||||
bufCopy.rowsPerImage = 1;
|
|
||||||
EXPECT_DEPRECATION_WARNING(encoder.CopyBufferToTexture(&bufCopy, &texCopy, ©Size));
|
|
||||||
EXPECT_DEPRECATION_WARNING(encoder.CopyTextureToBuffer(&texCopy, &bufCopy, ©Size));
|
|
||||||
wgpu::CommandBuffer command = encoder.Finish();
|
|
||||||
queue.Submit(1, &command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test that using both any old field and any new field is an error
|
|
||||||
TEST_P(BufferCopyViewDeprecationTests, BothOldAndNew) {
|
|
||||||
wgpu::BufferDescriptor desc;
|
|
||||||
desc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
|
||||||
desc.size = 8;
|
|
||||||
wgpu::Buffer buffer = device.CreateBuffer(&desc);
|
|
||||||
|
|
||||||
wgpu::TextureCopyView texCopy = MakeTextureCopyView();
|
|
||||||
|
|
||||||
auto testOne = [=](const wgpu::BufferCopyView& bufCopy) {
|
|
||||||
{
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
||||||
encoder.CopyBufferToTexture(&bufCopy, &texCopy, ©Size);
|
|
||||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
||||||
encoder.CopyTextureToBuffer(&texCopy, &bufCopy, ©Size);
|
|
||||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
|
||||||
wgpu::BufferCopyView bufCopy = {};
|
|
||||||
bufCopy.buffer = buffer;
|
|
||||||
bufCopy.layout.bytesPerRow = kTextureBytesPerRowAlignment;
|
|
||||||
{
|
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
||||||
encoder.CopyBufferToTexture(&bufCopy, &texCopy, ©Size);
|
|
||||||
encoder.CopyTextureToBuffer(&texCopy, &bufCopy, ©Size);
|
|
||||||
wgpu::CommandBuffer command = encoder.Finish();
|
|
||||||
queue.Submit(1, &command);
|
|
||||||
}
|
|
||||||
|
|
||||||
bufCopy.offset = 4;
|
|
||||||
testOne(bufCopy);
|
|
||||||
bufCopy.offset = 0;
|
|
||||||
bufCopy.bytesPerRow = kTextureBytesPerRowAlignment;
|
|
||||||
testOne(bufCopy);
|
|
||||||
bufCopy.bytesPerRow = 0;
|
|
||||||
bufCopy.rowsPerImage = 1;
|
|
||||||
testOne(bufCopy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(BufferCopyViewDeprecationTests,
|
|
||||||
D3D12Backend(),
|
|
||||||
MetalBackend(),
|
|
||||||
NullBackend(),
|
|
||||||
OpenGLBackend(),
|
|
||||||
VulkanBackend());
|
|
||||||
|
|
Loading…
Reference in New Issue