Commit 7cbff905 authored by Brandon Jones's avatar Brandon Jones Committed by Chromium LUCI CQ

Updated GPUDevice.createBindGroupLayout() to accept newest syntax

Logs a deprecation warning to the console if the .type value is set
for any given entry, but otherwise defers to Dawn for all disambiguation
between the old and new syntax and related errors.

Bug: 1165629
Change-Id: I547b622f3634e6a7e7fa26c51d4462ea840fb8fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625810
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842857}
parent d36fdf9f
......@@ -870,6 +870,7 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/webgpu/gpu_blend_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_buffer.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_buffer_binding.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_buffer_binding_layout.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_buffer_copy_view.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_buffer_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.idl",
......@@ -921,14 +922,17 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/webgpu/gpu_render_pipeline_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_request_adapter_options.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_sampler.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_sampler_binding_layout.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_sampler_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_shader_module.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_shader_module_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_shader_stage.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_stencil_state_face_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_storage_texture_binding_layout.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_swap_chain.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_binding_layout.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",
......
......@@ -53,6 +53,73 @@ WGPUBindingType AsDawnEnum<WGPUBindingType>(const WTF::String& webgpu_enum) {
return WGPUBindingType_Force32;
}
template <>
WGPUBufferBindingType AsDawnEnum<WGPUBufferBindingType>(
const WTF::String& webgpu_enum) {
if (webgpu_enum == "uniform") {
return WGPUBufferBindingType_Uniform;
}
if (webgpu_enum == "storage") {
return WGPUBufferBindingType_Storage;
}
if (webgpu_enum == "read-only-storage") {
return WGPUBufferBindingType_ReadOnlyStorage;
}
NOTREACHED();
return WGPUBufferBindingType_Force32;
}
template <>
WGPUSamplerBindingType AsDawnEnum<WGPUSamplerBindingType>(
const WTF::String& webgpu_enum) {
if (webgpu_enum == "filtering") {
return WGPUSamplerBindingType_Filtering;
}
if (webgpu_enum == "non-filtering") {
return WGPUSamplerBindingType_NonFiltering;
}
if (webgpu_enum == "comparison") {
return WGPUSamplerBindingType_Comparison;
}
NOTREACHED();
return WGPUSamplerBindingType_Force32;
}
template <>
WGPUTextureSampleType AsDawnEnum<WGPUTextureSampleType>(
const WTF::String& webgpu_enum) {
if (webgpu_enum == "float") {
return WGPUTextureSampleType_Float;
}
if (webgpu_enum == "unfilterable-float") {
return WGPUTextureSampleType_UnfilterableFloat;
}
if (webgpu_enum == "depth") {
return WGPUTextureSampleType_Depth;
}
if (webgpu_enum == "sint") {
return WGPUTextureSampleType_Sint;
}
if (webgpu_enum == "uint") {
return WGPUTextureSampleType_Uint;
}
NOTREACHED();
return WGPUTextureSampleType_Force32;
}
template <>
WGPUStorageTextureAccess AsDawnEnum<WGPUStorageTextureAccess>(
const WTF::String& webgpu_enum) {
if (webgpu_enum == "read-only") {
return WGPUStorageTextureAccess_ReadOnly;
}
if (webgpu_enum == "write-only") {
return WGPUStorageTextureAccess_WriteOnly;
}
NOTREACHED();
return WGPUStorageTextureAccess_Force32;
}
template <>
WGPUTextureComponentType AsDawnEnum<WGPUTextureComponentType>(
const WTF::String& webgpu_enum) {
......
......@@ -6,6 +6,10 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_bind_group_layout_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_bind_group_layout_entry.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding_layout.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_sampler_binding_layout.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_storage_texture_binding_layout.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_texture_binding_layout.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
......@@ -20,23 +24,65 @@ WGPUBindGroupLayoutEntry AsDawnType(
dawn_binding.binding = webgpu_binding->binding();
dawn_binding.visibility =
AsDawnEnum<WGPUShaderStage>(webgpu_binding->visibility());
dawn_binding.type = AsDawnEnum<WGPUBindingType>(webgpu_binding->type());
dawn_binding.hasDynamicOffset = webgpu_binding->hasDynamicOffset();
if (webgpu_binding->hasBuffer()) {
dawn_binding.buffer.type =
AsDawnEnum<WGPUBufferBindingType>(webgpu_binding->buffer()->type());
dawn_binding.buffer.hasDynamicOffset =
webgpu_binding->buffer()->hasDynamicOffset();
dawn_binding.buffer.minBindingSize =
webgpu_binding->buffer()->minBindingSize();
}
if (webgpu_binding->hasSampler()) {
dawn_binding.sampler.type =
AsDawnEnum<WGPUSamplerBindingType>(webgpu_binding->sampler()->type());
}
dawn_binding.minBufferBindingSize =
webgpu_binding->hasMinBufferBindingSize()
? webgpu_binding->minBufferBindingSize()
: 0;
if (webgpu_binding->hasTexture()) {
dawn_binding.texture.sampleType = AsDawnEnum<WGPUTextureSampleType>(
webgpu_binding->texture()->sampleType());
dawn_binding.texture.viewDimension = AsDawnEnum<WGPUTextureViewDimension>(
webgpu_binding->texture()->viewDimension());
dawn_binding.texture.multisampled =
webgpu_binding->texture()->multisampled();
}
if (webgpu_binding->hasStorageTexture()) {
dawn_binding.storageTexture.access = AsDawnEnum<WGPUStorageTextureAccess>(
webgpu_binding->storageTexture()->access());
dawn_binding.storageTexture.format = AsDawnEnum<WGPUTextureFormat>(
webgpu_binding->storageTexture()->format());
dawn_binding.storageTexture.viewDimension =
AsDawnEnum<WGPUTextureViewDimension>(
webgpu_binding->storageTexture()->viewDimension());
}
dawn_binding.viewDimension =
AsDawnEnum<WGPUTextureViewDimension>(webgpu_binding->viewDimension());
// Deprecated values
if (webgpu_binding->hasType()) {
device->AddConsoleWarning(
"The format of GPUBindGroupLayoutEntry has changed, and will soon "
"require the buffer, sampler, texture, or storageTexture members be "
"set rather than setting type, etc. on the entry directly.");
dawn_binding.textureComponentType = AsDawnEnum<WGPUTextureComponentType>(
webgpu_binding->textureComponentType());
dawn_binding.type = AsDawnEnum<WGPUBindingType>(webgpu_binding->type());
dawn_binding.storageTextureFormat =
AsDawnEnum<WGPUTextureFormat>(webgpu_binding->storageTextureFormat());
dawn_binding.hasDynamicOffset = webgpu_binding->hasDynamicOffset();
dawn_binding.minBufferBindingSize =
webgpu_binding->hasMinBufferBindingSize()
? webgpu_binding->minBufferBindingSize()
: 0;
dawn_binding.viewDimension =
AsDawnEnum<WGPUTextureViewDimension>(webgpu_binding->viewDimension());
dawn_binding.textureComponentType = AsDawnEnum<WGPUTextureComponentType>(
webgpu_binding->textureComponentType());
dawn_binding.storageTextureFormat =
AsDawnEnum<WGPUTextureFormat>(webgpu_binding->storageTextureFormat());
}
return dawn_binding;
}
......
// Copyright 2019 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/
dictionary GPUBindGroupLayoutEntry {
required GPUIndex32 binding;
required GPUShaderStageFlags visibility;
required GPUBindingType type;
GPUBufferBindingLayout buffer;
GPUSamplerBindingLayout sampler;
GPUTextureBindingLayout texture;
GPUStorageTextureBindingLayout storageTexture;
// Deprecated BindGroupLayout members.
GPUBindingType type;
boolean hasDynamicOffset = false;
......
// Copyright 2021 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/
dictionary GPUBufferBindingLayout {
GPUBufferBindingType type = "uniform";
boolean hasDynamicOffset = false;
GPUSize64 minBindingSize = 0;
};
enum GPUBufferBindingType {
"uniform",
"storage",
"read-only-storage",
};
// Copyright 2021 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/
dictionary GPUSamplerBindingLayout {
GPUSamplerBindingType type = "filtering";
};
enum GPUSamplerBindingType {
"filtering",
"non-filtering",
"comparison",
};
// Copyright 2021 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/
dictionary GPUStorageTextureBindingLayout {
required GPUStorageTextureAccess access;
required GPUTextureFormat format;
GPUTextureViewDimension viewDimension = "2d";
};
enum GPUStorageTextureAccess {
"read-only",
"write-only",
};
// Copyright 2021 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/
dictionary GPUTextureBindingLayout {
GPUTextureSampleType sampleType = "float";
GPUTextureViewDimension viewDimension = "2d";
boolean multisampled = false;
};
enum GPUTextureSampleType {
"float",
"unfilterable-float",
"depth",
"sint",
"uint",
};
......@@ -45,6 +45,7 @@ modules_dictionary_idl_files = [
"gpu_bind_group_layout_entry.idl",
"gpu_blend_descriptor.idl",
"gpu_buffer_binding.idl",
"gpu_buffer_binding_layout.idl",
"gpu_buffer_copy_view.idl",
"gpu_buffer_descriptor.idl",
"gpu_color_dict.idl",
......@@ -74,10 +75,13 @@ modules_dictionary_idl_files = [
"gpu_render_pass_descriptor.idl",
"gpu_render_pipeline_descriptor.idl",
"gpu_request_adapter_options.idl",
"gpu_sampler_binding_layout.idl",
"gpu_sampler_descriptor.idl",
"gpu_shader_module_descriptor.idl",
"gpu_stencil_state_face_descriptor.idl",
"gpu_storage_texture_binding_layout.idl",
"gpu_swap_chain_descriptor.idl",
"gpu_texture_binding_layout.idl",
"gpu_texture_copy_view.idl",
"gpu_texture_data_layout.idl",
"gpu_texture_descriptor.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