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:
Ben Clayton 2022-06-07 23:45:21 +00:00 committed by Dawn LUCI CQ
parent af510d7c6a
commit b853164261
18 changed files with 126 additions and 35 deletions

2
DEPS
View File

@ -169,7 +169,7 @@ deps = {
'condition': 'dawn_node', 'condition': 'dawn_node',
}, },
'third_party/gpuweb': { 'third_party/gpuweb': {
'url': '{github_git}/gpuweb/gpuweb.git@16df823c91c9045b7cdf9bd0f2c0ef6d43ac95e7', 'url': '{github_git}/gpuweb/gpuweb.git@3c4734b09c68eb800b15da5e9ecefeca735fa7df',
'condition': 'dawn_node', 'condition': 'dawn_node',
}, },

View File

@ -295,9 +295,6 @@ bool Converter::Convert(wgpu::TextureFormat& out, const interop::GPUTextureForma
case interop::GPUTextureFormat::kDepth32Float: case interop::GPUTextureFormat::kDepth32Float:
out = wgpu::TextureFormat::Depth32Float; out = wgpu::TextureFormat::Depth32Float;
return true; return true;
case interop::GPUTextureFormat::kDepth24UnormStencil8:
out = wgpu::TextureFormat::Depth24UnormStencil8;
return true;
case interop::GPUTextureFormat::kDepth32FloatStencil8: case interop::GPUTextureFormat::kDepth32FloatStencil8:
out = wgpu::TextureFormat::Depth32FloatStencil8; out = wgpu::TextureFormat::Depth32FloatStencil8;
return true; return true;
@ -1217,4 +1214,9 @@ bool Converter::Convert(wgpu::RenderPipelineDescriptor& out,
Convert(out.fragment, in.fragment); Convert(out.fragment, in.fragment);
} }
bool Converter::Convert(wgpu::PipelineLayout& out, const interop::GPUAutoLayoutMode& in) {
out = nullptr;
return true;
}
} // namespace wgpu::binding } // namespace wgpu::binding

View File

@ -243,6 +243,8 @@ class Converter {
[[nodiscard]] bool Convert(wgpu::RenderPipelineDescriptor& out, [[nodiscard]] bool Convert(wgpu::RenderPipelineDescriptor& out,
const interop::GPURenderPipelineDescriptor& in); const interop::GPURenderPipelineDescriptor& in);
[[nodiscard]] bool Convert(wgpu::PipelineLayout& out, const interop::GPUAutoLayoutMode& in);
// std::string to C string // std::string to C string
inline bool Convert(const char*& out, const std::string& in) { inline bool Convert(const char*& out, const std::string& in) {
out = in.c_str(); out = in.c_str();

View File

@ -165,4 +165,8 @@ interop::Promise<std::optional<interop::Interface<interop::GPUAdapter>>> GPU::re
return promise; return promise;
} }
interop::GPUTextureFormat GPU::getPreferredCanvasFormat(Napi::Env) {
UNIMPLEMENTED();
}
} // namespace wgpu::binding } // namespace wgpu::binding

View File

@ -32,6 +32,7 @@ class GPU final : public interop::GPU {
interop::Promise<std::optional<interop::Interface<interop::GPUAdapter>>> requestAdapter( interop::Promise<std::optional<interop::Interface<interop::GPUAdapter>>> requestAdapter(
Napi::Env env, Napi::Env env,
interop::GPURequestAdapterOptions options) override; interop::GPURequestAdapterOptions options) override;
interop::GPUTextureFormat getPreferredCanvasFormat(Napi::Env) override;
private: private:
const Flags flags_; const Flags flags_;

View File

@ -92,9 +92,6 @@ namespace {
class Features : public interop::GPUSupportedFeatures { class Features : public interop::GPUSupportedFeatures {
public: public:
explicit Features(WGPUDeviceProperties properties) { explicit Features(WGPUDeviceProperties properties) {
if (properties.depth24UnormStencil8) {
enabled_.emplace(interop::GPUFeatureName::kDepth24UnormStencil8);
}
if (properties.depth32FloatStencil8) { if (properties.depth32FloatStencil8) {
enabled_.emplace(interop::GPUFeatureName::kDepth32FloatStencil8); enabled_.emplace(interop::GPUFeatureName::kDepth32FloatStencil8);
} }
@ -115,8 +112,10 @@ class Features : public interop::GPUSupportedFeatures {
} }
// TODO(dawn:1123) add support for these extensions when possible. // TODO(dawn:1123) add support for these extensions when possible.
// wgpu::interop::GPUFeatureName::kIndirectFirstInstance
// wgpu::interop::GPUFeatureName::kDepthClipControl // 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; } bool has(interop::GPUFeatureName feature) { return enabled_.count(feature) != 0; }
@ -148,18 +147,10 @@ class Features : public interop::GPUSupportedFeatures {
// wgpu::bindings::GPUAdapter // wgpu::bindings::GPUAdapter
// TODO(crbug.com/dawn/1133): This is a stub implementation. Properly implement. // 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) { GPUAdapter::GPUAdapter(dawn::native::Adapter a, const Flags& flags) : adapter_(a), flags_(flags) {}
wgpu::AdapterProperties props;
adapter_.GetProperties(&props);
name_ = props.name;
}
// TODO(dawn:1133): Avoid the extra copy by making the generator make a virtual method with const // TODO(dawn:1133): Avoid the extra copy by making the generator make a virtual method with const
// std::string& // std::string&
std::string GPUAdapter::getName(Napi::Env) {
return name_;
}
interop::Interface<interop::GPUSupportedFeatures> GPUAdapter::getFeatures(Napi::Env env) { interop::Interface<interop::GPUSupportedFeatures> GPUAdapter::getFeatures(Napi::Env env) {
return interop::GPUSupportedFeatures::Create<Features>(env, adapter_.GetAdapterProperties()); return interop::GPUSupportedFeatures::Create<Features>(env, adapter_.GetAdapterProperties());
} }
@ -205,15 +196,13 @@ interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevi
case interop::GPUFeatureName::kTimestampQuery: case interop::GPUFeatureName::kTimestampQuery:
requiredFeatures.emplace_back(wgpu::FeatureName::TimestampQuery); requiredFeatures.emplace_back(wgpu::FeatureName::TimestampQuery);
continue; continue;
case interop::GPUFeatureName::kDepth24UnormStencil8:
requiredFeatures.emplace_back(wgpu::FeatureName::Depth24UnormStencil8);
continue;
case interop::GPUFeatureName::kDepth32FloatStencil8: case interop::GPUFeatureName::kDepth32FloatStencil8:
requiredFeatures.emplace_back(wgpu::FeatureName::Depth32FloatStencil8); requiredFeatures.emplace_back(wgpu::FeatureName::Depth32FloatStencil8);
continue; continue;
case interop::GPUFeatureName::kDepthClipControl: case interop::GPUFeatureName::kDepthClipControl:
case interop::GPUFeatureName::kIndirectFirstInstance:
case interop::GPUFeatureName::kShaderF16: case interop::GPUFeatureName::kShaderF16:
case interop::GPUFeatureName::kIndirectFirstInstance:
case interop::GPUFeatureName::kBgra8UnormStorage:
// TODO(dawn:1123) Add support for these extensions when possible. // TODO(dawn:1123) Add support for these extensions when possible.
continue; continue;
} }
@ -274,4 +263,11 @@ interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevi
} }
return promise; return promise;
} }
interop::Promise<interop::Interface<interop::GPUAdapterInfo>> GPUAdapter::requestAdapterInfo(
Napi::Env,
std::vector<std::string> unmaskHints) {
UNIMPLEMENTED();
}
} // namespace wgpu::binding } // namespace wgpu::binding

View File

@ -16,6 +16,7 @@
#define SRC_DAWN_NODE_BINDING_GPUADAPTER_H_ #define SRC_DAWN_NODE_BINDING_GPUADAPTER_H_
#include <string> #include <string>
#include <vector>
#include "dawn/native/DawnNative.h" #include "dawn/native/DawnNative.h"
#include "dawn/webgpu_cpp.h" #include "dawn/webgpu_cpp.h"
@ -31,18 +32,19 @@ class GPUAdapter final : public interop::GPUAdapter {
GPUAdapter(dawn::native::Adapter a, const Flags& flags); GPUAdapter(dawn::native::Adapter a, const Flags& flags);
// interop::GPUAdapter interface compliance // 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( interop::Promise<interop::Interface<interop::GPUDevice>> requestDevice(
Napi::Env env, Napi::Env env,
interop::GPUDeviceDescriptor descriptor) override; 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: private:
dawn::native::Adapter adapter_; dawn::native::Adapter adapter_;
const Flags& flags_; const Flags& flags_;
std::string name_;
}; };
} // namespace wgpu::binding } // namespace wgpu::binding

View File

@ -162,6 +162,14 @@ void GPUBuffer::destroy(Napi::Env) {
state_ = State::Destroyed; state_ = State::Destroyed;
} }
interop::GPUSize64 GPUBuffer::getSize(Napi::Env) {
UNIMPLEMENTED();
}
interop::GPUBufferUsageFlags GPUBuffer::getUsage(Napi::Env) {
UNIMPLEMENTED();
}
void GPUBuffer::DetachMappings() { void GPUBuffer::DetachMappings() {
for (auto& mapping : mapped_) { for (auto& mapping : mapped_) {
mapping.buffer.Value().Detach(); mapping.buffer.Value().Detach();

View File

@ -51,6 +51,8 @@ class GPUBuffer final : public interop::GPUBuffer {
std::optional<interop::GPUSize64> size) override; std::optional<interop::GPUSize64> size) override;
void unmap(Napi::Env) override; void unmap(Napi::Env) override;
void destroy(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; std::string getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::string value) override; void setLabel(Napi::Env, std::string value) override;

View File

@ -56,7 +56,16 @@ class DeviceLostInfo : public interop::GPUDeviceLostInfo {
std::string message_; 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 { class ValidationError : public interop::GPUValidationError {
public: public:
explicit ValidationError(std::string message) : message_(std::move(message)) {} 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); device_.PushErrorScope(f);
} }
interop::Promise<std::optional<interop::GPUError>> GPUDevice::popErrorScope(Napi::Env env) { interop::Promise<std::optional<interop::Interface<interop::GPUError>>> GPUDevice::popErrorScope(
using Promise = interop::Promise<std::optional<interop::GPUError>>; Napi::Env env) {
using Promise = interop::Promise<std::optional<interop::Interface<interop::GPUError>>>;
struct Context { struct Context {
Napi::Env env; Napi::Env env;
Promise promise; Promise promise;
@ -454,13 +464,18 @@ interop::Promise<std::optional<interop::GPUError>> GPUDevice::popErrorScope(Napi
case WGPUErrorType::WGPUErrorType_NoError: case WGPUErrorType::WGPUErrorType_NoError:
c->promise.Resolve({}); c->promise.Resolve({});
break; break;
case WGPUErrorType::WGPUErrorType_OutOfMemory: case WGPUErrorType::WGPUErrorType_OutOfMemory: {
c->promise.Resolve(interop::GPUOutOfMemoryError::Create<OOMError>(env)); interop::Interface<interop::GPUError> err{
interop::GPUOutOfMemoryError::Create<OOMError>(env, message)};
c->promise.Resolve(err);
break; break;
case WGPUErrorType::WGPUErrorType_Validation: }
c->promise.Resolve( case WGPUErrorType::WGPUErrorType_Validation: {
interop::GPUValidationError::Create<ValidationError>(env, message)); interop::Interface<interop::GPUError> err{
interop::GPUValidationError::Create<ValidationError>(env, message)};
c->promise.Resolve(err);
break; break;
}
case WGPUErrorType::WGPUErrorType_Unknown: case WGPUErrorType::WGPUErrorType_Unknown:
case WGPUErrorType::WGPUErrorType_DeviceLost: case WGPUErrorType::WGPUErrorType_DeviceLost:
c->promise.Reject(Errors::OperationError(env, message)); c->promise.Reject(Errors::OperationError(env, message));

View File

@ -83,7 +83,8 @@ class GPUDevice final : public interop::GPUDevice {
interop::Promise<interop::Interface<interop::GPUDeviceLostInfo>> getLost( interop::Promise<interop::Interface<interop::GPUDeviceLostInfo>> getLost(
Napi::Env env) override; Napi::Env env) override;
void pushErrorScope(Napi::Env, interop::GPUErrorFilter filter) 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; std::string getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::string value) override; void setLabel(Napi::Env, std::string value) override;
interop::Interface<interop::EventHandler> getOnuncapturederror(Napi::Env) override; interop::Interface<interop::EventHandler> getOnuncapturederror(Napi::Env) override;

View File

@ -29,6 +29,14 @@ void GPUQuerySet::destroy(Napi::Env) {
query_set_.Destroy(); query_set_.Destroy();
} }
interop::GPUQueryType GPUQuerySet::getType(Napi::Env) {
UNIMPLEMENTED();
}
interop::GPUSize32 GPUQuerySet::getCount(Napi::Env) {
UNIMPLEMENTED();
}
std::string GPUQuerySet::getLabel(Napi::Env) { std::string GPUQuerySet::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -34,6 +34,8 @@ class GPUQuerySet final : public interop::GPUQuerySet {
// interop::GPUQuerySet interface compliance // interop::GPUQuerySet interface compliance
void destroy(Napi::Env) override; void destroy(Napi::Env) override;
interop::GPUQueryType getType(Napi::Env) override;
interop::GPUSize32 getCount(Napi::Env) override;
std::string getLabel(Napi::Env) override; std::string getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::string value) override; void setLabel(Napi::Env, std::string value) override;

View File

@ -104,6 +104,11 @@ uint32_t GPUSupportedLimits::getMaxInterStageShaderComponents(Napi::Env) {
return limits_.limits.maxInterStageShaderComponents; return limits_.limits.maxInterStageShaderComponents;
} }
uint32_t GPUSupportedLimits::getMaxInterStageShaderVariables(Napi::Env) {
UNIMPLEMENTED();
// return limits_.limits.maxInterStageShaderVariables;
}
uint32_t GPUSupportedLimits::getMaxComputeWorkgroupStorageSize(Napi::Env) { uint32_t GPUSupportedLimits::getMaxComputeWorkgroupStorageSize(Napi::Env) {
return limits_.limits.maxComputeWorkgroupStorageSize; return limits_.limits.maxComputeWorkgroupStorageSize;
} }

View File

@ -49,6 +49,7 @@ class GPUSupportedLimits final : public interop::GPUSupportedLimits {
uint32_t getMaxVertexAttributes(Napi::Env) override; uint32_t getMaxVertexAttributes(Napi::Env) override;
uint32_t getMaxVertexBufferArrayStride(Napi::Env) override; uint32_t getMaxVertexBufferArrayStride(Napi::Env) override;
uint32_t getMaxInterStageShaderComponents(Napi::Env) override; uint32_t getMaxInterStageShaderComponents(Napi::Env) override;
uint32_t getMaxInterStageShaderVariables(Napi::Env) override;
uint32_t getMaxComputeWorkgroupStorageSize(Napi::Env) override; uint32_t getMaxComputeWorkgroupStorageSize(Napi::Env) override;
uint32_t getMaxComputeInvocationsPerWorkgroup(Napi::Env) override; uint32_t getMaxComputeInvocationsPerWorkgroup(Napi::Env) override;
uint32_t getMaxComputeWorkgroupSizeX(Napi::Env) override; uint32_t getMaxComputeWorkgroupSizeX(Napi::Env) override;

View File

@ -54,6 +54,38 @@ void GPUTexture::destroy(Napi::Env) {
texture_.Destroy(); 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) { std::string GPUTexture::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -37,6 +37,14 @@ class GPUTexture final : public interop::GPUTexture {
Napi::Env, Napi::Env,
interop::GPUTextureViewDescriptor descriptor) override; interop::GPUTextureViewDescriptor descriptor) override;
void destroy(Napi::Env) 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; std::string getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::string value) override; void setLabel(Napi::Env, std::string value) override;

View File

@ -86,3 +86,5 @@ typedef(ArrayBufferView or ArrayBuffer) BufferSource;
}; };
[LegacyNoInterfaceObject] interface EventHandler{}; [LegacyNoInterfaceObject] interface EventHandler{};
enum PredefinedColorSpace { "srgb", "display-p3" };