Commit 253994c9 authored by Kai Ninomiya's avatar Kai Ninomiya Committed by Commit Bot

Support GPUBufferCopyView.{bytesPerRow,rowsPerImage}

Deprecates GPUBufferCopyView.{rowPitch,imageHeight}.

Bug: 1069302
Change-Id: Ib756ac5402c4da53e2ba02dc7f298290e5b4e8f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143376Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757996}
parent 8af89d1f
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
dictionary GPUBufferCopyView { dictionary GPUBufferCopyView {
required GPUBuffer buffer; required GPUBuffer buffer;
GPUBufferSize offset = 0; GPUBufferSize offset = 0;
required unsigned long rowPitch;
required unsigned long imageHeight; // TODO(crbug.com/1069302): rowPitch is deprecated; remove it, make bytesPerRow required.
unsigned long bytesPerRow;
unsigned long rowPitch;
unsigned long rowsPerImage = 0;
// TODO(crbug.com/1069302): imageHeight is deprecated; remove it.
unsigned long imageHeight;
}; };
...@@ -108,7 +108,10 @@ WGPURenderPassDepthStencilAttachmentDescriptor AsDawnType( ...@@ -108,7 +108,10 @@ WGPURenderPassDepthStencilAttachmentDescriptor AsDawnType(
return dawn_desc; return dawn_desc;
} }
WGPUBufferCopyView AsDawnType(const GPUBufferCopyView* webgpu_view) { base::Optional<WGPUBufferCopyView> AsDawnType(
const GPUBufferCopyView* webgpu_view,
GPUDevice* device,
ExceptionState& exception_state) {
DCHECK(webgpu_view); DCHECK(webgpu_view);
DCHECK(webgpu_view->buffer()); DCHECK(webgpu_view->buffer());
...@@ -116,8 +119,31 @@ WGPUBufferCopyView AsDawnType(const GPUBufferCopyView* webgpu_view) { ...@@ -116,8 +119,31 @@ WGPUBufferCopyView AsDawnType(const GPUBufferCopyView* webgpu_view) {
dawn_view.nextInChain = nullptr; dawn_view.nextInChain = nullptr;
dawn_view.buffer = webgpu_view->buffer()->GetHandle(); dawn_view.buffer = webgpu_view->buffer()->GetHandle();
dawn_view.offset = webgpu_view->offset(); dawn_view.offset = webgpu_view->offset();
dawn_view.rowPitch = webgpu_view->rowPitch();
dawn_view.imageHeight = webgpu_view->imageHeight(); if (webgpu_view->hasRowPitch()) {
device->AddConsoleWarning(
"GPUBufferCopyView.rowPitch is deprecated: renamed to bytesPerRow");
}
if (webgpu_view->hasBytesPerRow()) {
dawn_view.rowPitch = webgpu_view->bytesPerRow();
} else {
if (!webgpu_view->hasRowPitch()) {
exception_state.ThrowTypeError(
"required member bytesPerRow is undefined.");
return base::nullopt;
}
dawn_view.rowPitch = webgpu_view->rowPitch();
}
// Note: in this case we check for the deprecated member first, because it is
// required, while the new member is optional.
if (webgpu_view->hasImageHeight()) {
device->AddConsoleWarning(
"GPUBufferCopyView.imageHeight is deprecated: renamed to rowsPerImage");
dawn_view.imageHeight = webgpu_view->imageHeight();
} else {
dawn_view.imageHeight = webgpu_view->rowsPerImage();
}
return dawn_view; return dawn_view;
} }
...@@ -251,12 +277,16 @@ void GPUCommandEncoder::copyBufferToTexture( ...@@ -251,12 +277,16 @@ void GPUCommandEncoder::copyBufferToTexture(
return; return;
} }
WGPUBufferCopyView dawn_source = AsDawnType(source); base::Optional<WGPUBufferCopyView> dawn_source =
AsDawnType(source, device_, exception_state);
if (!dawn_source) {
return;
}
WGPUTextureCopyView dawn_destination = AsDawnType(destination); WGPUTextureCopyView dawn_destination = AsDawnType(destination);
WGPUExtent3D dawn_copy_size = AsDawnType(&copy_size); WGPUExtent3D dawn_copy_size = AsDawnType(&copy_size);
GetProcs().commandEncoderCopyBufferToTexture( GetProcs().commandEncoderCopyBufferToTexture(
GetHandle(), &dawn_source, &dawn_destination, &dawn_copy_size); GetHandle(), &*dawn_source, &dawn_destination, &dawn_copy_size);
} }
void GPUCommandEncoder::copyTextureToBuffer( void GPUCommandEncoder::copyTextureToBuffer(
...@@ -270,11 +300,15 @@ void GPUCommandEncoder::copyTextureToBuffer( ...@@ -270,11 +300,15 @@ void GPUCommandEncoder::copyTextureToBuffer(
} }
WGPUTextureCopyView dawn_source = AsDawnType(source); WGPUTextureCopyView dawn_source = AsDawnType(source);
WGPUBufferCopyView dawn_destination = AsDawnType(destination); base::Optional<WGPUBufferCopyView> dawn_destination =
AsDawnType(destination, device_, exception_state);
if (!dawn_destination) {
return;
}
WGPUExtent3D dawn_copy_size = AsDawnType(&copy_size); WGPUExtent3D dawn_copy_size = AsDawnType(&copy_size);
GetProcs().commandEncoderCopyTextureToBuffer( GetProcs().commandEncoderCopyTextureToBuffer(
GetHandle(), &dawn_source, &dawn_destination, &dawn_copy_size); GetHandle(), &dawn_source, &*dawn_destination, &dawn_copy_size);
} }
void GPUCommandEncoder::copyTextureToTexture( void GPUCommandEncoder::copyTextureToTexture(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment