Commit 7d51165e authored by Jiawei Shao's avatar Jiawei Shao Committed by Commit Bot

WebGPU: Expose GPUAdapter.extensions in Blink

This patch exposes the read-only attribute GPUAdapter.extensions in
Blink as is required in WebGPU SPEC. GPUAdapter.extensions is a
dictionary whose keys are extension names and values are boolean values
that indicate if the extensions are supported on this adapter or not.

BUG=chromium:996713

Change-Id: I6bfd2283babf981208ade10adb458f088f0333f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1929717Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Cr-Commit-Position: refs/heads/master@{#718409}
parent efec9246
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/modules/webgpu/gpu_adapter.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/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_request_adapter_options.h"
......@@ -25,14 +26,21 @@ GPUAdapter::GPUAdapter(
uint32_t adapter_service_id,
const WGPUDeviceProperties& properties,
scoped_refptr<DawnControlClientHolder> dawn_control_client)
: DawnObjectBase(dawn_control_client), name_(name) {
// TODO(jiawei.shao@intel.com): add GPUExtensions as a member of GPUAdapter
}
: DawnObjectBase(dawn_control_client),
name_(name),
adapter_properties_(properties) {}
const String& GPUAdapter::name() const {
return name_;
}
ScriptValue GPUAdapter::extensions(ScriptState* script_state) const {
V8ObjectBuilder object_builder(script_state);
object_builder.AddBoolean("textureCompressionBC",
adapter_properties_.textureCompressionBC);
return object_builder.GetScriptValue();
}
// TODO(jiawei.shao@intel.com) request device with adapter_server_id
ScriptPromise GPUAdapter::requestDevice(ScriptState* script_state,
const GPUDeviceDescriptor* descriptor) {
......
......@@ -32,12 +32,14 @@ class GPUAdapter final : public ScriptWrappable, public DawnObjectBase {
scoped_refptr<DawnControlClientHolder> dawn_control_client);
const String& name() const;
ScriptValue extensions(ScriptState* script_state) const;
ScriptPromise requestDevice(ScriptState* script_state,
const GPUDeviceDescriptor* descriptor);
private:
String name_;
WGPUDeviceProperties adapter_properties_;
DISALLOW_COPY_AND_ASSIGN(GPUAdapter);
};
......
......@@ -8,6 +8,7 @@
Exposed(Window WebGPU, Worker WebGPU)
] interface GPUAdapter {
readonly attribute DOMString name;
[CallWith=ScriptState, SameObject] readonly attribute object extensions;
[CallWith=ScriptState] Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
};
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