dawn/node: Implement Adapter.GetAdapterInfo()

Bug: dawn:1761
Change-Id: Ia1bf7841052897b69de50d6db41b05ee5645be47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128104
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Jiawei Shao 2023-04-21 01:49:38 +00:00 committed by Dawn LUCI CQ
parent 2d1136281e
commit cd4b42b5a2
4 changed files with 104 additions and 2 deletions

View File

@ -25,6 +25,8 @@ add_library(dawn_node_binding STATIC
"GPU.h"
"GPUAdapter.cpp"
"GPUAdapter.h"
"GPUAdapterInfo.cpp"
"GPUAdapterInfo.h"
"GPUBindGroup.cpp"
"GPUBindGroup.h"
"GPUBindGroupLayout.cpp"

View File

@ -21,6 +21,7 @@
#include "src/dawn/node/binding/Converter.h"
#include "src/dawn/node/binding/Errors.h"
#include "src/dawn/node/binding/Flags.h"
#include "src/dawn/node/binding/GPUAdapterInfo.h"
#include "src/dawn/node/binding/GPUDevice.h"
#include "src/dawn/node/binding/GPUSupportedFeatures.h"
#include "src/dawn/node/binding/GPUSupportedLimits.h"
@ -203,9 +204,15 @@ interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevi
}
interop::Promise<interop::Interface<interop::GPUAdapterInfo>> GPUAdapter::requestAdapterInfo(
Napi::Env,
Napi::Env env,
std::vector<std::string> unmaskHints) {
UNIMPLEMENTED();
interop::Promise<interop::Interface<interop::GPUAdapterInfo>> promise(env, PROMISE_INFO);
WGPUAdapterProperties adapterProperties = {};
adapter_.GetProperties(&adapterProperties);
promise.Resolve(interop::GPUAdapterInfo::Create<GPUAdapterInfo>(env, adapterProperties));
return promise;
}
} // namespace wgpu::binding

View File

@ -0,0 +1,45 @@
// Copyright 2023 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/dawn/node/binding/GPUAdapterInfo.h"
namespace wgpu::binding {
////////////////////////////////////////////////////////////////////////////////
// wgpu::bindings::GPUAdapterInfo
////////////////////////////////////////////////////////////////////////////////
GPUAdapterInfo::GPUAdapterInfo(WGPUAdapterProperties properties)
: vendor_(properties.vendorName),
architecture_(properties.architecture),
device_(properties.name),
description_(properties.driverDescription) {}
std::string GPUAdapterInfo::getVendor(Napi::Env) {
return vendor_;
}
std::string GPUAdapterInfo::getArchitecture(Napi::Env) {
return architecture_;
}
std::string GPUAdapterInfo::getDevice(Napi::Env) {
return device_;
}
std::string GPUAdapterInfo::getDescription(Napi::Env) {
return description_;
}
} // namespace wgpu::binding

View File

@ -0,0 +1,48 @@
// Copyright 2023 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_DAWN_NODE_BINDING_GPUADAPTERINFO_H_
#define SRC_DAWN_NODE_BINDING_GPUADAPTERINFO_H_
#include <string>
#include "dawn/native/DawnNative.h"
#include "dawn/webgpu_cpp.h"
#include "src/dawn/node/interop/Napi.h"
#include "src/dawn/node/interop/WebGPU.h"
namespace wgpu::binding {
// GPUAdapterInfo is an implementation of interop::GPUAdapterInfo.
class GPUAdapterInfo final : public interop::GPUAdapterInfo {
public:
explicit GPUAdapterInfo(WGPUAdapterProperties);
// interop::GPUAdapterInfo interface compliance
std::string getVendor(Napi::Env) override;
std::string getArchitecture(Napi::Env) override;
std::string getDevice(Napi::Env) override;
std::string getDescription(Napi::Env) override;
private:
std::string vendor_;
std::string architecture_;
std::string device_;
std::string description_;
};
} // namespace wgpu::binding
#endif // SRC_DAWN_NODE_BINDING_GPUADAPTERINFO_H_