Commit 0fa034b2 authored by Kai Ninomiya's avatar Kai Ninomiya Committed by Commit Bot

WebGPU: remove deprecated items, split GPUTextureDataLayout, use USVString

According to upstream spec changes.

Bug: 1069302
Change-Id: I191528911b2d20a23e6438548b2c56be37721059
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2222298
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773779}
parent f4ba183b
......@@ -884,6 +884,7 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/webgpu/gpu_swap_chain_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture_copy_view.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture_data_layout.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture_usage.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture_view.idl",
......
......@@ -99,8 +99,6 @@ bindings_modules_generated_union_type_files = [
"$bindings_modules_v8_output_dir/string_or_string_sequence_or_constrain_dom_string_parameters.h",
"$bindings_modules_v8_output_dir/string_or_unsigned_long.cc",
"$bindings_modules_v8_output_dir/string_or_unsigned_long.h",
"$bindings_modules_v8_output_dir/string_or_uint32_array.cc",
"$bindings_modules_v8_output_dir/string_or_uint32_array.h",
"$bindings_modules_v8_output_dir/unsigned_long_or_unsigned_long_sequence.cc",
"$bindings_modules_v8_output_dir/unsigned_long_or_unsigned_long_sequence.h",
"$bindings_modules_v8_output_dir/unsigned_long_enforce_range_sequence_or_gpu_extent_3d_dict.cc",
......@@ -109,6 +107,8 @@ bindings_modules_generated_union_type_files = [
"$bindings_modules_v8_output_dir/unsigned_long_enforce_range_sequence_or_gpu_origin_2d_dict.h",
"$bindings_modules_v8_output_dir/unsigned_long_enforce_range_sequence_or_gpu_origin_3d_dict.cc",
"$bindings_modules_v8_output_dir/unsigned_long_enforce_range_sequence_or_gpu_origin_3d_dict.h",
"$bindings_modules_v8_output_dir/usv_string_or_uint32_array.cc",
"$bindings_modules_v8_output_dir/usv_string_or_uint32_array.h",
"$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.cc",
"$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.h",
"$bindings_modules_v8_output_dir/worklet_animation_effect_or_worklet_group_effect.cc",
......
......@@ -51,24 +51,11 @@ GPUBindGroup* GPUBindGroup::Create(GPUDevice* device,
DCHECK(device);
DCHECK(webgpu_desc);
if (webgpu_desc->hasBindings()) {
device->AddConsoleWarning(
"GPUBindGroupDescriptor.bindings is deprecated: renamed to entries");
}
uint32_t entry_count = 0;
std::unique_ptr<WGPUBindGroupEntry[]> entries;
if (webgpu_desc->hasEntries()) {
entry_count = static_cast<uint32_t>(webgpu_desc->entries().size());
entries = entry_count != 0 ? AsDawnType(webgpu_desc->entries()) : nullptr;
} else {
if (!webgpu_desc->hasBindings()) {
exception_state.ThrowTypeError("required member entries is undefined.");
return nullptr;
}
entry_count = static_cast<uint32_t>(webgpu_desc->bindings().size());
entries = entry_count != 0 ? AsDawnType(webgpu_desc->bindings()) : nullptr;
entry_count = static_cast<uint32_t>(webgpu_desc->entries().size());
if (entry_count > 0) {
entries = AsDawnType(webgpu_desc->entries());
}
WGPUBindGroupDescriptor dawn_desc = {};
......
......@@ -6,8 +6,5 @@
dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
required GPUBindGroupLayout layout;
// TODO(crbug.com/1069302): bindings is deprecated; remove it, make entries required.
sequence<GPUBindGroupEntry> bindings;
sequence<GPUBindGroupEntry> entries;
required sequence<GPUBindGroupEntry> entries;
};
......@@ -21,20 +21,8 @@ WGPUBindGroupLayoutEntry AsDawnType(
dawn_binding.type = AsDawnEnum<WGPUBindingType>(webgpu_binding->type());
dawn_binding.visibility =
AsDawnEnum<WGPUShaderStage>(webgpu_binding->visibility());
// Note: in this case we check for the deprecated member first, because
// the new member is optional so we can't check for its presence.
if (webgpu_binding->hasTextureDimension()) {
device->AddConsoleWarning(
"GPUBindGroupLayoutEntry.textureDimension is deprecated: renamed to "
"viewDimension");
dawn_binding.viewDimension = AsDawnEnum<WGPUTextureViewDimension>(
webgpu_binding->textureDimension());
} else {
dawn_binding.viewDimension =
AsDawnEnum<WGPUTextureViewDimension>(webgpu_binding->viewDimension());
}
dawn_binding.viewDimension =
AsDawnEnum<WGPUTextureViewDimension>(webgpu_binding->viewDimension());
dawn_binding.textureComponentType = AsDawnEnum<WGPUTextureComponentType>(
webgpu_binding->textureComponentType());
dawn_binding.multisampled = webgpu_binding->multisampled();
......@@ -66,27 +54,11 @@ GPUBindGroupLayout* GPUBindGroupLayout::Create(
DCHECK(device);
DCHECK(webgpu_desc);
if (webgpu_desc->hasBindings()) {
device->AddConsoleWarning(
"GPUBindGroupLayoutDescriptor.bindings is deprecated: renamed to "
"entries");
}
uint32_t entry_count = 0;
std::unique_ptr<WGPUBindGroupLayoutEntry[]> entries;
if (webgpu_desc->hasEntries()) {
entry_count = static_cast<uint32_t>(webgpu_desc->entries().size());
entries =
entry_count != 0 ? AsDawnType(webgpu_desc->entries(), device) : nullptr;
} else {
if (!webgpu_desc->hasBindings()) {
exception_state.ThrowTypeError("required member entries is undefined.");
return nullptr;
}
entry_count = static_cast<uint32_t>(webgpu_desc->bindings().size());
entries = entry_count != 0 ? AsDawnType(webgpu_desc->bindings(), device)
: nullptr;
entry_count = static_cast<uint32_t>(webgpu_desc->entries().size());
if (entry_count > 0) {
entries = AsDawnType(webgpu_desc->entries(), device);
}
WGPUBindGroupLayoutDescriptor dawn_desc = {};
......
......@@ -5,7 +5,5 @@
// https://gpuweb.github.io/gpuweb/
dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
// TODO(crbug.com/1069302): bindings is deprecated; remove it, make entries required.
sequence<GPUBindGroupLayoutEntry> bindings;
sequence<GPUBindGroupLayoutEntry> entries;
required sequence<GPUBindGroupLayoutEntry> entries;
};
......@@ -9,8 +9,6 @@ dictionary GPUBindGroupLayoutEntry {
required GPUShaderStageFlags visibility;
required GPUBindingType type;
GPUTextureViewDimension viewDimension = "2d";
// TODO(crbug.com/1069302): textureDimension is deprecated; remove it.
GPUTextureViewDimension textureDimension;
GPUTextureComponentType textureComponentType = "float";
boolean multisampled = false;
boolean hasDynamicOffset = false;
......
......@@ -4,15 +4,6 @@
// https://gpuweb.github.io/gpuweb/
dictionary GPUBufferCopyView {
dictionary GPUBufferCopyView : GPUTextureDataLayout {
required GPUBuffer buffer;
GPUSize64 offset = 0;
// TODO(crbug.com/1069302): rowPitch is deprecated; remove it, make bytesPerRow required.
GPUSize32 bytesPerRow;
unsigned long rowPitch;
GPUSize32 rowsPerImage = 0;
// TODO(crbug.com/1069302): imageHeight is deprecated; remove it.
unsigned long imageHeight;
};
......@@ -108,10 +108,7 @@ WGPURenderPassDepthStencilAttachmentDescriptor AsDawnType(
return dawn_desc;
}
base::Optional<WGPUBufferCopyView> AsDawnType(
const GPUBufferCopyView* webgpu_view,
GPUDevice* device,
ExceptionState& exception_state) {
WGPUBufferCopyView AsDawnType(const GPUBufferCopyView* webgpu_view) {
DCHECK(webgpu_view);
DCHECK(webgpu_view->buffer());
......@@ -119,32 +116,8 @@ base::Optional<WGPUBufferCopyView> AsDawnType(
dawn_view.nextInChain = nullptr;
dawn_view.buffer = webgpu_view->buffer()->GetHandle();
dawn_view.offset = webgpu_view->offset();
if (webgpu_view->hasRowPitch()) {
device->AddConsoleWarning(
"GPUBufferCopyView.rowPitch is deprecated: renamed to bytesPerRow");
}
if (webgpu_view->hasBytesPerRow()) {
dawn_view.bytesPerRow = webgpu_view->bytesPerRow();
} else {
if (!webgpu_view->hasRowPitch()) {
exception_state.ThrowTypeError(
"required member bytesPerRow is undefined.");
return base::nullopt;
}
dawn_view.bytesPerRow = 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.rowsPerImage = webgpu_view->imageHeight();
} else {
dawn_view.rowsPerImage = webgpu_view->rowsPerImage();
}
dawn_view.bytesPerRow = webgpu_view->bytesPerRow();
dawn_view.rowsPerImage = webgpu_view->rowsPerImage();
return dawn_view;
}
......@@ -277,8 +250,7 @@ void GPUCommandEncoder::copyBufferToTexture(
return;
}
base::Optional<WGPUBufferCopyView> dawn_source =
AsDawnType(source, device_, exception_state);
base::Optional<WGPUBufferCopyView> dawn_source = AsDawnType(source);
if (!dawn_source) {
return;
}
......@@ -300,8 +272,7 @@ void GPUCommandEncoder::copyTextureToBuffer(
}
WGPUTextureCopyView dawn_source = AsDawnType(source);
base::Optional<WGPUBufferCopyView> dawn_destination =
AsDawnType(destination, device_, exception_state);
base::Optional<WGPUBufferCopyView> dawn_destination = AsDawnType(destination);
if (!dawn_destination) {
return;
}
......
......@@ -32,9 +32,9 @@
GPUTextureCopyView destination,
GPUExtent3D copySize);
void pushDebugGroup(DOMString groupLabel);
void pushDebugGroup(USVString groupLabel);
void popDebugGroup();
void insertDebugMarker(DOMString markerLabel);
void insertDebugMarker(USVString markerLabel);
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
};
......@@ -5,5 +5,5 @@
// https://gpuweb.github.io/gpuweb/
dictionary GPUObjectDescriptorBase {
DOMString? label;
USVString? label;
};
......@@ -16,7 +16,7 @@
GPUSize64 dynamicOffsetsDataStart,
GPUSize32 dynamicOffsetsDataLength);
void pushDebugGroup(DOMString groupLabel);
void pushDebugGroup(USVString groupLabel);
void popDebugGroup();
void insertDebugMarker(DOMString markerLabel);
void insertDebugMarker(USVString markerLabel);
};
......@@ -6,5 +6,5 @@
dictionary GPUProgrammableStageDescriptor {
required GPUShaderModule module;
required DOMString entryPoint;
required USVString entryPoint;
};
......@@ -23,8 +23,8 @@ GPUShaderModule* GPUShaderModule::Create(
WGPUShaderModuleSPIRVDescriptor spirv_desc = {};
auto wgsl_or_spirv = webgpu_desc->code();
if (wgsl_or_spirv.IsString()) {
std::string code = wgsl_or_spirv.GetAsString().Utf8();
if (wgsl_or_spirv.IsUSVString()) {
std::string code = wgsl_or_spirv.GetAsUSVString().Utf8();
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
wgsl_desc.source = code.c_str();
......
......@@ -5,6 +5,6 @@
// https://gpuweb.github.io/gpuweb/
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
// TODO(crbug.com/1069302): Remove SPIR-V support, change this to DOMString.
required (DOMString or Uint32Array) code;
// TODO(crbug.com/1069302): Remove SPIR-V support, change this to USVString.
required (USVString or Uint32Array) code;
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://gpuweb.github.io/gpuweb/#dictdef-gputexturedatalayout
dictionary GPUTextureDataLayout {
GPUSize64 offset = 0;
required GPUSize32 bytesPerRow;
GPUSize32 rowsPerImage = 0;
};
......@@ -37,20 +37,20 @@ modules_idl_files = [
]
modules_dictionary_idl_files = [
"gpu_bind_group_entry.idl",
"gpu_bind_group_descriptor.idl",
"gpu_bind_group_layout_entry.idl",
"gpu_bind_group_entry.idl",
"gpu_bind_group_layout_descriptor.idl",
"gpu_bind_group_layout_entry.idl",
"gpu_blend_descriptor.idl",
"gpu_buffer_binding.idl",
"gpu_command_buffer_descriptor.idl",
"gpu_buffer_copy_view.idl",
"gpu_buffer_descriptor.idl",
"gpu_color_dict.idl",
"gpu_color_state_descriptor.idl",
"gpu_command_buffer_descriptor.idl",
"gpu_command_encoder_descriptor.idl",
"gpu_compute_pipeline_descriptor.idl",
"gpu_compute_pass_descriptor.idl",
"gpu_compute_pipeline_descriptor.idl",
"gpu_depth_stencil_state_descriptor.idl",
"gpu_device_descriptor.idl",
"gpu_extent_3d_dict.idl",
......@@ -76,6 +76,7 @@ modules_dictionary_idl_files = [
"gpu_stencil_state_face_descriptor.idl",
"gpu_swap_chain_descriptor.idl",
"gpu_texture_copy_view.idl",
"gpu_texture_data_layout.idl",
"gpu_texture_descriptor.idl",
"gpu_texture_view_descriptor.idl",
"gpu_uncaptured_error_event_init.idl",
......
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