dawn/node: Update for latest WebGPU IDL
Most new APIs have just been stubbed with `UNIMPLEMENTED()`. We'll need to flesh these out. This unblocks the Tint team for now though. Bug: dawn:1123 Change-Id: I484559278a21e187ba496e01401316ac91be7d26 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92941 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
af510d7c6a
commit
b853164261
2
DEPS
2
DEPS
|
@ -169,7 +169,7 @@ deps = {
|
|||
'condition': 'dawn_node',
|
||||
},
|
||||
'third_party/gpuweb': {
|
||||
'url': '{github_git}/gpuweb/gpuweb.git@16df823c91c9045b7cdf9bd0f2c0ef6d43ac95e7',
|
||||
'url': '{github_git}/gpuweb/gpuweb.git@3c4734b09c68eb800b15da5e9ecefeca735fa7df',
|
||||
'condition': 'dawn_node',
|
||||
},
|
||||
|
||||
|
|
|
@ -295,9 +295,6 @@ bool Converter::Convert(wgpu::TextureFormat& out, const interop::GPUTextureForma
|
|||
case interop::GPUTextureFormat::kDepth32Float:
|
||||
out = wgpu::TextureFormat::Depth32Float;
|
||||
return true;
|
||||
case interop::GPUTextureFormat::kDepth24UnormStencil8:
|
||||
out = wgpu::TextureFormat::Depth24UnormStencil8;
|
||||
return true;
|
||||
case interop::GPUTextureFormat::kDepth32FloatStencil8:
|
||||
out = wgpu::TextureFormat::Depth32FloatStencil8;
|
||||
return true;
|
||||
|
@ -1217,4 +1214,9 @@ bool Converter::Convert(wgpu::RenderPipelineDescriptor& out,
|
|||
Convert(out.fragment, in.fragment);
|
||||
}
|
||||
|
||||
bool Converter::Convert(wgpu::PipelineLayout& out, const interop::GPUAutoLayoutMode& in) {
|
||||
out = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace wgpu::binding
|
||||
|
|
|
@ -243,6 +243,8 @@ class Converter {
|
|||
[[nodiscard]] bool Convert(wgpu::RenderPipelineDescriptor& out,
|
||||
const interop::GPURenderPipelineDescriptor& in);
|
||||
|
||||
[[nodiscard]] bool Convert(wgpu::PipelineLayout& out, const interop::GPUAutoLayoutMode& in);
|
||||
|
||||
// std::string to C string
|
||||
inline bool Convert(const char*& out, const std::string& in) {
|
||||
out = in.c_str();
|
||||
|
|
|
@ -165,4 +165,8 @@ interop::Promise<std::optional<interop::Interface<interop::GPUAdapter>>> GPU::re
|
|||
return promise;
|
||||
}
|
||||
|
||||
interop::GPUTextureFormat GPU::getPreferredCanvasFormat(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
} // namespace wgpu::binding
|
||||
|
|
|
@ -32,6 +32,7 @@ class GPU final : public interop::GPU {
|
|||
interop::Promise<std::optional<interop::Interface<interop::GPUAdapter>>> requestAdapter(
|
||||
Napi::Env env,
|
||||
interop::GPURequestAdapterOptions options) override;
|
||||
interop::GPUTextureFormat getPreferredCanvasFormat(Napi::Env) override;
|
||||
|
||||
private:
|
||||
const Flags flags_;
|
||||
|
|
|
@ -92,9 +92,6 @@ namespace {
|
|||
class Features : public interop::GPUSupportedFeatures {
|
||||
public:
|
||||
explicit Features(WGPUDeviceProperties properties) {
|
||||
if (properties.depth24UnormStencil8) {
|
||||
enabled_.emplace(interop::GPUFeatureName::kDepth24UnormStencil8);
|
||||
}
|
||||
if (properties.depth32FloatStencil8) {
|
||||
enabled_.emplace(interop::GPUFeatureName::kDepth32FloatStencil8);
|
||||
}
|
||||
|
@ -115,8 +112,10 @@ class Features : public interop::GPUSupportedFeatures {
|
|||
}
|
||||
|
||||
// TODO(dawn:1123) add support for these extensions when possible.
|
||||
// wgpu::interop::GPUFeatureName::kIndirectFirstInstance
|
||||
// wgpu::interop::GPUFeatureName::kDepthClipControl
|
||||
// wgpu::interop::GPUFeatureName::kIndirectFirstInstance
|
||||
// wgpu::interop::GPUFeatureName::kShaderF16
|
||||
// wgpu::interop::GPUFeatureName::kBgra8UnormStorage
|
||||
}
|
||||
|
||||
bool has(interop::GPUFeatureName feature) { return enabled_.count(feature) != 0; }
|
||||
|
@ -148,18 +147,10 @@ class Features : public interop::GPUSupportedFeatures {
|
|||
// wgpu::bindings::GPUAdapter
|
||||
// TODO(crbug.com/dawn/1133): This is a stub implementation. Properly implement.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
GPUAdapter::GPUAdapter(dawn::native::Adapter a, const Flags& flags) : adapter_(a), flags_(flags) {
|
||||
wgpu::AdapterProperties props;
|
||||
adapter_.GetProperties(&props);
|
||||
name_ = props.name;
|
||||
}
|
||||
GPUAdapter::GPUAdapter(dawn::native::Adapter a, const Flags& flags) : adapter_(a), flags_(flags) {}
|
||||
|
||||
// TODO(dawn:1133): Avoid the extra copy by making the generator make a virtual method with const
|
||||
// std::string&
|
||||
std::string GPUAdapter::getName(Napi::Env) {
|
||||
return name_;
|
||||
}
|
||||
|
||||
interop::Interface<interop::GPUSupportedFeatures> GPUAdapter::getFeatures(Napi::Env env) {
|
||||
return interop::GPUSupportedFeatures::Create<Features>(env, adapter_.GetAdapterProperties());
|
||||
}
|
||||
|
@ -205,15 +196,13 @@ interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevi
|
|||
case interop::GPUFeatureName::kTimestampQuery:
|
||||
requiredFeatures.emplace_back(wgpu::FeatureName::TimestampQuery);
|
||||
continue;
|
||||
case interop::GPUFeatureName::kDepth24UnormStencil8:
|
||||
requiredFeatures.emplace_back(wgpu::FeatureName::Depth24UnormStencil8);
|
||||
continue;
|
||||
case interop::GPUFeatureName::kDepth32FloatStencil8:
|
||||
requiredFeatures.emplace_back(wgpu::FeatureName::Depth32FloatStencil8);
|
||||
continue;
|
||||
case interop::GPUFeatureName::kDepthClipControl:
|
||||
case interop::GPUFeatureName::kIndirectFirstInstance:
|
||||
case interop::GPUFeatureName::kShaderF16:
|
||||
case interop::GPUFeatureName::kIndirectFirstInstance:
|
||||
case interop::GPUFeatureName::kBgra8UnormStorage:
|
||||
// TODO(dawn:1123) Add support for these extensions when possible.
|
||||
continue;
|
||||
}
|
||||
|
@ -274,4 +263,11 @@ interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevi
|
|||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
interop::Promise<interop::Interface<interop::GPUAdapterInfo>> GPUAdapter::requestAdapterInfo(
|
||||
Napi::Env,
|
||||
std::vector<std::string> unmaskHints) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
} // namespace wgpu::binding
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define SRC_DAWN_NODE_BINDING_GPUADAPTER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "dawn/native/DawnNative.h"
|
||||
#include "dawn/webgpu_cpp.h"
|
||||
|
@ -31,18 +32,19 @@ class GPUAdapter final : public interop::GPUAdapter {
|
|||
GPUAdapter(dawn::native::Adapter a, const Flags& flags);
|
||||
|
||||
// interop::GPUAdapter interface compliance
|
||||
std::string getName(Napi::Env) override;
|
||||
interop::Interface<interop::GPUSupportedFeatures> getFeatures(Napi::Env) override;
|
||||
interop::Interface<interop::GPUSupportedLimits> getLimits(Napi::Env) override;
|
||||
bool getIsFallbackAdapter(Napi::Env) override;
|
||||
interop::Promise<interop::Interface<interop::GPUDevice>> requestDevice(
|
||||
Napi::Env env,
|
||||
interop::GPUDeviceDescriptor descriptor) override;
|
||||
interop::Promise<interop::Interface<interop::GPUAdapterInfo>> requestAdapterInfo(
|
||||
Napi::Env,
|
||||
std::vector<std::string> unmaskHints) override;
|
||||
interop::Interface<interop::GPUSupportedFeatures> getFeatures(Napi::Env) override;
|
||||
interop::Interface<interop::GPUSupportedLimits> getLimits(Napi::Env) override;
|
||||
bool getIsFallbackAdapter(Napi::Env) override;
|
||||
|
||||
private:
|
||||
dawn::native::Adapter adapter_;
|
||||
const Flags& flags_;
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
} // namespace wgpu::binding
|
||||
|
|
|
@ -162,6 +162,14 @@ void GPUBuffer::destroy(Napi::Env) {
|
|||
state_ = State::Destroyed;
|
||||
}
|
||||
|
||||
interop::GPUSize64 GPUBuffer::getSize(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUBufferUsageFlags GPUBuffer::getUsage(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void GPUBuffer::DetachMappings() {
|
||||
for (auto& mapping : mapped_) {
|
||||
mapping.buffer.Value().Detach();
|
||||
|
|
|
@ -51,6 +51,8 @@ class GPUBuffer final : public interop::GPUBuffer {
|
|||
std::optional<interop::GPUSize64> size) override;
|
||||
void unmap(Napi::Env) override;
|
||||
void destroy(Napi::Env) override;
|
||||
interop::GPUSize64 getSize(Napi::Env) override;
|
||||
interop::GPUBufferUsageFlags getUsage(Napi::Env) override;
|
||||
std::string getLabel(Napi::Env) override;
|
||||
void setLabel(Napi::Env, std::string value) override;
|
||||
|
||||
|
|
|
@ -56,7 +56,16 @@ class DeviceLostInfo : public interop::GPUDeviceLostInfo {
|
|||
std::string message_;
|
||||
};
|
||||
|
||||
class OOMError : public interop::GPUOutOfMemoryError {};
|
||||
class OOMError : public interop::GPUOutOfMemoryError {
|
||||
public:
|
||||
explicit OOMError(std::string message) : message_(std::move(message)) {}
|
||||
|
||||
std::string getMessage(Napi::Env) override { return message_; };
|
||||
|
||||
private:
|
||||
std::string message_;
|
||||
};
|
||||
|
||||
class ValidationError : public interop::GPUValidationError {
|
||||
public:
|
||||
explicit ValidationError(std::string message) : message_(std::move(message)) {}
|
||||
|
@ -436,8 +445,9 @@ void GPUDevice::pushErrorScope(Napi::Env env, interop::GPUErrorFilter filter) {
|
|||
device_.PushErrorScope(f);
|
||||
}
|
||||
|
||||
interop::Promise<std::optional<interop::GPUError>> GPUDevice::popErrorScope(Napi::Env env) {
|
||||
using Promise = interop::Promise<std::optional<interop::GPUError>>;
|
||||
interop::Promise<std::optional<interop::Interface<interop::GPUError>>> GPUDevice::popErrorScope(
|
||||
Napi::Env env) {
|
||||
using Promise = interop::Promise<std::optional<interop::Interface<interop::GPUError>>>;
|
||||
struct Context {
|
||||
Napi::Env env;
|
||||
Promise promise;
|
||||
|
@ -454,13 +464,18 @@ interop::Promise<std::optional<interop::GPUError>> GPUDevice::popErrorScope(Napi
|
|||
case WGPUErrorType::WGPUErrorType_NoError:
|
||||
c->promise.Resolve({});
|
||||
break;
|
||||
case WGPUErrorType::WGPUErrorType_OutOfMemory:
|
||||
c->promise.Resolve(interop::GPUOutOfMemoryError::Create<OOMError>(env));
|
||||
case WGPUErrorType::WGPUErrorType_OutOfMemory: {
|
||||
interop::Interface<interop::GPUError> err{
|
||||
interop::GPUOutOfMemoryError::Create<OOMError>(env, message)};
|
||||
c->promise.Resolve(err);
|
||||
break;
|
||||
case WGPUErrorType::WGPUErrorType_Validation:
|
||||
c->promise.Resolve(
|
||||
interop::GPUValidationError::Create<ValidationError>(env, message));
|
||||
}
|
||||
case WGPUErrorType::WGPUErrorType_Validation: {
|
||||
interop::Interface<interop::GPUError> err{
|
||||
interop::GPUValidationError::Create<ValidationError>(env, message)};
|
||||
c->promise.Resolve(err);
|
||||
break;
|
||||
}
|
||||
case WGPUErrorType::WGPUErrorType_Unknown:
|
||||
case WGPUErrorType::WGPUErrorType_DeviceLost:
|
||||
c->promise.Reject(Errors::OperationError(env, message));
|
||||
|
|
|
@ -83,7 +83,8 @@ class GPUDevice final : public interop::GPUDevice {
|
|||
interop::Promise<interop::Interface<interop::GPUDeviceLostInfo>> getLost(
|
||||
Napi::Env env) override;
|
||||
void pushErrorScope(Napi::Env, interop::GPUErrorFilter filter) override;
|
||||
interop::Promise<std::optional<interop::GPUError>> popErrorScope(Napi::Env env) override;
|
||||
interop::Promise<std::optional<interop::Interface<interop::GPUError>>> popErrorScope(
|
||||
Napi::Env env) override;
|
||||
std::string getLabel(Napi::Env) override;
|
||||
void setLabel(Napi::Env, std::string value) override;
|
||||
interop::Interface<interop::EventHandler> getOnuncapturederror(Napi::Env) override;
|
||||
|
|
|
@ -29,6 +29,14 @@ void GPUQuerySet::destroy(Napi::Env) {
|
|||
query_set_.Destroy();
|
||||
}
|
||||
|
||||
interop::GPUQueryType GPUQuerySet::getType(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUSize32 GPUQuerySet::getCount(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
std::string GPUQuerySet::getLabel(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ class GPUQuerySet final : public interop::GPUQuerySet {
|
|||
|
||||
// interop::GPUQuerySet interface compliance
|
||||
void destroy(Napi::Env) override;
|
||||
interop::GPUQueryType getType(Napi::Env) override;
|
||||
interop::GPUSize32 getCount(Napi::Env) override;
|
||||
std::string getLabel(Napi::Env) override;
|
||||
void setLabel(Napi::Env, std::string value) override;
|
||||
|
||||
|
|
|
@ -104,6 +104,11 @@ uint32_t GPUSupportedLimits::getMaxInterStageShaderComponents(Napi::Env) {
|
|||
return limits_.limits.maxInterStageShaderComponents;
|
||||
}
|
||||
|
||||
uint32_t GPUSupportedLimits::getMaxInterStageShaderVariables(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
// return limits_.limits.maxInterStageShaderVariables;
|
||||
}
|
||||
|
||||
uint32_t GPUSupportedLimits::getMaxComputeWorkgroupStorageSize(Napi::Env) {
|
||||
return limits_.limits.maxComputeWorkgroupStorageSize;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ class GPUSupportedLimits final : public interop::GPUSupportedLimits {
|
|||
uint32_t getMaxVertexAttributes(Napi::Env) override;
|
||||
uint32_t getMaxVertexBufferArrayStride(Napi::Env) override;
|
||||
uint32_t getMaxInterStageShaderComponents(Napi::Env) override;
|
||||
uint32_t getMaxInterStageShaderVariables(Napi::Env) override;
|
||||
uint32_t getMaxComputeWorkgroupStorageSize(Napi::Env) override;
|
||||
uint32_t getMaxComputeInvocationsPerWorkgroup(Napi::Env) override;
|
||||
uint32_t getMaxComputeWorkgroupSizeX(Napi::Env) override;
|
||||
|
|
|
@ -54,6 +54,38 @@ void GPUTexture::destroy(Napi::Env) {
|
|||
texture_.Destroy();
|
||||
}
|
||||
|
||||
interop::GPUIntegerCoordinate GPUTexture::getWidth(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUIntegerCoordinate GPUTexture::getHeight(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUIntegerCoordinate GPUTexture::getDepthOrArrayLayers(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUIntegerCoordinate GPUTexture::getMipLevelCount(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUSize32 GPUTexture::getSampleCount(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUTextureDimension GPUTexture::getDimension(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUTextureFormat GPUTexture::getFormat(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
interop::GPUTextureUsageFlags GPUTexture::getUsage(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
std::string GPUTexture::getLabel(Napi::Env) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
|
|
@ -37,6 +37,14 @@ class GPUTexture final : public interop::GPUTexture {
|
|||
Napi::Env,
|
||||
interop::GPUTextureViewDescriptor descriptor) override;
|
||||
void destroy(Napi::Env) override;
|
||||
interop::GPUIntegerCoordinate getWidth(Napi::Env) override;
|
||||
interop::GPUIntegerCoordinate getHeight(Napi::Env) override;
|
||||
interop::GPUIntegerCoordinate getDepthOrArrayLayers(Napi::Env) override;
|
||||
interop::GPUIntegerCoordinate getMipLevelCount(Napi::Env) override;
|
||||
interop::GPUSize32 getSampleCount(Napi::Env) override;
|
||||
interop::GPUTextureDimension getDimension(Napi::Env) override;
|
||||
interop::GPUTextureFormat getFormat(Napi::Env) override;
|
||||
interop::GPUTextureUsageFlags getUsage(Napi::Env) override;
|
||||
std::string getLabel(Napi::Env) override;
|
||||
void setLabel(Napi::Env, std::string value) override;
|
||||
|
||||
|
|
|
@ -86,3 +86,5 @@ typedef(ArrayBufferView or ArrayBuffer) BufferSource;
|
|||
};
|
||||
|
||||
[LegacyNoInterfaceObject] interface EventHandler{};
|
||||
|
||||
enum PredefinedColorSpace { "srgb", "display-p3" };
|
||||
|
|
Loading…
Reference in New Issue