Roll WebGPU IDL, update dawn/node bindings.

Bug: dawn:1123
Bug: dawn:1286
Change-Id: I3ffeea82fda381905ee8f02f9f2768c81c7e6d6d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79761
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton 2022-03-03 21:13:51 +00:00 committed by Dawn LUCI CQ
parent ba70fac14d
commit db8666fa71
43 changed files with 132 additions and 141 deletions

2
DEPS
View File

@ -162,7 +162,7 @@ deps = {
'condition': 'dawn_node', 'condition': 'dawn_node',
}, },
'third_party/gpuweb': { 'third_party/gpuweb': {
'url': '{github_git}/gpuweb/gpuweb.git@0aadaca4c53ca131aa19708c1d2b1bed56da1118', 'url': '{github_git}/gpuweb/gpuweb.git@881403b5fda2d9ac9ffc5daa24e34738205bf155',
'condition': 'dawn_node', 'condition': 'dawn_node',
}, },

View File

@ -952,63 +952,24 @@ namespace wgpu::binding {
bool Converter::Convert(wgpu::RenderPassColorAttachment& out, bool Converter::Convert(wgpu::RenderPassColorAttachment& out,
const interop::GPURenderPassColorAttachment& in) { const interop::GPURenderPassColorAttachment& in) {
out = {}; out = {};
if (auto* op = std::get_if<interop::GPULoadOp>(&in.loadValue)) { return Convert(out.view, in.view) && //
if (!Convert(out.loadOp, *op)) { Convert(out.resolveTarget, in.resolveTarget) && //
return false; Convert(out.clearColor, in.clearValue) && //
} Convert(out.loadOp, in.loadOp) && //
} else if (auto* color = std::get_if<interop::GPUColor>(&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) &&
Convert(out.storeOp, in.storeOp); Convert(out.storeOp, in.storeOp);
} }
bool Converter::Convert(wgpu::RenderPassDepthStencilAttachment& out, bool Converter::Convert(wgpu::RenderPassDepthStencilAttachment& out,
const interop::GPURenderPassDepthStencilAttachment& in) { const interop::GPURenderPassDepthStencilAttachment& in) {
out = {}; out = {};
if (auto* op = std::get_if<interop::GPULoadOp>(&in.depthLoadValue)) { return Convert(out.view, in.view) && //
if (!Convert(out.depthLoadOp, *op)) { Convert(out.clearDepth, in.depthClearValue) && //
return false; Convert(out.depthLoadOp, in.depthLoadOp) && //
} Convert(out.depthStoreOp, in.depthStoreOp) && //
} else if (auto* value = std::get_if<float>(&in.depthLoadValue)) { Convert(out.depthReadOnly, in.depthReadOnly) && //
out.stencilLoadOp = wgpu::LoadOp::Clear; Convert(out.clearStencil, in.stencilClearValue) && //
if (!Convert(out.clearDepth, *value)) { Convert(out.stencilLoadOp, in.stencilLoadOp) && //
return false; Convert(out.stencilStoreOp, in.stencilStoreOp) && //
}
} else {
Napi::Error::New(env,
"invalid value for GPURenderPassDepthStencilAttachment.depthLoadValue")
.ThrowAsJavaScriptException();
return false;
}
if (auto* op = std::get_if<interop::GPULoadOp>(&in.stencilLoadValue)) {
if (!Convert(out.stencilLoadOp, *op)) {
return false;
}
} else if (auto* value = std::get_if<interop::GPUStencilValue>(&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) &&
Convert(out.stencilReadOnly, in.stencilReadOnly); Convert(out.stencilReadOnly, in.stencilReadOnly);
} }
@ -1018,6 +979,9 @@ namespace wgpu::binding {
case interop::GPULoadOp::kLoad: case interop::GPULoadOp::kLoad:
out = wgpu::LoadOp::Load; out = wgpu::LoadOp::Load;
return true; return true;
case interop::GPULoadOp::kClear:
out = wgpu::LoadOp::Clear;
return true;
} }
Napi::Error::New(env, "invalid value for GPULoadOp").ThrowAsJavaScriptException(); Napi::Error::New(env, "invalid value for GPULoadOp").ThrowAsJavaScriptException();
return false; return false;

View File

@ -24,11 +24,12 @@ namespace wgpu::binding {
GPUBindGroup::GPUBindGroup(wgpu::BindGroup group) : group_(std::move(group)) { GPUBindGroup::GPUBindGroup(wgpu::BindGroup group) : group_(std::move(group)) {
} }
std::optional<std::string> GPUBindGroup::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUBindGroup::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUBindGroup::setLabel(Napi::Env, std::optional<std::string> value) { void GPUBindGroup::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -33,8 +33,8 @@ namespace wgpu::binding {
} }
// interop::GPUBindGroup interface compliance // interop::GPUBindGroup interface compliance
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
private: private:
wgpu::BindGroup group_; wgpu::BindGroup group_;

View File

@ -25,11 +25,12 @@ namespace wgpu::binding {
: layout_(std::move(layout)) { : layout_(std::move(layout)) {
} }
std::optional<std::string> GPUBindGroupLayout::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUBindGroupLayout::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUBindGroupLayout::setLabel(Napi::Env, std::optional<std::string> value) { void GPUBindGroupLayout::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -34,8 +34,8 @@ namespace wgpu::binding {
} }
// interop::GPUBindGroupLayout interface compliance // interop::GPUBindGroupLayout interface compliance
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::BindGroupLayout layout_; wgpu::BindGroupLayout layout_;

View File

@ -158,11 +158,11 @@ namespace wgpu::binding {
state_ = State::Destroyed; state_ = State::Destroyed;
} }
std::optional<std::string> GPUBuffer::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUBuffer::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUBuffer::setLabel(Napi::Env, std::optional<std::string> value) { void GPUBuffer::setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -51,8 +51,8 @@ namespace wgpu::binding {
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;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
struct Mapping { struct Mapping {

View File

@ -25,11 +25,12 @@ namespace wgpu::binding {
GPUCommandBuffer::GPUCommandBuffer(wgpu::CommandBuffer cmd_buf) : cmd_buf_(std::move(cmd_buf)) { GPUCommandBuffer::GPUCommandBuffer(wgpu::CommandBuffer cmd_buf) : cmd_buf_(std::move(cmd_buf)) {
} }
std::optional<std::string> GPUCommandBuffer::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUCommandBuffer::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUCommandBuffer::setLabel(Napi::Env, std::optional<std::string> value) { void GPUCommandBuffer::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -34,8 +34,8 @@ namespace wgpu::binding {
} }
// interop::GPUCommandBuffer interface compliance // interop::GPUCommandBuffer interface compliance
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::CommandBuffer cmd_buf_; wgpu::CommandBuffer cmd_buf_;

View File

@ -204,11 +204,12 @@ namespace wgpu::binding {
return interop::GPUCommandBuffer::Create<GPUCommandBuffer>(env, enc_.Finish(&desc)); return interop::GPUCommandBuffer::Create<GPUCommandBuffer>(env, enc_.Finish(&desc));
} }
std::optional<std::string> GPUCommandEncoder::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUCommandEncoder::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUCommandEncoder::setLabel(Napi::Env, std::optional<std::string> value) { void GPUCommandEncoder::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -72,8 +72,8 @@ namespace wgpu::binding {
interop::Interface<interop::GPUCommandBuffer> finish( interop::Interface<interop::GPUCommandBuffer> finish(
Napi::Env env, Napi::Env env,
interop::GPUCommandBufferDescriptor descriptor) override; interop::GPUCommandBufferDescriptor descriptor) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::CommandEncoder enc_; wgpu::CommandEncoder enc_;

View File

@ -54,10 +54,6 @@ namespace wgpu::binding {
enc_.End(); enc_.End();
} }
void GPUComputePassEncoder::endPass(Napi::Env) {
enc_.EndPass();
}
void GPUComputePassEncoder::setBindGroup( void GPUComputePassEncoder::setBindGroup(
Napi::Env env, Napi::Env env,
interop::GPUIndex32 index, interop::GPUIndex32 index,
@ -104,11 +100,12 @@ namespace wgpu::binding {
enc_.InsertDebugMarker(markerLabel.c_str()); enc_.InsertDebugMarker(markerLabel.c_str());
} }
std::optional<std::string> GPUComputePassEncoder::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUComputePassEncoder::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUComputePassEncoder::setLabel(Napi::Env, std::optional<std::string> value) { void GPUComputePassEncoder::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -44,7 +44,6 @@ namespace wgpu::binding {
interop::Interface<interop::GPUBuffer> indirectBuffer, interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override; interop::GPUSize64 indirectOffset) override;
void end(Napi::Env) override; void end(Napi::Env) override;
void endPass(Napi::Env) override; // TODO(dawn:1286): Remove after deprecation period.
void setBindGroup(Napi::Env, void setBindGroup(Napi::Env,
interop::GPUIndex32 index, interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup, interop::Interface<interop::GPUBindGroup> bindGroup,
@ -58,8 +57,8 @@ namespace wgpu::binding {
void pushDebugGroup(Napi::Env, std::string groupLabel) override; void pushDebugGroup(Napi::Env, std::string groupLabel) override;
void popDebugGroup(Napi::Env) override; void popDebugGroup(Napi::Env) override;
void insertDebugMarker(Napi::Env, std::string markerLabel) override; void insertDebugMarker(Napi::Env, std::string markerLabel) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
private: private:
wgpu::ComputePassEncoder enc_; wgpu::ComputePassEncoder enc_;

View File

@ -34,11 +34,12 @@ namespace wgpu::binding {
env, pipeline_.GetBindGroupLayout(index)); env, pipeline_.GetBindGroupLayout(index));
} }
std::optional<std::string> GPUComputePipeline::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUComputePipeline::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUComputePipeline::setLabel(Napi::Env, std::optional<std::string> value) { void GPUComputePipeline::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -36,8 +36,8 @@ namespace wgpu::binding {
// interop::GPUComputePipeline interface compliance // interop::GPUComputePipeline interface compliance
interop::Interface<interop::GPUBindGroupLayout> getBindGroupLayout(Napi::Env, interop::Interface<interop::GPUBindGroupLayout> getBindGroupLayout(Napi::Env,
uint32_t index) override; uint32_t index) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::ComputePipeline pipeline_; wgpu::ComputePipeline pipeline_;

View File

@ -44,7 +44,8 @@ namespace wgpu::binding {
DeviceLostInfo(interop::GPUDeviceLostReason reason, std::string message) DeviceLostInfo(interop::GPUDeviceLostReason reason, std::string message)
: reason_(reason), message_(message) { : reason_(reason), message_(message) {
} }
std::variant<interop::GPUDeviceLostReason> getReason(Napi::Env env) override { std::variant<interop::GPUDeviceLostReason, interop::UndefinedType> getReason(
Napi::Env env) override {
return reason_; return reason_;
} }
std::string getMessage(Napi::Env) override { std::string getMessage(Napi::Env) override {
@ -488,11 +489,11 @@ namespace wgpu::binding {
return promise; return promise;
} }
std::optional<std::string> GPUDevice::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUDevice::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
}; };
void GPUDevice::setLabel(Napi::Env, std::optional<std::string> value) { void GPUDevice::setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
}; };

View File

@ -81,8 +81,8 @@ namespace wgpu::binding {
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::GPUError>> popErrorScope(Napi::Env env) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
interop::Interface<interop::EventHandler> getOnuncapturederror(Napi::Env) override; interop::Interface<interop::EventHandler> getOnuncapturederror(Napi::Env) override;
void setOnuncapturederror(Napi::Env, void setOnuncapturederror(Napi::Env,
interop::Interface<interop::EventHandler> value) override; interop::Interface<interop::EventHandler> value) override;

View File

@ -24,11 +24,12 @@ namespace wgpu::binding {
GPUPipelineLayout::GPUPipelineLayout(wgpu::PipelineLayout layout) : layout_(std::move(layout)) { GPUPipelineLayout::GPUPipelineLayout(wgpu::PipelineLayout layout) : layout_(std::move(layout)) {
} }
std::optional<std::string> GPUPipelineLayout::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUPipelineLayout::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUPipelineLayout::setLabel(Napi::Env, std::optional<std::string> value) { void GPUPipelineLayout::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -34,8 +34,8 @@ namespace wgpu::binding {
} }
// interop::GPUPipelineLayout interface compliance // interop::GPUPipelineLayout interface compliance
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
private: private:
wgpu::PipelineLayout layout_; wgpu::PipelineLayout layout_;

View File

@ -28,11 +28,11 @@ namespace wgpu::binding {
query_set_.Destroy(); query_set_.Destroy();
} }
std::optional<std::string> GPUQuerySet::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUQuerySet::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUQuerySet::setLabel(Napi::Env, std::optional<std::string> value) { void GPUQuerySet::setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -34,8 +34,8 @@ namespace wgpu::binding {
// interop::GPUQuerySet interface compliance // interop::GPUQuerySet interface compliance
void destroy(Napi::Env) override; void destroy(Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
private: private:
wgpu::QuerySet query_set_; wgpu::QuerySet query_set_;

View File

@ -121,11 +121,11 @@ namespace wgpu::binding {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
std::optional<std::string> GPUQueue::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUQueue::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUQueue::setLabel(Napi::Env, std::optional<std::string> value) { void GPUQueue::setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -48,8 +48,8 @@ namespace wgpu::binding {
interop::GPUImageCopyExternalImage source, interop::GPUImageCopyExternalImage source,
interop::GPUImageCopyTextureTagged destination, interop::GPUImageCopyTextureTagged destination,
interop::GPUExtent3D copySize) override; interop::GPUExtent3D copySize) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::Queue queue_; wgpu::Queue queue_;

View File

@ -28,11 +28,12 @@ namespace wgpu::binding {
GPURenderBundle::GPURenderBundle(wgpu::RenderBundle bundle) : bundle_(std::move(bundle)) { GPURenderBundle::GPURenderBundle(wgpu::RenderBundle bundle) : bundle_(std::move(bundle)) {
} }
std::optional<std::string> GPURenderBundle::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPURenderBundle::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPURenderBundle::setLabel(Napi::Env, std::optional<std::string> value) { void GPURenderBundle::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -34,8 +34,8 @@ namespace wgpu::binding {
} }
// interop::GPURenderBundle interface compliance // interop::GPURenderBundle interface compliance
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::RenderBundle bundle_; wgpu::RenderBundle bundle_;

View File

@ -181,11 +181,12 @@ namespace wgpu::binding {
enc_.DrawIndexedIndirect(b, o); enc_.DrawIndexedIndirect(b, o);
} }
std::optional<std::string> GPURenderBundleEncoder::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPURenderBundleEncoder::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPURenderBundleEncoder::setLabel(Napi::Env, std::optional<std::string> value) { void GPURenderBundleEncoder::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -74,8 +74,8 @@ namespace wgpu::binding {
void drawIndexedIndirect(Napi::Env, void drawIndexedIndirect(Napi::Env,
interop::Interface<interop::GPUBuffer> indirectBuffer, interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override; interop::GPUSize64 indirectOffset) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::RenderBundleEncoder enc_; wgpu::RenderBundleEncoder enc_;

View File

@ -89,10 +89,6 @@ namespace wgpu::binding {
enc_.End(); enc_.End();
} }
void GPURenderPassEncoder::endPass(Napi::Env) {
enc_.EndPass();
}
void GPURenderPassEncoder::setBindGroup( void GPURenderPassEncoder::setBindGroup(
Napi::Env env, Napi::Env env,
interop::GPUIndex32 index, interop::GPUIndex32 index,
@ -231,11 +227,12 @@ namespace wgpu::binding {
enc_.DrawIndexedIndirect(b, o); enc_.DrawIndexedIndirect(b, o);
} }
std::optional<std::string> GPURenderPassEncoder::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPURenderPassEncoder::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPURenderPassEncoder::setLabel(Napi::Env, std::optional<std::string> value) { void GPURenderPassEncoder::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -54,7 +54,6 @@ namespace wgpu::binding {
Napi::Env, Napi::Env,
std::vector<interop::Interface<interop::GPURenderBundle>> bundles) override; std::vector<interop::Interface<interop::GPURenderBundle>> bundles) override;
void end(Napi::Env) override; void end(Napi::Env) override;
void endPass(Napi::Env) override; // TODO(dawn:1286): Remove after deprecation period.
void setBindGroup(Napi::Env, void setBindGroup(Napi::Env,
interop::GPUIndex32 index, interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup, interop::Interface<interop::GPUBindGroup> bindGroup,
@ -97,8 +96,8 @@ namespace wgpu::binding {
void drawIndexedIndirect(Napi::Env, void drawIndexedIndirect(Napi::Env,
interop::Interface<interop::GPUBuffer> indirectBuffer, interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override; interop::GPUSize64 indirectOffset) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
private: private:
wgpu::RenderPassEncoder enc_; wgpu::RenderPassEncoder enc_;

View File

@ -34,11 +34,12 @@ namespace wgpu::binding {
env, pipeline_.GetBindGroupLayout(index)); env, pipeline_.GetBindGroupLayout(index));
} }
std::optional<std::string> GPURenderPipeline::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPURenderPipeline::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPURenderPipeline::setLabel(Napi::Env, std::optional<std::string> value) { void GPURenderPipeline::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -36,8 +36,8 @@ namespace wgpu::binding {
// interop::GPURenderPipeline interface compliance // interop::GPURenderPipeline interface compliance
interop::Interface<interop::GPUBindGroupLayout> getBindGroupLayout(Napi::Env, interop::Interface<interop::GPUBindGroupLayout> getBindGroupLayout(Napi::Env,
uint32_t index) override; uint32_t index) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::RenderPipeline pipeline_; wgpu::RenderPipeline pipeline_;

View File

@ -25,11 +25,11 @@ namespace wgpu::binding {
GPUSampler::GPUSampler(wgpu::Sampler sampler) : sampler_(std::move(sampler)) { GPUSampler::GPUSampler(wgpu::Sampler sampler) : sampler_(std::move(sampler)) {
} }
std::optional<std::string> GPUSampler::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUSampler::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUSampler::setLabel(Napi::Env, std::optional<std::string> value) { void GPUSampler::setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -32,8 +32,8 @@ namespace wgpu::binding {
} }
// interop::GPUSampler interface compliance // interop::GPUSampler interface compliance
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
private: private:
wgpu::Sampler sampler_; wgpu::Sampler sampler_;

View File

@ -114,11 +114,12 @@ namespace wgpu::binding {
return promise; return promise;
} }
std::optional<std::string> GPUShaderModule::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUShaderModule::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUShaderModule::setLabel(Napi::Env, std::optional<std::string> value) { void GPUShaderModule::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -37,8 +37,8 @@ namespace wgpu::binding {
// interop::GPUShaderModule interface compliance // interop::GPUShaderModule interface compliance
interop::Promise<interop::Interface<interop::GPUCompilationInfo>> compilationInfo( interop::Promise<interop::Interface<interop::GPUCompilationInfo>> compilationInfo(
Napi::Env) override; Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::ShaderModule shader_; wgpu::ShaderModule shader_;

View File

@ -53,11 +53,11 @@ namespace wgpu::binding {
texture_.Destroy(); texture_.Destroy();
} }
std::optional<std::string> GPUTexture::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUTexture::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUTexture::setLabel(Napi::Env, std::optional<std::string> value) { void GPUTexture::setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

View File

@ -37,8 +37,8 @@ namespace wgpu::binding {
Napi::Env, Napi::Env,
interop::GPUTextureViewDescriptor descriptor) override; interop::GPUTextureViewDescriptor descriptor) override;
void destroy(Napi::Env) override; void destroy(Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType>getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType>value) override;
private: private:
wgpu::Texture texture_; wgpu::Texture texture_;

View File

@ -24,11 +24,12 @@ namespace wgpu::binding {
GPUTextureView::GPUTextureView(wgpu::TextureView view) : view_(std::move(view)) { GPUTextureView::GPUTextureView(wgpu::TextureView view) : view_(std::move(view)) {
} }
std::optional<std::string> GPUTextureView::getLabel(Napi::Env) { std::variant<std::string, interop::UndefinedType> GPUTextureView::getLabel(Napi::Env) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void GPUTextureView::setLabel(Napi::Env, std::optional<std::string> value) { void GPUTextureView::setLabel(Napi::Env,
std::variant<std::string, interop::UndefinedType> value) {
UNIMPLEMENTED(); UNIMPLEMENTED();
}; };

View File

@ -34,8 +34,8 @@ namespace wgpu::binding {
} }
// interop::GPUTextureView interface compliance // interop::GPUTextureView interface compliance
std::optional<std::string> getLabel(Napi::Env) override; std::variant<std::string, interop::UndefinedType> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override; void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
private: private:
wgpu::TextureView view_; wgpu::TextureView view_;

View File

@ -157,4 +157,14 @@ namespace wgpu::interop {
return Napi::Value::From(env, value); return Napi::Value::From(env, value);
} }
Result Converter<UndefinedType>::FromJS(Napi::Env, Napi::Value value, UndefinedType&) {
if (value.IsUndefined()) {
return Success;
}
return Error("value is undefined");
}
Napi::Value Converter<UndefinedType>::ToJS(Napi::Env env, UndefinedType) {
return env.Undefined();
}
} // namespace wgpu::interop } // namespace wgpu::interop

View File

@ -62,6 +62,10 @@ namespace wgpu::interop {
using Float64Array = Napi::TypedArrayOf<double>; using Float64Array = Napi::TypedArrayOf<double>;
using DataView = Napi::TypedArray; using DataView = Napi::TypedArray;
// Datatype used for undefined values.
struct UndefinedType {};
static constexpr UndefinedType Undefined;
template <typename T> template <typename T>
using FrozenArray = std::vector<T>; using FrozenArray = std::vector<T>;
@ -439,6 +443,13 @@ namespace wgpu::interop {
static Napi::Value ToJS(Napi::Env, double); static Napi::Value ToJS(Napi::Env, double);
}; };
template <>
class Converter<UndefinedType> {
public:
static Result FromJS(Napi::Env, Napi::Value, UndefinedType&);
static Napi::Value ToJS(Napi::Env, UndefinedType);
};
template <typename T> template <typename T>
class Converter<Interface<T>> { class Converter<Interface<T>> {
public: public:

View File

@ -118,8 +118,10 @@ See:
*/ -}} */ -}}
{{- define "VariantTypeList" -}} {{- define "VariantTypeList" -}}
{{- range $i, $ty := $}} {{- range $i, $ty := $}}
{{- if not (IsUndefinedType $ty)}} {{- if $i }}, {{end}}
{{- if $i }}, {{end}} {{- if IsUndefinedType $ty -}}
UndefinedType
{{- else}}
{{- template "Type" $ty}} {{- template "Type" $ty}}
{{- end}} {{- end}}
{{- end}} {{- end}}