dawn_node: Add binding/GPUAdapter.cpp
Bug: dawn:1123 Change-Id: I5eee0036acf4db18dd103f863c4f07511a0cee25 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64917 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
9a10674bb9
commit
c6b786e0fc
|
@ -21,6 +21,7 @@ add_library(dawn_node_binding STATIC
|
|||
"Errors.h"
|
||||
"GPU.cpp"
|
||||
"GPU.h"
|
||||
"GPUAdapter.cpp"
|
||||
"GPUAdapter.h"
|
||||
"GPUBindGroup.cpp"
|
||||
"GPUBindGroup.h"
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright 2021 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/GPUAdapter.h"
|
||||
|
||||
#include "src/dawn_node/binding/GPUDevice.h"
|
||||
#include "src/dawn_node/binding/GPUSupportedLimits.h"
|
||||
|
||||
namespace wgpu { namespace binding {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// wgpu::bindings::GPUAdapter
|
||||
// TODO(crbug.com/dawn/1133): This is a stub implementation. Properly implement.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
GPUAdapter::GPUAdapter(dawn_native::Adapter a) : adapter_(a) {
|
||||
}
|
||||
|
||||
std::string GPUAdapter::getName(Napi::Env) {
|
||||
return "dawn-adapter";
|
||||
}
|
||||
|
||||
interop::Interface<interop::GPUSupportedFeatures> GPUAdapter::getFeatures(Napi::Env env) {
|
||||
class Features : public interop::GPUSupportedFeatures {};
|
||||
return interop::GPUSupportedFeatures::Create<Features>(env);
|
||||
}
|
||||
|
||||
interop::Interface<interop::GPUSupportedLimits> GPUAdapter::getLimits(Napi::Env env) {
|
||||
return interop::GPUSupportedLimits::Create<GPUSupportedLimits>(env);
|
||||
}
|
||||
|
||||
bool GPUAdapter::getIsFallbackAdapter(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevice(
|
||||
Napi::Env env,
|
||||
std::optional<interop::GPUDeviceDescriptor> descriptor) {
|
||||
dawn_native::DeviceDescriptor desc{}; // TODO(crbug.com/dawn/1133): Fill in.
|
||||
interop::Promise<interop::Interface<interop::GPUDevice>> promise(env);
|
||||
|
||||
auto wgpu_device = adapter_.CreateDevice(&desc);
|
||||
if (wgpu_device) {
|
||||
promise.Resolve(interop::GPUDevice::Create<GPUDevice>(env, env, wgpu_device));
|
||||
} else {
|
||||
Napi::Error::New(env, "failed to create device").ThrowAsJavaScriptException();
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
}} // namespace wgpu::binding
|
Loading…
Reference in New Issue