diff --git a/DEPS b/DEPS index 2e3f70293c..6eb750c587 100644 --- a/DEPS +++ b/DEPS @@ -162,7 +162,7 @@ deps = { 'condition': 'dawn_node', }, 'third_party/gpuweb': { - 'url': '{github_git}/gpuweb/gpuweb.git@0aadaca4c53ca131aa19708c1d2b1bed56da1118', + 'url': '{github_git}/gpuweb/gpuweb.git@881403b5fda2d9ac9ffc5daa24e34738205bf155', 'condition': 'dawn_node', }, diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp index 7387ce120b..e693a34a97 100644 --- a/src/dawn/node/binding/Converter.cpp +++ b/src/dawn/node/binding/Converter.cpp @@ -952,63 +952,24 @@ namespace wgpu::binding { bool Converter::Convert(wgpu::RenderPassColorAttachment& out, const interop::GPURenderPassColorAttachment& in) { out = {}; - if (auto* op = std::get_if(&in.loadValue)) { - if (!Convert(out.loadOp, *op)) { - return false; - } - } else if (auto* color = std::get_if(&in.loadValue)) { - out.loadOp = wgpu::LoadOp::Clear; - if (!Convert(out.clearColor, *color)) { - return false; - } - } else { - Napi::Error::New(env, "invalid value for GPURenderPassColorAttachment.loadValue") - .ThrowAsJavaScriptException(); - return false; - } - - return Convert(out.view, in.view) && Convert(out.resolveTarget, in.resolveTarget) && + return Convert(out.view, in.view) && // + Convert(out.resolveTarget, in.resolveTarget) && // + Convert(out.clearColor, in.clearValue) && // + Convert(out.loadOp, in.loadOp) && // Convert(out.storeOp, in.storeOp); } bool Converter::Convert(wgpu::RenderPassDepthStencilAttachment& out, const interop::GPURenderPassDepthStencilAttachment& in) { out = {}; - if (auto* op = std::get_if(&in.depthLoadValue)) { - if (!Convert(out.depthLoadOp, *op)) { - return false; - } - } else if (auto* value = std::get_if(&in.depthLoadValue)) { - out.stencilLoadOp = wgpu::LoadOp::Clear; - if (!Convert(out.clearDepth, *value)) { - return false; - } - } else { - Napi::Error::New(env, - "invalid value for GPURenderPassDepthStencilAttachment.depthLoadValue") - .ThrowAsJavaScriptException(); - return false; - } - - if (auto* op = std::get_if(&in.stencilLoadValue)) { - if (!Convert(out.stencilLoadOp, *op)) { - return false; - } - } else if (auto* value = std::get_if(&in.stencilLoadValue)) { - if (!Convert(out.clearStencil, *value)) { - return false; - } - } else { - Napi::Error::New(env, - "invalid value for " - "GPURenderPassDepthStencilAttachment.stencilLoadValue") - .ThrowAsJavaScriptException(); - return false; - } - - return Convert(out.view, in.view) && Convert(out.depthStoreOp, in.depthStoreOp) && - Convert(out.depthReadOnly, in.depthReadOnly) && - Convert(out.stencilStoreOp, in.stencilStoreOp) && + return Convert(out.view, in.view) && // + Convert(out.clearDepth, in.depthClearValue) && // + Convert(out.depthLoadOp, in.depthLoadOp) && // + Convert(out.depthStoreOp, in.depthStoreOp) && // + Convert(out.depthReadOnly, in.depthReadOnly) && // + Convert(out.clearStencil, in.stencilClearValue) && // + Convert(out.stencilLoadOp, in.stencilLoadOp) && // + Convert(out.stencilStoreOp, in.stencilStoreOp) && // Convert(out.stencilReadOnly, in.stencilReadOnly); } @@ -1018,6 +979,9 @@ namespace wgpu::binding { case interop::GPULoadOp::kLoad: out = wgpu::LoadOp::Load; return true; + case interop::GPULoadOp::kClear: + out = wgpu::LoadOp::Clear; + return true; } Napi::Error::New(env, "invalid value for GPULoadOp").ThrowAsJavaScriptException(); return false; diff --git a/src/dawn/node/binding/GPUBindGroup.cpp b/src/dawn/node/binding/GPUBindGroup.cpp index 36b092966a..1170cefa6f 100644 --- a/src/dawn/node/binding/GPUBindGroup.cpp +++ b/src/dawn/node/binding/GPUBindGroup.cpp @@ -24,11 +24,12 @@ namespace wgpu::binding { GPUBindGroup::GPUBindGroup(wgpu::BindGroup group) : group_(std::move(group)) { } - std::optional GPUBindGroup::getLabel(Napi::Env) { + std::variant GPUBindGroup::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUBindGroup::setLabel(Napi::Env, std::optional value) { + void GPUBindGroup::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUBindGroup.h b/src/dawn/node/binding/GPUBindGroup.h index b644b90645..54b005acb3 100644 --- a/src/dawn/node/binding/GPUBindGroup.h +++ b/src/dawn/node/binding/GPUBindGroup.h @@ -33,8 +33,8 @@ namespace wgpu::binding { } // interop::GPUBindGroup interface compliance - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; private: wgpu::BindGroup group_; diff --git a/src/dawn/node/binding/GPUBindGroupLayout.cpp b/src/dawn/node/binding/GPUBindGroupLayout.cpp index 6b1a5abcf5..5642150385 100644 --- a/src/dawn/node/binding/GPUBindGroupLayout.cpp +++ b/src/dawn/node/binding/GPUBindGroupLayout.cpp @@ -25,11 +25,12 @@ namespace wgpu::binding { : layout_(std::move(layout)) { } - std::optional GPUBindGroupLayout::getLabel(Napi::Env) { + std::variant GPUBindGroupLayout::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUBindGroupLayout::setLabel(Napi::Env, std::optional value) { + void GPUBindGroupLayout::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUBindGroupLayout.h b/src/dawn/node/binding/GPUBindGroupLayout.h index 009c96c29b..0382c479c0 100644 --- a/src/dawn/node/binding/GPUBindGroupLayout.h +++ b/src/dawn/node/binding/GPUBindGroupLayout.h @@ -34,8 +34,8 @@ namespace wgpu::binding { } // interop::GPUBindGroupLayout interface compliance - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::BindGroupLayout layout_; diff --git a/src/dawn/node/binding/GPUBuffer.cpp b/src/dawn/node/binding/GPUBuffer.cpp index 5f84bc100b..dbff2c5f0a 100644 --- a/src/dawn/node/binding/GPUBuffer.cpp +++ b/src/dawn/node/binding/GPUBuffer.cpp @@ -158,11 +158,11 @@ namespace wgpu::binding { state_ = State::Destroyed; } - std::optional GPUBuffer::getLabel(Napi::Env) { + std::variant GPUBuffer::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUBuffer::setLabel(Napi::Env, std::optional value) { + void GPUBuffer::setLabel(Napi::Env, std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUBuffer.h b/src/dawn/node/binding/GPUBuffer.h index 32cdfe6d3c..994bd1c75c 100644 --- a/src/dawn/node/binding/GPUBuffer.h +++ b/src/dawn/node/binding/GPUBuffer.h @@ -51,8 +51,8 @@ namespace wgpu::binding { std::optional size) override; void unmap(Napi::Env) override; void destroy(Napi::Env) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: struct Mapping { diff --git a/src/dawn/node/binding/GPUCommandBuffer.cpp b/src/dawn/node/binding/GPUCommandBuffer.cpp index ab0f7083a1..ac86c1dccd 100644 --- a/src/dawn/node/binding/GPUCommandBuffer.cpp +++ b/src/dawn/node/binding/GPUCommandBuffer.cpp @@ -25,11 +25,12 @@ namespace wgpu::binding { GPUCommandBuffer::GPUCommandBuffer(wgpu::CommandBuffer cmd_buf) : cmd_buf_(std::move(cmd_buf)) { } - std::optional GPUCommandBuffer::getLabel(Napi::Env) { + std::variant GPUCommandBuffer::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUCommandBuffer::setLabel(Napi::Env, std::optional value) { + void GPUCommandBuffer::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUCommandBuffer.h b/src/dawn/node/binding/GPUCommandBuffer.h index bd84d1b746..34604dc81a 100644 --- a/src/dawn/node/binding/GPUCommandBuffer.h +++ b/src/dawn/node/binding/GPUCommandBuffer.h @@ -34,8 +34,8 @@ namespace wgpu::binding { } // interop::GPUCommandBuffer interface compliance - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::CommandBuffer cmd_buf_; diff --git a/src/dawn/node/binding/GPUCommandEncoder.cpp b/src/dawn/node/binding/GPUCommandEncoder.cpp index b6beee6577..b707966280 100644 --- a/src/dawn/node/binding/GPUCommandEncoder.cpp +++ b/src/dawn/node/binding/GPUCommandEncoder.cpp @@ -204,11 +204,12 @@ namespace wgpu::binding { return interop::GPUCommandBuffer::Create(env, enc_.Finish(&desc)); } - std::optional GPUCommandEncoder::getLabel(Napi::Env) { + std::variant GPUCommandEncoder::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUCommandEncoder::setLabel(Napi::Env, std::optional value) { + void GPUCommandEncoder::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUCommandEncoder.h b/src/dawn/node/binding/GPUCommandEncoder.h index cf5a77dc8a..3b3179ab08 100644 --- a/src/dawn/node/binding/GPUCommandEncoder.h +++ b/src/dawn/node/binding/GPUCommandEncoder.h @@ -72,8 +72,8 @@ namespace wgpu::binding { interop::Interface finish( Napi::Env env, interop::GPUCommandBufferDescriptor descriptor) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::CommandEncoder enc_; diff --git a/src/dawn/node/binding/GPUComputePassEncoder.cpp b/src/dawn/node/binding/GPUComputePassEncoder.cpp index 224dc03e78..fa287710c7 100644 --- a/src/dawn/node/binding/GPUComputePassEncoder.cpp +++ b/src/dawn/node/binding/GPUComputePassEncoder.cpp @@ -54,10 +54,6 @@ namespace wgpu::binding { enc_.End(); } - void GPUComputePassEncoder::endPass(Napi::Env) { - enc_.EndPass(); - } - void GPUComputePassEncoder::setBindGroup( Napi::Env env, interop::GPUIndex32 index, @@ -104,11 +100,12 @@ namespace wgpu::binding { enc_.InsertDebugMarker(markerLabel.c_str()); } - std::optional GPUComputePassEncoder::getLabel(Napi::Env) { + std::variant GPUComputePassEncoder::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUComputePassEncoder::setLabel(Napi::Env, std::optional value) { + void GPUComputePassEncoder::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUComputePassEncoder.h b/src/dawn/node/binding/GPUComputePassEncoder.h index 01eab694b8..8b325cb758 100644 --- a/src/dawn/node/binding/GPUComputePassEncoder.h +++ b/src/dawn/node/binding/GPUComputePassEncoder.h @@ -44,7 +44,6 @@ namespace wgpu::binding { interop::Interface indirectBuffer, interop::GPUSize64 indirectOffset) override; void end(Napi::Env) override; - void endPass(Napi::Env) override; // TODO(dawn:1286): Remove after deprecation period. void setBindGroup(Napi::Env, interop::GPUIndex32 index, interop::Interface bindGroup, @@ -58,8 +57,8 @@ namespace wgpu::binding { void pushDebugGroup(Napi::Env, std::string groupLabel) override; void popDebugGroup(Napi::Env) override; void insertDebugMarker(Napi::Env, std::string markerLabel) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; private: wgpu::ComputePassEncoder enc_; diff --git a/src/dawn/node/binding/GPUComputePipeline.cpp b/src/dawn/node/binding/GPUComputePipeline.cpp index 9e57961d26..9ae09241e6 100644 --- a/src/dawn/node/binding/GPUComputePipeline.cpp +++ b/src/dawn/node/binding/GPUComputePipeline.cpp @@ -34,11 +34,12 @@ namespace wgpu::binding { env, pipeline_.GetBindGroupLayout(index)); } - std::optional GPUComputePipeline::getLabel(Napi::Env) { + std::variant GPUComputePipeline::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUComputePipeline::setLabel(Napi::Env, std::optional value) { + void GPUComputePipeline::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUComputePipeline.h b/src/dawn/node/binding/GPUComputePipeline.h index c37eb284ac..0410db0b14 100644 --- a/src/dawn/node/binding/GPUComputePipeline.h +++ b/src/dawn/node/binding/GPUComputePipeline.h @@ -36,8 +36,8 @@ namespace wgpu::binding { // interop::GPUComputePipeline interface compliance interop::Interface getBindGroupLayout(Napi::Env, uint32_t index) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::ComputePipeline pipeline_; diff --git a/src/dawn/node/binding/GPUDevice.cpp b/src/dawn/node/binding/GPUDevice.cpp index 2358b700f0..5d378d4150 100644 --- a/src/dawn/node/binding/GPUDevice.cpp +++ b/src/dawn/node/binding/GPUDevice.cpp @@ -44,7 +44,8 @@ namespace wgpu::binding { DeviceLostInfo(interop::GPUDeviceLostReason reason, std::string message) : reason_(reason), message_(message) { } - std::variant getReason(Napi::Env env) override { + std::variant getReason( + Napi::Env env) override { return reason_; } std::string getMessage(Napi::Env) override { @@ -488,11 +489,11 @@ namespace wgpu::binding { return promise; } - std::optional GPUDevice::getLabel(Napi::Env) { + std::variant GPUDevice::getLabel(Napi::Env) { UNIMPLEMENTED(); }; - void GPUDevice::setLabel(Napi::Env, std::optional value) { + void GPUDevice::setLabel(Napi::Env, std::variant value) { UNIMPLEMENTED(); }; diff --git a/src/dawn/node/binding/GPUDevice.h b/src/dawn/node/binding/GPUDevice.h index 84ba67d027..583439c8f6 100644 --- a/src/dawn/node/binding/GPUDevice.h +++ b/src/dawn/node/binding/GPUDevice.h @@ -81,8 +81,8 @@ namespace wgpu::binding { Napi::Env env) override; void pushErrorScope(Napi::Env, interop::GPUErrorFilter filter) override; interop::Promise> popErrorScope(Napi::Env env) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; interop::Interface getOnuncapturederror(Napi::Env) override; void setOnuncapturederror(Napi::Env, interop::Interface value) override; diff --git a/src/dawn/node/binding/GPUPipelineLayout.cpp b/src/dawn/node/binding/GPUPipelineLayout.cpp index 945fb4a876..4e0b5a9ef2 100644 --- a/src/dawn/node/binding/GPUPipelineLayout.cpp +++ b/src/dawn/node/binding/GPUPipelineLayout.cpp @@ -24,11 +24,12 @@ namespace wgpu::binding { GPUPipelineLayout::GPUPipelineLayout(wgpu::PipelineLayout layout) : layout_(std::move(layout)) { } - std::optional GPUPipelineLayout::getLabel(Napi::Env) { + std::variant GPUPipelineLayout::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUPipelineLayout::setLabel(Napi::Env, std::optional value) { + void GPUPipelineLayout::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUPipelineLayout.h b/src/dawn/node/binding/GPUPipelineLayout.h index 174b1611b5..a9c3bb6da9 100644 --- a/src/dawn/node/binding/GPUPipelineLayout.h +++ b/src/dawn/node/binding/GPUPipelineLayout.h @@ -34,8 +34,8 @@ namespace wgpu::binding { } // interop::GPUPipelineLayout interface compliance - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; private: wgpu::PipelineLayout layout_; diff --git a/src/dawn/node/binding/GPUQuerySet.cpp b/src/dawn/node/binding/GPUQuerySet.cpp index b0714f4849..e9f0e3f979 100644 --- a/src/dawn/node/binding/GPUQuerySet.cpp +++ b/src/dawn/node/binding/GPUQuerySet.cpp @@ -28,11 +28,11 @@ namespace wgpu::binding { query_set_.Destroy(); } - std::optional GPUQuerySet::getLabel(Napi::Env) { + std::variant GPUQuerySet::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUQuerySet::setLabel(Napi::Env, std::optional value) { + void GPUQuerySet::setLabel(Napi::Env, std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUQuerySet.h b/src/dawn/node/binding/GPUQuerySet.h index a7e37d3b56..2ae99eb3a2 100644 --- a/src/dawn/node/binding/GPUQuerySet.h +++ b/src/dawn/node/binding/GPUQuerySet.h @@ -34,8 +34,8 @@ namespace wgpu::binding { // interop::GPUQuerySet interface compliance void destroy(Napi::Env) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; private: wgpu::QuerySet query_set_; diff --git a/src/dawn/node/binding/GPUQueue.cpp b/src/dawn/node/binding/GPUQueue.cpp index e7f7a7290a..6081e00ae5 100644 --- a/src/dawn/node/binding/GPUQueue.cpp +++ b/src/dawn/node/binding/GPUQueue.cpp @@ -121,11 +121,11 @@ namespace wgpu::binding { UNIMPLEMENTED(); } - std::optional GPUQueue::getLabel(Napi::Env) { + std::variant GPUQueue::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUQueue::setLabel(Napi::Env, std::optional value) { + void GPUQueue::setLabel(Napi::Env, std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUQueue.h b/src/dawn/node/binding/GPUQueue.h index be8ba8c712..0c5ba7d6e6 100644 --- a/src/dawn/node/binding/GPUQueue.h +++ b/src/dawn/node/binding/GPUQueue.h @@ -48,8 +48,8 @@ namespace wgpu::binding { interop::GPUImageCopyExternalImage source, interop::GPUImageCopyTextureTagged destination, interop::GPUExtent3D copySize) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::Queue queue_; diff --git a/src/dawn/node/binding/GPURenderBundle.cpp b/src/dawn/node/binding/GPURenderBundle.cpp index c136d03439..b741817086 100644 --- a/src/dawn/node/binding/GPURenderBundle.cpp +++ b/src/dawn/node/binding/GPURenderBundle.cpp @@ -28,11 +28,12 @@ namespace wgpu::binding { GPURenderBundle::GPURenderBundle(wgpu::RenderBundle bundle) : bundle_(std::move(bundle)) { } - std::optional GPURenderBundle::getLabel(Napi::Env) { + std::variant GPURenderBundle::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPURenderBundle::setLabel(Napi::Env, std::optional value) { + void GPURenderBundle::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPURenderBundle.h b/src/dawn/node/binding/GPURenderBundle.h index 76635c3f66..8d9b2c7ca7 100644 --- a/src/dawn/node/binding/GPURenderBundle.h +++ b/src/dawn/node/binding/GPURenderBundle.h @@ -34,8 +34,8 @@ namespace wgpu::binding { } // interop::GPURenderBundle interface compliance - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::RenderBundle bundle_; diff --git a/src/dawn/node/binding/GPURenderBundleEncoder.cpp b/src/dawn/node/binding/GPURenderBundleEncoder.cpp index 6c3fe9961c..9bfededee0 100644 --- a/src/dawn/node/binding/GPURenderBundleEncoder.cpp +++ b/src/dawn/node/binding/GPURenderBundleEncoder.cpp @@ -181,11 +181,12 @@ namespace wgpu::binding { enc_.DrawIndexedIndirect(b, o); } - std::optional GPURenderBundleEncoder::getLabel(Napi::Env) { + std::variant GPURenderBundleEncoder::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPURenderBundleEncoder::setLabel(Napi::Env, std::optional value) { + void GPURenderBundleEncoder::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPURenderBundleEncoder.h b/src/dawn/node/binding/GPURenderBundleEncoder.h index c459e84db2..8c879b519a 100644 --- a/src/dawn/node/binding/GPURenderBundleEncoder.h +++ b/src/dawn/node/binding/GPURenderBundleEncoder.h @@ -74,8 +74,8 @@ namespace wgpu::binding { void drawIndexedIndirect(Napi::Env, interop::Interface indirectBuffer, interop::GPUSize64 indirectOffset) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::RenderBundleEncoder enc_; diff --git a/src/dawn/node/binding/GPURenderPassEncoder.cpp b/src/dawn/node/binding/GPURenderPassEncoder.cpp index 3fe4791e36..39c763647b 100644 --- a/src/dawn/node/binding/GPURenderPassEncoder.cpp +++ b/src/dawn/node/binding/GPURenderPassEncoder.cpp @@ -89,10 +89,6 @@ namespace wgpu::binding { enc_.End(); } - void GPURenderPassEncoder::endPass(Napi::Env) { - enc_.EndPass(); - } - void GPURenderPassEncoder::setBindGroup( Napi::Env env, interop::GPUIndex32 index, @@ -231,11 +227,12 @@ namespace wgpu::binding { enc_.DrawIndexedIndirect(b, o); } - std::optional GPURenderPassEncoder::getLabel(Napi::Env) { + std::variant GPURenderPassEncoder::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPURenderPassEncoder::setLabel(Napi::Env, std::optional value) { + void GPURenderPassEncoder::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPURenderPassEncoder.h b/src/dawn/node/binding/GPURenderPassEncoder.h index 3926052ff7..bbd8012cb4 100644 --- a/src/dawn/node/binding/GPURenderPassEncoder.h +++ b/src/dawn/node/binding/GPURenderPassEncoder.h @@ -54,7 +54,6 @@ namespace wgpu::binding { Napi::Env, std::vector> bundles) override; void end(Napi::Env) override; - void endPass(Napi::Env) override; // TODO(dawn:1286): Remove after deprecation period. void setBindGroup(Napi::Env, interop::GPUIndex32 index, interop::Interface bindGroup, @@ -97,8 +96,8 @@ namespace wgpu::binding { void drawIndexedIndirect(Napi::Env, interop::Interface indirectBuffer, interop::GPUSize64 indirectOffset) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; private: wgpu::RenderPassEncoder enc_; diff --git a/src/dawn/node/binding/GPURenderPipeline.cpp b/src/dawn/node/binding/GPURenderPipeline.cpp index 58003d987e..8618f1fc3b 100644 --- a/src/dawn/node/binding/GPURenderPipeline.cpp +++ b/src/dawn/node/binding/GPURenderPipeline.cpp @@ -34,11 +34,12 @@ namespace wgpu::binding { env, pipeline_.GetBindGroupLayout(index)); } - std::optional GPURenderPipeline::getLabel(Napi::Env) { + std::variant GPURenderPipeline::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPURenderPipeline::setLabel(Napi::Env, std::optional value) { + void GPURenderPipeline::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPURenderPipeline.h b/src/dawn/node/binding/GPURenderPipeline.h index 3eaf2cd15f..ad8b0afc23 100644 --- a/src/dawn/node/binding/GPURenderPipeline.h +++ b/src/dawn/node/binding/GPURenderPipeline.h @@ -36,8 +36,8 @@ namespace wgpu::binding { // interop::GPURenderPipeline interface compliance interop::Interface getBindGroupLayout(Napi::Env, uint32_t index) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::RenderPipeline pipeline_; diff --git a/src/dawn/node/binding/GPUSampler.cpp b/src/dawn/node/binding/GPUSampler.cpp index 70f653603c..c1076e961f 100644 --- a/src/dawn/node/binding/GPUSampler.cpp +++ b/src/dawn/node/binding/GPUSampler.cpp @@ -25,11 +25,11 @@ namespace wgpu::binding { GPUSampler::GPUSampler(wgpu::Sampler sampler) : sampler_(std::move(sampler)) { } - std::optional GPUSampler::getLabel(Napi::Env) { + std::variant GPUSampler::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUSampler::setLabel(Napi::Env, std::optional value) { + void GPUSampler::setLabel(Napi::Env, std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUSampler.h b/src/dawn/node/binding/GPUSampler.h index 4f1ff20444..e6d792ec32 100644 --- a/src/dawn/node/binding/GPUSampler.h +++ b/src/dawn/node/binding/GPUSampler.h @@ -32,8 +32,8 @@ namespace wgpu::binding { } // interop::GPUSampler interface compliance - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; private: wgpu::Sampler sampler_; diff --git a/src/dawn/node/binding/GPUShaderModule.cpp b/src/dawn/node/binding/GPUShaderModule.cpp index a889fdbe92..a599f05da1 100644 --- a/src/dawn/node/binding/GPUShaderModule.cpp +++ b/src/dawn/node/binding/GPUShaderModule.cpp @@ -114,11 +114,12 @@ namespace wgpu::binding { return promise; } - std::optional GPUShaderModule::getLabel(Napi::Env) { + std::variant GPUShaderModule::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUShaderModule::setLabel(Napi::Env, std::optional value) { + void GPUShaderModule::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUShaderModule.h b/src/dawn/node/binding/GPUShaderModule.h index c0a94aab30..df2bdc2f08 100644 --- a/src/dawn/node/binding/GPUShaderModule.h +++ b/src/dawn/node/binding/GPUShaderModule.h @@ -37,8 +37,8 @@ namespace wgpu::binding { // interop::GPUShaderModule interface compliance interop::Promise> compilationInfo( Napi::Env) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::ShaderModule shader_; diff --git a/src/dawn/node/binding/GPUTexture.cpp b/src/dawn/node/binding/GPUTexture.cpp index 0387248450..ac0465f8cc 100644 --- a/src/dawn/node/binding/GPUTexture.cpp +++ b/src/dawn/node/binding/GPUTexture.cpp @@ -53,11 +53,11 @@ namespace wgpu::binding { texture_.Destroy(); } - std::optional GPUTexture::getLabel(Napi::Env) { + std::variant GPUTexture::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUTexture::setLabel(Napi::Env, std::optional value) { + void GPUTexture::setLabel(Napi::Env, std::variant value) { UNIMPLEMENTED(); } diff --git a/src/dawn/node/binding/GPUTexture.h b/src/dawn/node/binding/GPUTexture.h index cdff7014a0..dda0829847 100644 --- a/src/dawn/node/binding/GPUTexture.h +++ b/src/dawn/node/binding/GPUTexture.h @@ -37,8 +37,8 @@ namespace wgpu::binding { Napi::Env, interop::GPUTextureViewDescriptor descriptor) override; void destroy(Napi::Env) override; - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variantgetLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variantvalue) override; private: wgpu::Texture texture_; diff --git a/src/dawn/node/binding/GPUTextureView.cpp b/src/dawn/node/binding/GPUTextureView.cpp index 1e183dbda8..7998f6c03a 100644 --- a/src/dawn/node/binding/GPUTextureView.cpp +++ b/src/dawn/node/binding/GPUTextureView.cpp @@ -24,11 +24,12 @@ namespace wgpu::binding { GPUTextureView::GPUTextureView(wgpu::TextureView view) : view_(std::move(view)) { } - std::optional GPUTextureView::getLabel(Napi::Env) { + std::variant GPUTextureView::getLabel(Napi::Env) { UNIMPLEMENTED(); } - void GPUTextureView::setLabel(Napi::Env, std::optional value) { + void GPUTextureView::setLabel(Napi::Env, + std::variant value) { UNIMPLEMENTED(); }; diff --git a/src/dawn/node/binding/GPUTextureView.h b/src/dawn/node/binding/GPUTextureView.h index 6568e70e55..ceb750aa0d 100644 --- a/src/dawn/node/binding/GPUTextureView.h +++ b/src/dawn/node/binding/GPUTextureView.h @@ -34,8 +34,8 @@ namespace wgpu::binding { } // interop::GPUTextureView interface compliance - std::optional getLabel(Napi::Env) override; - void setLabel(Napi::Env, std::optional value) override; + std::variant getLabel(Napi::Env) override; + void setLabel(Napi::Env, std::variant value) override; private: wgpu::TextureView view_; diff --git a/src/dawn/node/interop/Core.cpp b/src/dawn/node/interop/Core.cpp index a2232ae707..151d852b8d 100644 --- a/src/dawn/node/interop/Core.cpp +++ b/src/dawn/node/interop/Core.cpp @@ -157,4 +157,14 @@ namespace wgpu::interop { return Napi::Value::From(env, value); } + Result Converter::FromJS(Napi::Env, Napi::Value value, UndefinedType&) { + if (value.IsUndefined()) { + return Success; + } + return Error("value is undefined"); + } + Napi::Value Converter::ToJS(Napi::Env env, UndefinedType) { + return env.Undefined(); + } + } // namespace wgpu::interop diff --git a/src/dawn/node/interop/Core.h b/src/dawn/node/interop/Core.h index 30545695cb..8ea62d1ae6 100644 --- a/src/dawn/node/interop/Core.h +++ b/src/dawn/node/interop/Core.h @@ -62,6 +62,10 @@ namespace wgpu::interop { using Float64Array = Napi::TypedArrayOf; using DataView = Napi::TypedArray; + // Datatype used for undefined values. + struct UndefinedType {}; + static constexpr UndefinedType Undefined; + template using FrozenArray = std::vector; @@ -439,6 +443,13 @@ namespace wgpu::interop { static Napi::Value ToJS(Napi::Env, double); }; + template <> + class Converter { + public: + static Result FromJS(Napi::Env, Napi::Value, UndefinedType&); + static Napi::Value ToJS(Napi::Env, UndefinedType); + }; + template class Converter> { public: diff --git a/src/dawn/node/interop/WebGPUCommon.tmpl b/src/dawn/node/interop/WebGPUCommon.tmpl index 94b2e407c8..1311c906be 100644 --- a/src/dawn/node/interop/WebGPUCommon.tmpl +++ b/src/dawn/node/interop/WebGPUCommon.tmpl @@ -118,8 +118,10 @@ See: */ -}} {{- define "VariantTypeList" -}} {{- range $i, $ty := $}} -{{- if not (IsUndefinedType $ty)}} -{{- if $i }}, {{end}} +{{- if $i }}, {{end}} +{{- if IsUndefinedType $ty -}} + UndefinedType +{{- else}} {{- template "Type" $ty}} {{- end}} {{- end}}