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( ...@@ -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_swap_chain_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture.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_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_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture_usage.idl", "//third_party/blink/renderer/modules/webgpu/gpu_texture_usage.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_texture_view.idl", "//third_party/blink/renderer/modules/webgpu/gpu_texture_view.idl",
......
...@@ -99,8 +99,6 @@ bindings_modules_generated_union_type_files = [ ...@@ -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_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.cc",
"$bindings_modules_v8_output_dir/string_or_unsigned_long.h", "$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.cc",
"$bindings_modules_v8_output_dir/unsigned_long_or_unsigned_long_sequence.h", "$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", "$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 = [ ...@@ -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_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.cc",
"$bindings_modules_v8_output_dir/unsigned_long_enforce_range_sequence_or_gpu_origin_3d_dict.h", "$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.cc",
"$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.h", "$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", "$bindings_modules_v8_output_dir/worklet_animation_effect_or_worklet_group_effect.cc",
......
...@@ -51,24 +51,11 @@ GPUBindGroup* GPUBindGroup::Create(GPUDevice* device, ...@@ -51,24 +51,11 @@ GPUBindGroup* GPUBindGroup::Create(GPUDevice* device,
DCHECK(device); DCHECK(device);
DCHECK(webgpu_desc); DCHECK(webgpu_desc);
if (webgpu_desc->hasBindings()) {
device->AddConsoleWarning(
"GPUBindGroupDescriptor.bindings is deprecated: renamed to entries");
}
uint32_t entry_count = 0; uint32_t entry_count = 0;
std::unique_ptr<WGPUBindGroupEntry[]> entries; std::unique_ptr<WGPUBindGroupEntry[]> entries;
if (webgpu_desc->hasEntries()) { entry_count = static_cast<uint32_t>(webgpu_desc->entries().size());
entry_count = static_cast<uint32_t>(webgpu_desc->entries().size()); if (entry_count > 0) {
entries = entry_count != 0 ? AsDawnType(webgpu_desc->entries()) : nullptr; entries = AsDawnType(webgpu_desc->entries());
} 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;
} }
WGPUBindGroupDescriptor dawn_desc = {}; WGPUBindGroupDescriptor dawn_desc = {};
......
...@@ -6,8 +6,5 @@ ...@@ -6,8 +6,5 @@
dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase { dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
required GPUBindGroupLayout layout; required GPUBindGroupLayout layout;
required sequence<GPUBindGroupEntry> entries;
// TODO(crbug.com/1069302): bindings is deprecated; remove it, make entries required.
sequence<GPUBindGroupEntry> bindings;
sequence<GPUBindGroupEntry> entries;
}; };
...@@ -21,20 +21,8 @@ WGPUBindGroupLayoutEntry AsDawnType( ...@@ -21,20 +21,8 @@ WGPUBindGroupLayoutEntry AsDawnType(
dawn_binding.type = AsDawnEnum<WGPUBindingType>(webgpu_binding->type()); dawn_binding.type = AsDawnEnum<WGPUBindingType>(webgpu_binding->type());
dawn_binding.visibility = dawn_binding.visibility =
AsDawnEnum<WGPUShaderStage>(webgpu_binding->visibility()); AsDawnEnum<WGPUShaderStage>(webgpu_binding->visibility());
dawn_binding.viewDimension =
// Note: in this case we check for the deprecated member first, because AsDawnEnum<WGPUTextureViewDimension>(webgpu_binding->viewDimension());
// 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.textureComponentType = AsDawnEnum<WGPUTextureComponentType>( dawn_binding.textureComponentType = AsDawnEnum<WGPUTextureComponentType>(
webgpu_binding->textureComponentType()); webgpu_binding->textureComponentType());
dawn_binding.multisampled = webgpu_binding->multisampled(); dawn_binding.multisampled = webgpu_binding->multisampled();
...@@ -66,27 +54,11 @@ GPUBindGroupLayout* GPUBindGroupLayout::Create( ...@@ -66,27 +54,11 @@ GPUBindGroupLayout* GPUBindGroupLayout::Create(
DCHECK(device); DCHECK(device);
DCHECK(webgpu_desc); DCHECK(webgpu_desc);
if (webgpu_desc->hasBindings()) {
device->AddConsoleWarning(
"GPUBindGroupLayoutDescriptor.bindings is deprecated: renamed to "
"entries");
}
uint32_t entry_count = 0; uint32_t entry_count = 0;
std::unique_ptr<WGPUBindGroupLayoutEntry[]> entries; std::unique_ptr<WGPUBindGroupLayoutEntry[]> entries;
if (webgpu_desc->hasEntries()) { entry_count = static_cast<uint32_t>(webgpu_desc->entries().size());
entry_count = static_cast<uint32_t>(webgpu_desc->entries().size()); if (entry_count > 0) {
entries = entries = AsDawnType(webgpu_desc->entries(), device);
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;
} }
WGPUBindGroupLayoutDescriptor dawn_desc = {}; WGPUBindGroupLayoutDescriptor dawn_desc = {};
......
...@@ -5,7 +5,5 @@ ...@@ -5,7 +5,5 @@
// https://gpuweb.github.io/gpuweb/ // https://gpuweb.github.io/gpuweb/
dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase { dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
// TODO(crbug.com/1069302): bindings is deprecated; remove it, make entries required. required sequence<GPUBindGroupLayoutEntry> entries;
sequence<GPUBindGroupLayoutEntry> bindings;
sequence<GPUBindGroupLayoutEntry> entries;
}; };
...@@ -9,8 +9,6 @@ dictionary GPUBindGroupLayoutEntry { ...@@ -9,8 +9,6 @@ dictionary GPUBindGroupLayoutEntry {
required GPUShaderStageFlags visibility; required GPUShaderStageFlags visibility;
required GPUBindingType type; required GPUBindingType type;
GPUTextureViewDimension viewDimension = "2d"; GPUTextureViewDimension viewDimension = "2d";
// TODO(crbug.com/1069302): textureDimension is deprecated; remove it.
GPUTextureViewDimension textureDimension;
GPUTextureComponentType textureComponentType = "float"; GPUTextureComponentType textureComponentType = "float";
boolean multisampled = false; boolean multisampled = false;
boolean hasDynamicOffset = false; boolean hasDynamicOffset = false;
......
...@@ -4,15 +4,6 @@ ...@@ -4,15 +4,6 @@
// https://gpuweb.github.io/gpuweb/ // https://gpuweb.github.io/gpuweb/
dictionary GPUBufferCopyView { dictionary GPUBufferCopyView : GPUTextureDataLayout {
required GPUBuffer buffer; 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( ...@@ -108,10 +108,7 @@ WGPURenderPassDepthStencilAttachmentDescriptor AsDawnType(
return dawn_desc; return dawn_desc;
} }
base::Optional<WGPUBufferCopyView> AsDawnType( WGPUBufferCopyView AsDawnType(const GPUBufferCopyView* webgpu_view) {
const GPUBufferCopyView* webgpu_view,
GPUDevice* device,
ExceptionState& exception_state) {
DCHECK(webgpu_view); DCHECK(webgpu_view);
DCHECK(webgpu_view->buffer()); DCHECK(webgpu_view->buffer());
...@@ -119,32 +116,8 @@ base::Optional<WGPUBufferCopyView> AsDawnType( ...@@ -119,32 +116,8 @@ base::Optional<WGPUBufferCopyView> AsDawnType(
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.bytesPerRow = webgpu_view->bytesPerRow();
if (webgpu_view->hasRowPitch()) { dawn_view.rowsPerImage = webgpu_view->rowsPerImage();
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();
}
return dawn_view; return dawn_view;
} }
...@@ -277,8 +250,7 @@ void GPUCommandEncoder::copyBufferToTexture( ...@@ -277,8 +250,7 @@ void GPUCommandEncoder::copyBufferToTexture(
return; return;
} }
base::Optional<WGPUBufferCopyView> dawn_source = base::Optional<WGPUBufferCopyView> dawn_source = AsDawnType(source);
AsDawnType(source, device_, exception_state);
if (!dawn_source) { if (!dawn_source) {
return; return;
} }
...@@ -300,8 +272,7 @@ void GPUCommandEncoder::copyTextureToBuffer( ...@@ -300,8 +272,7 @@ void GPUCommandEncoder::copyTextureToBuffer(
} }
WGPUTextureCopyView dawn_source = AsDawnType(source); WGPUTextureCopyView dawn_source = AsDawnType(source);
base::Optional<WGPUBufferCopyView> dawn_destination = base::Optional<WGPUBufferCopyView> dawn_destination = AsDawnType(destination);
AsDawnType(destination, device_, exception_state);
if (!dawn_destination) { if (!dawn_destination) {
return; return;
} }
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
GPUTextureCopyView destination, GPUTextureCopyView destination,
GPUExtent3D copySize); GPUExtent3D copySize);
void pushDebugGroup(DOMString groupLabel); void pushDebugGroup(USVString groupLabel);
void popDebugGroup(); void popDebugGroup();
void insertDebugMarker(DOMString markerLabel); void insertDebugMarker(USVString markerLabel);
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {}); GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
}; };
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
// https://gpuweb.github.io/gpuweb/ // https://gpuweb.github.io/gpuweb/
dictionary GPUObjectDescriptorBase { dictionary GPUObjectDescriptorBase {
DOMString? label; USVString? label;
}; };
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
GPUSize64 dynamicOffsetsDataStart, GPUSize64 dynamicOffsetsDataStart,
GPUSize32 dynamicOffsetsDataLength); GPUSize32 dynamicOffsetsDataLength);
void pushDebugGroup(DOMString groupLabel); void pushDebugGroup(USVString groupLabel);
void popDebugGroup(); void popDebugGroup();
void insertDebugMarker(DOMString markerLabel); void insertDebugMarker(USVString markerLabel);
}; };
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
dictionary GPUProgrammableStageDescriptor { dictionary GPUProgrammableStageDescriptor {
required GPUShaderModule module; required GPUShaderModule module;
required DOMString entryPoint; required USVString entryPoint;
}; };
...@@ -23,8 +23,8 @@ GPUShaderModule* GPUShaderModule::Create( ...@@ -23,8 +23,8 @@ GPUShaderModule* GPUShaderModule::Create(
WGPUShaderModuleSPIRVDescriptor spirv_desc = {}; WGPUShaderModuleSPIRVDescriptor spirv_desc = {};
auto wgsl_or_spirv = webgpu_desc->code(); auto wgsl_or_spirv = webgpu_desc->code();
if (wgsl_or_spirv.IsString()) { if (wgsl_or_spirv.IsUSVString()) {
std::string code = wgsl_or_spirv.GetAsString().Utf8(); std::string code = wgsl_or_spirv.GetAsUSVString().Utf8();
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor; wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
wgsl_desc.source = code.c_str(); wgsl_desc.source = code.c_str();
......
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
// https://gpuweb.github.io/gpuweb/ // https://gpuweb.github.io/gpuweb/
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase { dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
// TODO(crbug.com/1069302): Remove SPIR-V support, change this to DOMString. // TODO(crbug.com/1069302): Remove SPIR-V support, change this to USVString.
required (DOMString or Uint32Array) code; 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 = [ ...@@ -37,20 +37,20 @@ modules_idl_files = [
] ]
modules_dictionary_idl_files = [ modules_dictionary_idl_files = [
"gpu_bind_group_entry.idl",
"gpu_bind_group_descriptor.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_descriptor.idl",
"gpu_bind_group_layout_entry.idl",
"gpu_blend_descriptor.idl", "gpu_blend_descriptor.idl",
"gpu_buffer_binding.idl", "gpu_buffer_binding.idl",
"gpu_command_buffer_descriptor.idl",
"gpu_buffer_copy_view.idl", "gpu_buffer_copy_view.idl",
"gpu_buffer_descriptor.idl", "gpu_buffer_descriptor.idl",
"gpu_color_dict.idl", "gpu_color_dict.idl",
"gpu_color_state_descriptor.idl", "gpu_color_state_descriptor.idl",
"gpu_command_buffer_descriptor.idl",
"gpu_command_encoder_descriptor.idl", "gpu_command_encoder_descriptor.idl",
"gpu_compute_pipeline_descriptor.idl",
"gpu_compute_pass_descriptor.idl", "gpu_compute_pass_descriptor.idl",
"gpu_compute_pipeline_descriptor.idl",
"gpu_depth_stencil_state_descriptor.idl", "gpu_depth_stencil_state_descriptor.idl",
"gpu_device_descriptor.idl", "gpu_device_descriptor.idl",
"gpu_extent_3d_dict.idl", "gpu_extent_3d_dict.idl",
...@@ -76,6 +76,7 @@ modules_dictionary_idl_files = [ ...@@ -76,6 +76,7 @@ modules_dictionary_idl_files = [
"gpu_stencil_state_face_descriptor.idl", "gpu_stencil_state_face_descriptor.idl",
"gpu_swap_chain_descriptor.idl", "gpu_swap_chain_descriptor.idl",
"gpu_texture_copy_view.idl", "gpu_texture_copy_view.idl",
"gpu_texture_data_layout.idl",
"gpu_texture_descriptor.idl", "gpu_texture_descriptor.idl",
"gpu_texture_view_descriptor.idl", "gpu_texture_view_descriptor.idl",
"gpu_uncaptured_error_event_init.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