diff --git a/DEPS b/DEPS index 6159c7aeb8..ee3831b3ef 100644 --- a/DEPS +++ b/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', }, diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp index 65c59a5bde..cad53f67e4 100644 --- a/src/dawn/node/binding/Converter.cpp +++ b/src/dawn/node/binding/Converter.cpp @@ -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 diff --git a/src/dawn/node/binding/Converter.h b/src/dawn/node/binding/Converter.h index fb94598376..e0ef58c017 100644 --- a/src/dawn/node/binding/Converter.h +++ b/src/dawn/node/binding/Converter.h @@ -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(); diff --git a/src/dawn/node/binding/GPU.cpp b/src/dawn/node/binding/GPU.cpp index 1b147ed37f..beeaa83863 100644 --- a/src/dawn/node/binding/GPU.cpp +++ b/src/dawn/node/binding/GPU.cpp @@ -165,4 +165,8 @@ interop::Promise>> GPU::re 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 8ccafff99b..aa6956e5a8 100644 --- a/src/dawn/node/binding/GPU.h +++ b/src/dawn/node/binding/GPU.h @@ -32,6 +32,7 @@ class GPU final : public interop::GPU { interop::Promise>> 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 be3864c2a8..511225e297 100644 --- a/src/dawn/node/binding/GPUAdapter.cpp +++ b/src/dawn/node/binding/GPUAdapter.cpp @@ -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 GPUAdapter::getFeatures(Napi::Env env) { return interop::GPUSupportedFeatures::Create(env, adapter_.GetAdapterProperties()); } @@ -205,15 +196,13 @@ interop::Promise> 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> GPUAdapter::requestDevi } return promise; } + +interop::Promise> GPUAdapter::requestAdapterInfo( + Napi::Env, + std::vector unmaskHints) { + UNIMPLEMENTED(); +} + } // namespace wgpu::binding diff --git a/src/dawn/node/binding/GPUAdapter.h b/src/dawn/node/binding/GPUAdapter.h index c8c8cb39c6..60b8436ab0 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 +#include #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 getFeatures(Napi::Env) override; - interop::Interface getLimits(Napi::Env) override; - bool getIsFallbackAdapter(Napi::Env) override; interop::Promise> requestDevice( Napi::Env env, interop::GPUDeviceDescriptor descriptor) override; + interop::Promise> requestAdapterInfo( + Napi::Env, + std::vector unmaskHints) override; + interop::Interface getFeatures(Napi::Env) override; + interop::Interface 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 4c2a90e54c..afe0735f68 100644 --- a/src/dawn/node/binding/GPUBuffer.cpp +++ b/src/dawn/node/binding/GPUBuffer.cpp @@ -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(); diff --git a/src/dawn/node/binding/GPUBuffer.h b/src/dawn/node/binding/GPUBuffer.h index f4e1b30e38..250f41b7f5 100644 --- a/src/dawn/node/binding/GPUBuffer.h +++ b/src/dawn/node/binding/GPUBuffer.h @@ -51,6 +51,8 @@ class GPUBuffer final : public interop::GPUBuffer { std::optional 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 45ab83b3ee..5239ce16e1 100644 --- a/src/dawn/node/binding/GPUDevice.cpp +++ b/src/dawn/node/binding/GPUDevice.cpp @@ -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> GPUDevice::popErrorScope(Napi::Env env) { - using Promise = interop::Promise>; +interop::Promise>> GPUDevice::popErrorScope( + Napi::Env env) { + using Promise = interop::Promise>>; struct Context { Napi::Env env; Promise promise; @@ -454,13 +464,18 @@ interop::Promise> GPUDevice::popErrorScope(Napi case WGPUErrorType::WGPUErrorType_NoError: c->promise.Resolve({}); break; - case WGPUErrorType::WGPUErrorType_OutOfMemory: - c->promise.Resolve(interop::GPUOutOfMemoryError::Create(env)); + case WGPUErrorType::WGPUErrorType_OutOfMemory: { + interop::Interface err{ + interop::GPUOutOfMemoryError::Create(env, message)}; + c->promise.Resolve(err); break; - case WGPUErrorType::WGPUErrorType_Validation: - c->promise.Resolve( - interop::GPUValidationError::Create(env, message)); + } + case WGPUErrorType::WGPUErrorType_Validation: { + interop::Interface err{ + interop::GPUValidationError::Create(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 57a4c2ca51..02a2ea80b1 100644 --- a/src/dawn/node/binding/GPUDevice.h +++ b/src/dawn/node/binding/GPUDevice.h @@ -83,7 +83,8 @@ class GPUDevice final : public interop::GPUDevice { interop::Promise> getLost( Napi::Env env) override; void pushErrorScope(Napi::Env, interop::GPUErrorFilter filter) override; - interop::Promise> popErrorScope(Napi::Env env) override; + interop::Promise>> popErrorScope( + Napi::Env env) override; std::string getLabel(Napi::Env) override; void setLabel(Napi::Env, std::string value) override; interop::Interface getOnuncapturederror(Napi::Env) override; diff --git a/src/dawn/node/binding/GPUQuerySet.cpp b/src/dawn/node/binding/GPUQuerySet.cpp index 3197d987e4..08a8a4700b 100644 --- a/src/dawn/node/binding/GPUQuerySet.cpp +++ b/src/dawn/node/binding/GPUQuerySet.cpp @@ -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(); } diff --git a/src/dawn/node/binding/GPUQuerySet.h b/src/dawn/node/binding/GPUQuerySet.h index 7c0e9dd163..d2bced17fa 100644 --- a/src/dawn/node/binding/GPUQuerySet.h +++ b/src/dawn/node/binding/GPUQuerySet.h @@ -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; diff --git a/src/dawn/node/binding/GPUSupportedLimits.cpp b/src/dawn/node/binding/GPUSupportedLimits.cpp index 341385f89e..83a5cb2b29 100644 --- a/src/dawn/node/binding/GPUSupportedLimits.cpp +++ b/src/dawn/node/binding/GPUSupportedLimits.cpp @@ -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; } diff --git a/src/dawn/node/binding/GPUSupportedLimits.h b/src/dawn/node/binding/GPUSupportedLimits.h index 337db00d8c..246da4d41f 100644 --- a/src/dawn/node/binding/GPUSupportedLimits.h +++ b/src/dawn/node/binding/GPUSupportedLimits.h @@ -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; diff --git a/src/dawn/node/binding/GPUTexture.cpp b/src/dawn/node/binding/GPUTexture.cpp index 61ca716b35..38aaac598d 100644 --- a/src/dawn/node/binding/GPUTexture.cpp +++ b/src/dawn/node/binding/GPUTexture.cpp @@ -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(); } diff --git a/src/dawn/node/binding/GPUTexture.h b/src/dawn/node/binding/GPUTexture.h index edc96d103a..e108d78184 100644 --- a/src/dawn/node/binding/GPUTexture.h +++ b/src/dawn/node/binding/GPUTexture.h @@ -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; diff --git a/src/dawn/node/interop/Browser.idl b/src/dawn/node/interop/Browser.idl index b36c667b2d..44638f62ab 100644 --- a/src/dawn/node/interop/Browser.idl +++ b/src/dawn/node/interop/Browser.idl @@ -86,3 +86,5 @@ typedef(ArrayBufferView or ArrayBuffer) BufferSource; }; [LegacyNoInterfaceObject] interface EventHandler{}; + +enum PredefinedColorSpace { "srgb", "display-p3" };