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>
diff --git a/DEPS b/DEPS
index 6159c7a..ee3831b 100644
--- a/DEPS
+++ b/DEPS
@@ -169,7 +169,7 @@
'condition': 'dawn_node',
},
'third_party/gpuweb': {
- 'url': '{github_git}/gpuweb/gpuweb.git@16df823c91c9045b7cdf9bd0f2c0ef6d43ac95e7',
+ 'url': '{github_git}/gpuweb/gpuweb.git@3c4734b09c68eb800b15da5e9ecefeca735fa7df',
'condition': 'dawn_node',
},
diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp
index 65c59a5..cad53f6 100644
--- a/src/dawn/node/binding/Converter.cpp
+++ b/src/dawn/node/binding/Converter.cpp
@@ -295,9 +295,6 @@
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 @@
Convert(out.fragment, in.fragment);
}
+bool Converter::Convert(wgpu::PipelineLayout& out, const interop::GPUAutoLayoutMode& in) {
+ out = nullptr;
+ return true;
+}
+
} // namespace wgpu::binding
diff --git a/src/dawn/node/binding/Converter.h b/src/dawn/node/binding/Converter.h
index fb94598..e0ef58c 100644
--- a/src/dawn/node/binding/Converter.h
+++ b/src/dawn/node/binding/Converter.h
@@ -243,6 +243,8 @@
[[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();
diff --git a/src/dawn/node/binding/GPU.cpp b/src/dawn/node/binding/GPU.cpp
index 1b147ed..beeaa83 100644
--- a/src/dawn/node/binding/GPU.cpp
+++ b/src/dawn/node/binding/GPU.cpp
@@ -165,4 +165,8 @@
return promise;
}
+interop::GPUTextureFormat GPU::getPreferredCanvasFormat(Napi::Env) {
+ UNIMPLEMENTED();
+}
+
} // namespace wgpu::binding
diff --git a/src/dawn/node/binding/GPU.h b/src/dawn/node/binding/GPU.h
index 8ccafff..aa6956e 100644
--- a/src/dawn/node/binding/GPU.h
+++ b/src/dawn/node/binding/GPU.h
@@ -32,6 +32,7 @@
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_;
diff --git a/src/dawn/node/binding/GPUAdapter.cpp b/src/dawn/node/binding/GPUAdapter.cpp
index be3864c..511225e 100644
--- a/src/dawn/node/binding/GPUAdapter.cpp
+++ b/src/dawn/node/binding/GPUAdapter.cpp
@@ -92,9 +92,6 @@
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 @@
}
// 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 @@
// 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 @@
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 @@
}
return promise;
}
+
+interop::Promise<interop::Interface<interop::GPUAdapterInfo>> GPUAdapter::requestAdapterInfo(
+ Napi::Env,
+ std::vector<std::string> unmaskHints) {
+ UNIMPLEMENTED();
+}
+
} // namespace wgpu::binding
diff --git a/src/dawn/node/binding/GPUAdapter.h b/src/dawn/node/binding/GPUAdapter.h
index c8c8cb3..60b8436 100644
--- a/src/dawn/node/binding/GPUAdapter.h
+++ b/src/dawn/node/binding/GPUAdapter.h
@@ -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 @@
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
diff --git a/src/dawn/node/binding/GPUBuffer.cpp b/src/dawn/node/binding/GPUBuffer.cpp
index 4c2a90e..afe0735 100644
--- a/src/dawn/node/binding/GPUBuffer.cpp
+++ b/src/dawn/node/binding/GPUBuffer.cpp
@@ -162,6 +162,14 @@
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();
diff --git a/src/dawn/node/binding/GPUBuffer.h b/src/dawn/node/binding/GPUBuffer.h
index f4e1b30..250f41b 100644
--- a/src/dawn/node/binding/GPUBuffer.h
+++ b/src/dawn/node/binding/GPUBuffer.h
@@ -51,6 +51,8 @@
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;
diff --git a/src/dawn/node/binding/GPUDevice.cpp b/src/dawn/node/binding/GPUDevice.cpp
index 45ab83b..5239ce1 100644
--- a/src/dawn/node/binding/GPUDevice.cpp
+++ b/src/dawn/node/binding/GPUDevice.cpp
@@ -56,7 +56,16 @@
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 @@
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 @@
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));
diff --git a/src/dawn/node/binding/GPUDevice.h b/src/dawn/node/binding/GPUDevice.h
index 57a4c2c..02a2ea8 100644
--- a/src/dawn/node/binding/GPUDevice.h
+++ b/src/dawn/node/binding/GPUDevice.h
@@ -83,7 +83,8 @@
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;
diff --git a/src/dawn/node/binding/GPUQuerySet.cpp b/src/dawn/node/binding/GPUQuerySet.cpp
index 3197d98..08a8a47 100644
--- a/src/dawn/node/binding/GPUQuerySet.cpp
+++ b/src/dawn/node/binding/GPUQuerySet.cpp
@@ -29,6 +29,14 @@
query_set_.Destroy();
}
+interop::GPUQueryType GPUQuerySet::getType(Napi::Env) {
+ UNIMPLEMENTED();
+}
+
+interop::GPUSize32 GPUQuerySet::getCount(Napi::Env) {
+ UNIMPLEMENTED();
+}
+
std::string GPUQuerySet::getLabel(Napi::Env) {
UNIMPLEMENTED();
}
diff --git a/src/dawn/node/binding/GPUQuerySet.h b/src/dawn/node/binding/GPUQuerySet.h
index 7c0e9dd..d2bced1 100644
--- a/src/dawn/node/binding/GPUQuerySet.h
+++ b/src/dawn/node/binding/GPUQuerySet.h
@@ -34,6 +34,8 @@
// 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;
diff --git a/src/dawn/node/binding/GPUSupportedLimits.cpp b/src/dawn/node/binding/GPUSupportedLimits.cpp
index 341385f..83a5cb2 100644
--- a/src/dawn/node/binding/GPUSupportedLimits.cpp
+++ b/src/dawn/node/binding/GPUSupportedLimits.cpp
@@ -104,6 +104,11 @@
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;
}
diff --git a/src/dawn/node/binding/GPUSupportedLimits.h b/src/dawn/node/binding/GPUSupportedLimits.h
index 337db00..246da4d 100644
--- a/src/dawn/node/binding/GPUSupportedLimits.h
+++ b/src/dawn/node/binding/GPUSupportedLimits.h
@@ -49,6 +49,7 @@
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;
diff --git a/src/dawn/node/binding/GPUTexture.cpp b/src/dawn/node/binding/GPUTexture.cpp
index 61ca716..38aaac5 100644
--- a/src/dawn/node/binding/GPUTexture.cpp
+++ b/src/dawn/node/binding/GPUTexture.cpp
@@ -54,6 +54,38 @@
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();
}
diff --git a/src/dawn/node/binding/GPUTexture.h b/src/dawn/node/binding/GPUTexture.h
index edc96d1..e108d78 100644
--- a/src/dawn/node/binding/GPUTexture.h
+++ b/src/dawn/node/binding/GPUTexture.h
@@ -37,6 +37,14 @@
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;
diff --git a/src/dawn/node/interop/Browser.idl b/src/dawn/node/interop/Browser.idl
index b36c667..44638f6 100644
--- a/src/dawn/node/interop/Browser.idl
+++ b/src/dawn/node/interop/Browser.idl
@@ -86,3 +86,5 @@
};
[LegacyNoInterfaceObject] interface EventHandler{};
+
+enum PredefinedColorSpace { "srgb", "display-p3" };