diff --git a/src/dawn_node/binding/CMakeLists.txt b/src/dawn_node/binding/CMakeLists.txt index 514bdd9198..f75ec08192 100644 --- a/src/dawn_node/binding/CMakeLists.txt +++ b/src/dawn_node/binding/CMakeLists.txt @@ -21,25 +21,36 @@ add_library(dawn_node_binding STATIC "Errors.h" "GPU.h" "GPUAdapter.h" + "GPUBindGroup.cpp" "GPUBindGroup.h" + "GPUBindGroupLayout.cpp" "GPUBindGroupLayout.h" "GPUBuffer.h" + "GPUCommandBuffer.cpp" "GPUCommandBuffer.h" "GPUCommandEncoder.h" "GPUComputePassEncoder.h" + "GPUComputePipeline.cpp" "GPUComputePipeline.h" "GPUDevice.h" + "GPUPipelineLayout.cpp" "GPUPipelineLayout.h" + "GPUQuerySet.cpp" "GPUQuerySet.h" "GPUQueue.h" + "GPURenderBundle.cpp" "GPURenderBundle.h" "GPURenderBundleEncoder.h" "GPURenderPassEncoder.h" + "GPURenderPipeline.cpp" "GPURenderPipeline.h" + "GPUSampler.cpp" "GPUSampler.h" "GPUShaderModule.h" + "GPUSupportedLimits.cpp" "GPUSupportedLimits.h" "GPUTexture.h" + "GPUTextureView.cpp" "GPUTextureView.h" ) diff --git a/src/dawn_node/binding/GPUBindGroup.cpp b/src/dawn_node/binding/GPUBindGroup.cpp new file mode 100644 index 0000000000..e156700580 --- /dev/null +++ b/src/dawn_node/binding/GPUBindGroup.cpp @@ -0,0 +1,35 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUBindGroup.h" + +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUBindGroup + //////////////////////////////////////////////////////////////////////////////// + GPUBindGroup::GPUBindGroup(wgpu::BindGroup group) : group_(std::move(group)) { + } + + std::optional GPUBindGroup::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUBindGroup::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUBindGroupLayout.cpp b/src/dawn_node/binding/GPUBindGroupLayout.cpp new file mode 100644 index 0000000000..ddaeaba6f1 --- /dev/null +++ b/src/dawn_node/binding/GPUBindGroupLayout.cpp @@ -0,0 +1,36 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUBindGroupLayout.h" + +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUBindGroupLayout + //////////////////////////////////////////////////////////////////////////////// + GPUBindGroupLayout::GPUBindGroupLayout(wgpu::BindGroupLayout layout) + : layout_(std::move(layout)) { + } + + std::optional GPUBindGroupLayout::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUBindGroupLayout::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUCommandBuffer.cpp b/src/dawn_node/binding/GPUCommandBuffer.cpp new file mode 100644 index 0000000000..0ff503fc54 --- /dev/null +++ b/src/dawn_node/binding/GPUCommandBuffer.cpp @@ -0,0 +1,40 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUCommandBuffer.h" + +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUCommandBuffer + //////////////////////////////////////////////////////////////////////////////// + + GPUCommandBuffer::GPUCommandBuffer(wgpu::CommandBuffer cmd_buf) : cmd_buf_(std::move(cmd_buf)) { + } + + interop::Promise GPUCommandBuffer::getExecutionTime(Napi::Env) { + UNIMPLEMENTED(); + }; + + std::optional GPUCommandBuffer::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUCommandBuffer::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUComputePipeline.cpp b/src/dawn_node/binding/GPUComputePipeline.cpp new file mode 100644 index 0000000000..0eef82ec54 --- /dev/null +++ b/src/dawn_node/binding/GPUComputePipeline.cpp @@ -0,0 +1,45 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUComputePipeline.h" + +#include "src/dawn_node/binding/GPUBindGroupLayout.h" +#include "src/dawn_node/binding/GPUBuffer.h" +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUComputePipeline + //////////////////////////////////////////////////////////////////////////////// + GPUComputePipeline::GPUComputePipeline(wgpu::ComputePipeline pipeline) + : pipeline_(std::move(pipeline)) { + } + + interop::Interface GPUComputePipeline::getBindGroupLayout( + Napi::Env env, + uint32_t index) { + return interop::GPUBindGroupLayout::Create( + env, pipeline_.GetBindGroupLayout(index)); + } + + std::optional GPUComputePipeline::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUComputePipeline::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUPipelineLayout.cpp b/src/dawn_node/binding/GPUPipelineLayout.cpp new file mode 100644 index 0000000000..861df210d4 --- /dev/null +++ b/src/dawn_node/binding/GPUPipelineLayout.cpp @@ -0,0 +1,35 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUPipelineLayout.h" + +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUPipelineLayout + //////////////////////////////////////////////////////////////////////////////// + GPUPipelineLayout::GPUPipelineLayout(wgpu::PipelineLayout layout) : layout_(std::move(layout)) { + } + + std::optional GPUPipelineLayout::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUPipelineLayout::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUQuerySet.cpp b/src/dawn_node/binding/GPUQuerySet.cpp new file mode 100644 index 0000000000..e56564a94c --- /dev/null +++ b/src/dawn_node/binding/GPUQuerySet.cpp @@ -0,0 +1,39 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUQuerySet.h" + +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUQuerySet + //////////////////////////////////////////////////////////////////////////////// + GPUQuerySet::GPUQuerySet(wgpu::QuerySet query_set) : query_set_(std::move(query_set)) { + } + + void GPUQuerySet::destroy(Napi::Env) { + query_set_.Destroy(); + } + + std::optional GPUQuerySet::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUQuerySet::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPURenderBundle.cpp b/src/dawn_node/binding/GPURenderBundle.cpp new file mode 100644 index 0000000000..2f42ac72d3 --- /dev/null +++ b/src/dawn_node/binding/GPURenderBundle.cpp @@ -0,0 +1,39 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPURenderBundle.h" + +#include "src/dawn_node/binding/Converter.h" +#include "src/dawn_node/binding/GPUBuffer.h" +#include "src/dawn_node/binding/GPURenderBundle.h" +#include "src/dawn_node/binding/GPURenderPipeline.h" +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPURenderBundle + //////////////////////////////////////////////////////////////////////////////// + GPURenderBundle::GPURenderBundle(wgpu::RenderBundle bundle) : bundle_(std::move(bundle)) { + } + + std::optional GPURenderBundle::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPURenderBundle::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPURenderPipeline.cpp b/src/dawn_node/binding/GPURenderPipeline.cpp new file mode 100644 index 0000000000..3f363fc2a4 --- /dev/null +++ b/src/dawn_node/binding/GPURenderPipeline.cpp @@ -0,0 +1,45 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPURenderPipeline.h" + +#include "src/dawn_node/binding/GPUBindGroupLayout.h" +#include "src/dawn_node/binding/GPUBuffer.h" +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPURenderPipeline + //////////////////////////////////////////////////////////////////////////////// + GPURenderPipeline::GPURenderPipeline(wgpu::RenderPipeline pipeline) + : pipeline_(std::move(pipeline)) { + } + + interop::Interface GPURenderPipeline::getBindGroupLayout( + Napi::Env env, + uint32_t index) { + return interop::GPUBindGroupLayout::Create( + env, pipeline_.GetBindGroupLayout(index)); + } + + std::optional GPURenderPipeline::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPURenderPipeline::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUSampler.cpp b/src/dawn_node/binding/GPUSampler.cpp new file mode 100644 index 0000000000..6de3aa49c0 --- /dev/null +++ b/src/dawn_node/binding/GPUSampler.cpp @@ -0,0 +1,36 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUSampler.h" + +#include "src/dawn_node/binding/Converter.h" +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUSampler + //////////////////////////////////////////////////////////////////////////////// + GPUSampler::GPUSampler(wgpu::Sampler sampler) : sampler_(std::move(sampler)) { + } + + std::optional GPUSampler::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUSampler::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUSupportedLimits.cpp b/src/dawn_node/binding/GPUSupportedLimits.cpp new file mode 100644 index 0000000000..8587031879 --- /dev/null +++ b/src/dawn_node/binding/GPUSupportedLimits.cpp @@ -0,0 +1,131 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUSupportedLimits.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUSupportedLimits + //////////////////////////////////////////////////////////////////////////////// + + // Values taken from. + // https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/webgpu/gpu_supported_limits.h + // TODO(crbug.com/dawn/1131): Actually use limits reported by the device / adapter. + + uint32_t GPUSupportedLimits::getMaxTextureDimension1D(Napi::Env) { + return 8192; + } + + uint32_t GPUSupportedLimits::getMaxTextureDimension2D(Napi::Env) { + return 8192; + } + + uint32_t GPUSupportedLimits::getMaxTextureDimension3D(Napi::Env) { + return 2048; + } + + uint32_t GPUSupportedLimits::getMaxTextureArrayLayers(Napi::Env) { + return 2048; + } + + uint32_t GPUSupportedLimits::getMaxBindGroups(Napi::Env) { + return 4; + } + + uint32_t GPUSupportedLimits::getMaxDynamicUniformBuffersPerPipelineLayout(Napi::Env) { + return 8; + } + + uint32_t GPUSupportedLimits::getMaxDynamicStorageBuffersPerPipelineLayout(Napi::Env) { + return 4; + } + + uint32_t GPUSupportedLimits::getMaxSampledTexturesPerShaderStage(Napi::Env) { + return 16; + } + + uint32_t GPUSupportedLimits::getMaxSamplersPerShaderStage(Napi::Env) { + return 16; + } + + uint32_t GPUSupportedLimits::getMaxStorageBuffersPerShaderStage(Napi::Env) { + return 4; + } + + uint32_t GPUSupportedLimits::getMaxStorageTexturesPerShaderStage(Napi::Env) { + return 4; + } + + uint32_t GPUSupportedLimits::getMaxUniformBuffersPerShaderStage(Napi::Env) { + return 12; + } + + uint64_t GPUSupportedLimits::getMaxUniformBufferBindingSize(Napi::Env) { + return 16384; + } + + uint64_t GPUSupportedLimits::getMaxStorageBufferBindingSize(Napi::Env) { + return 134217728; + } + + uint32_t GPUSupportedLimits::getMinUniformBufferOffsetAlignment(Napi::Env) { + return 256; + } + + uint32_t GPUSupportedLimits::getMinStorageBufferOffsetAlignment(Napi::Env) { + return 256; + } + + uint32_t GPUSupportedLimits::getMaxVertexBuffers(Napi::Env) { + return 8; + } + + uint32_t GPUSupportedLimits::getMaxVertexAttributes(Napi::Env) { + return 16; + } + + uint32_t GPUSupportedLimits::getMaxVertexBufferArrayStride(Napi::Env) { + return 2048; + } + + uint32_t GPUSupportedLimits::getMaxInterStageShaderComponents(Napi::Env) { + return 60; + } + + uint32_t GPUSupportedLimits::getMaxComputeWorkgroupStorageSize(Napi::Env) { + return 16352; + } + + uint32_t GPUSupportedLimits::getMaxComputeInvocationsPerWorkgroup(Napi::Env) { + return 256; + } + + uint32_t GPUSupportedLimits::getMaxComputeWorkgroupSizeX(Napi::Env) { + return 256; + } + + uint32_t GPUSupportedLimits::getMaxComputeWorkgroupSizeY(Napi::Env) { + return 256; + } + + uint32_t GPUSupportedLimits::getMaxComputeWorkgroupSizeZ(Napi::Env) { + return 64; + } + + uint32_t GPUSupportedLimits::getMaxComputeWorkgroupsPerDimension(Napi::Env) { + return 65535; + } + +}} // namespace wgpu::binding diff --git a/src/dawn_node/binding/GPUTextureView.cpp b/src/dawn_node/binding/GPUTextureView.cpp new file mode 100644 index 0000000000..f03bc3f266 --- /dev/null +++ b/src/dawn_node/binding/GPUTextureView.cpp @@ -0,0 +1,35 @@ +// Copyright 2021 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/dawn_node/binding/GPUTextureView.h" + +#include "src/dawn_node/utils/Debug.h" + +namespace wgpu { namespace binding { + + //////////////////////////////////////////////////////////////////////////////// + // wgpu::bindings::GPUTextureView + //////////////////////////////////////////////////////////////////////////////// + GPUTextureView::GPUTextureView(wgpu::TextureView view) : view_(std::move(view)) { + } + + std::optional GPUTextureView::getLabel(Napi::Env) { + UNIMPLEMENTED(); + } + + void GPUTextureView::setLabel(Napi::Env, std::optional value) { + UNIMPLEMENTED(); + }; + +}} // namespace wgpu::binding