Commit 7d601fbe authored by Jinho Bang's avatar Jinho Bang Committed by Commit Bot

WebGPU: Change GPUExtensions dictionary into array of GPUExtensionName

Related spec changes:
  https://github.com/gpuweb/gpuweb/pull/518
  https://github.com/gpuweb/gpuweb/pull/545

Bug: 852089
Change-Id: I462caa2a94664a19f518a1e6813328acc68f77bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2021564
Commit-Queue: Jinho Bang <jinho.bang@samsung.com>
Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738858}
parent 87d0258c
...@@ -813,7 +813,6 @@ static_idl_files_in_modules = get_path_info( ...@@ -813,7 +813,6 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/webgpu/gpu_device.idl", "//third_party/blink/renderer/modules/webgpu/gpu_device.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_device_descriptor.idl", "//third_party/blink/renderer/modules/webgpu/gpu_device_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.idl", "//third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_extensions.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_extent_3d_dict.idl", "//third_party/blink/renderer/modules/webgpu/gpu_extent_3d_dict.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_fence.idl", "//third_party/blink/renderer/modules/webgpu/gpu_fence.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_fence_descriptor.idl", "//third_party/blink/renderer/modules/webgpu/gpu_fence_descriptor.idl",
......
...@@ -798,7 +798,6 @@ modules_dictionary_idl_files = ...@@ -798,7 +798,6 @@ modules_dictionary_idl_files =
"webgpu/gpu_compute_pass_descriptor.idl", "webgpu/gpu_compute_pass_descriptor.idl",
"webgpu/gpu_depth_stencil_state_descriptor.idl", "webgpu/gpu_depth_stencil_state_descriptor.idl",
"webgpu/gpu_device_descriptor.idl", "webgpu/gpu_device_descriptor.idl",
"webgpu/gpu_extensions.idl",
"webgpu/gpu_extent_3d_dict.idl", "webgpu/gpu_extent_3d_dict.idl",
"webgpu/gpu_fence_descriptor.idl", "webgpu/gpu_fence_descriptor.idl",
"webgpu/gpu_image_bitmap_copy_view.idl", "webgpu/gpu_image_bitmap_copy_view.idl",
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_object_builder.h" #include "third_party/blink/renderer/bindings/core/v8/v8_object_builder.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_device_descriptor.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_device_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_extensions.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_request_adapter_options.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_request_adapter_options.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" #include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
...@@ -19,9 +18,15 @@ namespace { ...@@ -19,9 +18,15 @@ namespace {
WGPUDeviceProperties AsDawnType(const GPUDeviceDescriptor* descriptor) { WGPUDeviceProperties AsDawnType(const GPUDeviceDescriptor* descriptor) {
DCHECK_NE(nullptr, descriptor); DCHECK_NE(nullptr, descriptor);
HashSet<String> extension_set;
for (auto& extension : descriptor->extensions())
extension_set.insert(extension);
WGPUDeviceProperties requested_device_properties = {}; WGPUDeviceProperties requested_device_properties = {};
// TODO(crbug.com/1048603): We should validate that the extension_set is a
// subset of the adapter's extension set.
requested_device_properties.textureCompressionBC = requested_device_properties.textureCompressionBC =
descriptor->extensions()->textureCompressionBC(); extension_set.Contains("textureCompressionBC");
return requested_device_properties; return requested_device_properties;
} }
...@@ -35,17 +40,16 @@ GPUAdapter::GPUAdapter( ...@@ -35,17 +40,16 @@ GPUAdapter::GPUAdapter(
: DawnObjectBase(dawn_control_client), : DawnObjectBase(dawn_control_client),
name_(name), name_(name),
adapter_service_id_(adapter_service_id), adapter_service_id_(adapter_service_id),
adapter_properties_(properties) {} adapter_properties_(properties) {
InitializeExtensionNameList();
}
const String& GPUAdapter::name() const { const String& GPUAdapter::name() const {
return name_; return name_;
} }
ScriptValue GPUAdapter::extensions(ScriptState* script_state) const { Vector<String> GPUAdapter::extensions(ScriptState* script_state) const {
V8ObjectBuilder object_builder(script_state); return extension_name_list_;
object_builder.AddBoolean("textureCompressionBC",
adapter_properties_.textureCompressionBC);
return object_builder.GetScriptValue();
} }
void GPUAdapter::OnRequestDeviceCallback(ScriptPromiseResolver* resolver, void GPUAdapter::OnRequestDeviceCallback(ScriptPromiseResolver* resolver,
...@@ -63,6 +67,13 @@ void GPUAdapter::OnRequestDeviceCallback(ScriptPromiseResolver* resolver, ...@@ -63,6 +67,13 @@ void GPUAdapter::OnRequestDeviceCallback(ScriptPromiseResolver* resolver,
} }
} }
void GPUAdapter::InitializeExtensionNameList() {
DCHECK(extension_name_list_.IsEmpty());
if (adapter_properties_.textureCompressionBC) {
extension_name_list_.emplace_back("textureCompressionBC");
}
}
ScriptPromise GPUAdapter::requestDevice(ScriptState* script_state, ScriptPromise GPUAdapter::requestDevice(ScriptState* script_state,
const GPUDeviceDescriptor* descriptor) { const GPUDeviceDescriptor* descriptor) {
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
......
...@@ -28,7 +28,7 @@ class GPUAdapter final : public ScriptWrappable, public DawnObjectBase { ...@@ -28,7 +28,7 @@ class GPUAdapter final : public ScriptWrappable, public DawnObjectBase {
scoped_refptr<DawnControlClientHolder> dawn_control_client); scoped_refptr<DawnControlClientHolder> dawn_control_client);
const String& name() const; const String& name() const;
ScriptValue extensions(ScriptState* script_state) const; Vector<String> extensions(ScriptState* script_state) const;
ScriptPromise requestDevice(ScriptState* script_state, ScriptPromise requestDevice(ScriptState* script_state,
const GPUDeviceDescriptor* descriptor); const GPUDeviceDescriptor* descriptor);
...@@ -37,10 +37,12 @@ class GPUAdapter final : public ScriptWrappable, public DawnObjectBase { ...@@ -37,10 +37,12 @@ class GPUAdapter final : public ScriptWrappable, public DawnObjectBase {
void OnRequestDeviceCallback(ScriptPromiseResolver* resolver, void OnRequestDeviceCallback(ScriptPromiseResolver* resolver,
const GPUDeviceDescriptor* descriptor, const GPUDeviceDescriptor* descriptor,
bool is_request_device_success); bool is_request_device_success);
void InitializeExtensionNameList();
String name_; String name_;
uint32_t adapter_service_id_; uint32_t adapter_service_id_;
WGPUDeviceProperties adapter_properties_; WGPUDeviceProperties adapter_properties_;
Vector<String> extension_name_list_;
DISALLOW_COPY_AND_ASSIGN(GPUAdapter); DISALLOW_COPY_AND_ASSIGN(GPUAdapter);
}; };
......
...@@ -4,11 +4,15 @@ ...@@ -4,11 +4,15 @@
// https://gpuweb.github.io/gpuweb/ // https://gpuweb.github.io/gpuweb/
enum GPUExtensionName {
"textureCompressionBC",
};
[ [
Exposed(Window WebGPU, Worker WebGPU) Exposed(Window WebGPU, Worker WebGPU)
] interface GPUAdapter { ] interface GPUAdapter {
readonly attribute DOMString name; readonly attribute DOMString name;
[CallWith=ScriptState, SameObject] readonly attribute object extensions; [CallWith=ScriptState, SameObject] readonly attribute FrozenArray<GPUExtensionName> extensions;
[CallWith=ScriptState] Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {}); [CallWith=ScriptState] Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
}; };
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
// https://gpuweb.github.io/gpuweb/ // https://gpuweb.github.io/gpuweb/
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase { dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
GPUExtensions extensions = {}; sequence<GPUExtensionName> extensions = [];
GPULimits limits = {}; GPULimits limits = {};
}; };
// 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 GPUExtensions {
boolean textureCompressionBC = false;
};
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