dawn_node: Add all the headers for the binding classes

Nothing includes these yet.

Bug: dawn:1123
Change-Id: Ia2178d4bc9bf2c8f8f586493568b2864063d3fc7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64906
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Ben Clayton 2021-09-28 13:09:30 +00:00 committed by Dawn LUCI CQ
parent a35156b732
commit 3e5848a4de
23 changed files with 1348 additions and 0 deletions

View File

@ -17,6 +17,28 @@ add_library(dawn_node_binding STATIC
"AsyncRunner.h" "AsyncRunner.h"
"Errors.cpp" "Errors.cpp"
"Errors.h" "Errors.h"
"GPU.h"
"GPUAdapter.h"
"GPUBindGroup.h"
"GPUBindGroupLayout.h"
"GPUBuffer.h"
"GPUCommandBuffer.h"
"GPUCommandEncoder.h"
"GPUComputePassEncoder.h"
"GPUComputePipeline.h"
"GPUDevice.h"
"GPUPipelineLayout.h"
"GPUQuerySet.h"
"GPUQueue.h"
"GPURenderBundle.h"
"GPURenderBundleEncoder.h"
"GPURenderPassEncoder.h"
"GPURenderPipeline.h"
"GPUSampler.h"
"GPUShaderModule.h"
"GPUSupportedLimits.h"
"GPUTexture.h"
"GPUTextureView.h"
) )
target_include_directories(dawn_node_binding target_include_directories(dawn_node_binding

View File

@ -0,0 +1,41 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPU_H_
#define DAWN_NODE_BINDING_GPU_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPU is an implementation of interop::GPU that wraps a dawn_native::Instance.
class GPU final : public interop::GPU {
public:
GPU();
// interop::GPU interface compliance
interop::Promise<std::optional<interop::Interface<interop::GPUAdapter>>> requestAdapter(
Napi::Env env,
std::optional<interop::GPURequestAdapterOptions> options) override;
private:
dawn_native::Instance instance_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPU_H_

View File

@ -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.
#ifndef DAWN_NODE_BINDING_GPUADAPTER_H_
#define DAWN_NODE_BINDING_GPUADAPTER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUAdapter is an implementation of interop::GPUAdapter that wraps a dawn_native::Adapter.
class GPUAdapter final : public interop::GPUAdapter {
public:
GPUAdapter(dawn_native::Adapter a);
// interop::GPUAdapter interface compliance
std::string getName(Napi::Env) override;
interop::Interface<interop::GPUSupportedFeatures> getFeatures(Napi::Env) override;
interop::Interface<interop::GPUSupportedLimits> getLimits(Napi::Env) override;
bool getIsFallbackAdapter(Napi::Env) override;
interop::Promise<interop::Interface<interop::GPUDevice>> requestDevice(
Napi::Env env,
std::optional<interop::GPUDeviceDescriptor> descriptor) override;
private:
dawn_native::Adapter adapter_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUADAPTER_H_

View File

@ -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.
#ifndef DAWN_NODE_BINDING_GPUBINDGROUP_H_
#define DAWN_NODE_BINDING_GPUBINDGROUP_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUBindGroup is an implementation of interop::GPUBindGroup that wraps a wgpu::BindGroup.
class GPUBindGroup final : public interop::GPUBindGroup {
public:
GPUBindGroup(wgpu::BindGroup group);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::BindGroup &() const {
return group_;
}
// interop::GPUBindGroup interface compliance
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::BindGroup group_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUBINDGROUP_H_

View File

@ -0,0 +1,46 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUBINDGROUPLAYOUT_H_
#define DAWN_NODE_BINDING_GPUBINDGROUPLAYOUT_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUBindGroupLayout is an implementation of interop::GPUBindGroupLayout that wraps a
// wgpu::BindGroupLayout.
class GPUBindGroupLayout final : public interop::GPUBindGroupLayout {
public:
GPUBindGroupLayout(wgpu::BindGroupLayout layout);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::BindGroupLayout &() const {
return layout_;
}
// interop::GPUBindGroupLayout interface compliance
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::BindGroupLayout layout_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUBINDGROUPLAYOUT_H_

View File

@ -0,0 +1,86 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUBUFFER_H_
#define DAWN_NODE_BINDING_GPUBUFFER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/binding/AsyncRunner.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUBuffer is an implementation of interop::GPUBuffer that wraps a wgpu::Buffer.
class GPUBuffer final : public interop::GPUBuffer {
public:
GPUBuffer(wgpu::Buffer buffer,
wgpu::BufferDescriptor desc,
wgpu::Device device,
std::shared_ptr<AsyncRunner> async);
// Desc() returns the wgpu::BufferDescriptor used to construct the buffer
const wgpu::BufferDescriptor& Desc() const {
return desc_;
}
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::Buffer &() const {
return buffer_;
}
// interop::GPUBuffer interface compliance
interop::Promise<void> mapAsync(Napi::Env env,
interop::GPUMapModeFlags mode,
std::optional<interop::GPUSize64> offset,
std::optional<interop::GPUSize64> size) override;
interop::ArrayBuffer getMappedRange(Napi::Env env,
std::optional<interop::GPUSize64> offset,
std::optional<interop::GPUSize64> size) override;
void unmap(Napi::Env) override;
void destroy(Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
struct Mapping {
uint64_t start;
uint64_t end;
inline bool Intersects(uint64_t s, uint64_t e) const {
return s < end && e > start;
}
Napi::Reference<interop::ArrayBuffer> buffer;
};
// https://www.w3.org/TR/webgpu/#buffer-interface
enum class State {
Unmapped,
Mapped,
MappedAtCreation,
MappingPending,
Destroyed,
};
wgpu::Buffer buffer_;
wgpu::BufferDescriptor const desc_;
wgpu::Device const device_;
std::shared_ptr<AsyncRunner> async_;
State state_ = State::Unmapped;
std::vector<Mapping> mapped_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUBUFFER_H_

View File

@ -0,0 +1,47 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUCOMMANDBUFFER_H_
#define DAWN_NODE_BINDING_GPUCOMMANDBUFFER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUCommandBuffer is an implementation of interop::GPUCommandBuffer that wraps a
// wgpu::CommandBuffer.
class GPUCommandBuffer final : public interop::GPUCommandBuffer {
public:
GPUCommandBuffer(wgpu::CommandBuffer cmd_buf);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::CommandBuffer &() const {
return cmd_buf_;
}
// interop::GPUCommandBuffer interface compliance
interop::Promise<double> getExecutionTime(Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::CommandBuffer cmd_buf_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUCOMMANDBUFFER_H_

View File

@ -0,0 +1,80 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUCOMMANDENCODER_H_
#define DAWN_NODE_BINDING_GPUCOMMANDENCODER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUCommandEncoder is an implementation of interop::GPUCommandEncoder that wraps a
// wgpu::CommandEncoder.
class GPUCommandEncoder final : public interop::GPUCommandEncoder {
public:
GPUCommandEncoder(wgpu::CommandEncoder enc);
// interop::GPUCommandEncoder interface compliance
interop::Interface<interop::GPURenderPassEncoder> beginRenderPass(
Napi::Env,
interop::GPURenderPassDescriptor descriptor) override;
interop::Interface<interop::GPUComputePassEncoder> beginComputePass(
Napi::Env,
std::optional<interop::GPUComputePassDescriptor> descriptor) override;
void copyBufferToBuffer(Napi::Env,
interop::Interface<interop::GPUBuffer> source,
interop::GPUSize64 sourceOffset,
interop::Interface<interop::GPUBuffer> destination,
interop::GPUSize64 destinationOffset,
interop::GPUSize64 size) override;
void copyBufferToTexture(Napi::Env,
interop::GPUImageCopyBuffer source,
interop::GPUImageCopyTexture destination,
interop::GPUExtent3D copySize) override;
void copyTextureToBuffer(Napi::Env,
interop::GPUImageCopyTexture source,
interop::GPUImageCopyBuffer destination,
interop::GPUExtent3D copySize) override;
void copyTextureToTexture(Napi::Env,
interop::GPUImageCopyTexture source,
interop::GPUImageCopyTexture destination,
interop::GPUExtent3D copySize) override;
void pushDebugGroup(Napi::Env, std::string groupLabel) override;
void popDebugGroup(Napi::Env) override;
void insertDebugMarker(Napi::Env, std::string markerLabel) override;
void writeTimestamp(Napi::Env,
interop::Interface<interop::GPUQuerySet> querySet,
interop::GPUSize32 queryIndex) override;
void resolveQuerySet(Napi::Env,
interop::Interface<interop::GPUQuerySet> querySet,
interop::GPUSize32 firstQuery,
interop::GPUSize32 queryCount,
interop::Interface<interop::GPUBuffer> destination,
interop::GPUSize64 destinationOffset) override;
interop::Interface<interop::GPUCommandBuffer> finish(
Napi::Env env,
std::optional<interop::GPUCommandBufferDescriptor> descriptor) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::CommandEncoder enc_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUCOMMANDENCODER_H_

View File

@ -0,0 +1,77 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUCOMPUTEPASSENCODER_H_
#define DAWN_NODE_BINDING_GPUCOMPUTEPASSENCODER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUComputePassEncoder is an implementation of interop::GPUComputePassEncoder that wraps a
// wgpu::ComputePassEncoder.
class GPUComputePassEncoder final : public interop::GPUComputePassEncoder {
public:
GPUComputePassEncoder(wgpu::ComputePassEncoder enc);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::ComputePassEncoder &() const {
return enc_;
}
// interop::GPUComputePassEncoder interface compliance
void setPipeline(Napi::Env,
interop::Interface<interop::GPUComputePipeline> pipeline) override;
void dispatch(Napi::Env,
interop::GPUSize32 x,
std::optional<interop::GPUSize32> y,
std::optional<interop::GPUSize32> z) override;
void dispatchIndirect(Napi::Env,
interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override;
void beginPipelineStatisticsQuery(Napi::Env,
interop::Interface<interop::GPUQuerySet> querySet,
interop::GPUSize32 queryIndex) override;
void endPipelineStatisticsQuery(Napi::Env) override;
void writeTimestamp(Napi::Env,
interop::Interface<interop::GPUQuerySet> querySet,
interop::GPUSize32 queryIndex) override;
void endPass(Napi::Env) override;
void setBindGroup(
Napi::Env,
interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup,
std::optional<std::vector<interop::GPUBufferDynamicOffset>> dynamicOffsets) override;
void setBindGroup(Napi::Env,
interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup,
interop::Uint32Array dynamicOffsetsData,
interop::GPUSize64 dynamicOffsetsDataStart,
interop::GPUSize32 dynamicOffsetsDataLength) override;
void pushDebugGroup(Napi::Env, std::string groupLabel) override;
void popDebugGroup(Napi::Env) override;
void insertDebugMarker(Napi::Env, std::string markerLabel) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::ComputePassEncoder enc_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUCOMPUTEPASSENCODER_H_

View File

@ -0,0 +1,48 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUPIPELINE_H_
#define DAWN_NODE_BINDING_GPUPIPELINE_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUComputePipeline is an implementation of interop::GPUComputePipeline that wraps a
// wgpu::ComputePipeline.
class GPUComputePipeline final : public interop::GPUComputePipeline {
public:
GPUComputePipeline(wgpu::ComputePipeline pipeline);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::ComputePipeline &() const {
return pipeline_;
}
// interop::GPUComputePipeline interface compliance
interop::Interface<interop::GPUBindGroupLayout> getBindGroupLayout(Napi::Env,
uint32_t index) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::ComputePipeline pipeline_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUPIPELINE_H_

View File

@ -0,0 +1,113 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUDEVICE_H_
#define DAWN_NODE_BINDING_GPUDEVICE_H_
#include "dawn/webgpu_cpp.h"
#include "napi.h"
#include "src/dawn_node/binding/AsyncRunner.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUDevice is an implementation of interop::GPUDevice that wraps a wgpu::Device.
class GPUDevice final : public interop::GPUDevice {
public:
GPUDevice(Napi::Env env, wgpu::Device device);
~GPUDevice();
// interop::GPUDevice interface compliance
interop::Interface<interop::GPUSupportedFeatures> getFeatures(Napi::Env) override;
interop::Interface<interop::GPUSupportedLimits> getLimits(Napi::Env) override;
interop::Interface<interop::GPUQueue> getQueue(Napi::Env env) override;
void destroy(Napi::Env) override;
interop::Interface<interop::GPUBuffer> createBuffer(
Napi::Env env,
interop::GPUBufferDescriptor descriptor) override;
interop::Interface<interop::GPUTexture> createTexture(
Napi::Env,
interop::GPUTextureDescriptor descriptor) override;
interop::Interface<interop::GPUSampler> createSampler(
Napi::Env,
std::optional<interop::GPUSamplerDescriptor> descriptor) override;
interop::Interface<interop::GPUExternalTexture> importExternalTexture(
Napi::Env,
interop::GPUExternalTextureDescriptor descriptor) override;
interop::Interface<interop::GPUBindGroupLayout> createBindGroupLayout(
Napi::Env,
interop::GPUBindGroupLayoutDescriptor descriptor) override;
interop::Interface<interop::GPUPipelineLayout> createPipelineLayout(
Napi::Env,
interop::GPUPipelineLayoutDescriptor descriptor) override;
interop::Interface<interop::GPUBindGroup> createBindGroup(
Napi::Env,
interop::GPUBindGroupDescriptor descriptor) override;
interop::Interface<interop::GPUShaderModule> createShaderModule(
Napi::Env,
interop::GPUShaderModuleDescriptor descriptor) override;
interop::Interface<interop::GPUComputePipeline> createComputePipeline(
Napi::Env,
interop::GPUComputePipelineDescriptor descriptor) override;
interop::Interface<interop::GPURenderPipeline> createRenderPipeline(
Napi::Env,
interop::GPURenderPipelineDescriptor descriptor) override;
interop::Promise<interop::Interface<interop::GPUComputePipeline>>
createComputePipelineAsync(Napi::Env env,
interop::GPUComputePipelineDescriptor descriptor) override;
interop::Promise<interop::Interface<interop::GPURenderPipeline>> createRenderPipelineAsync(
Napi::Env env,
interop::GPURenderPipelineDescriptor descriptor) override;
interop::Interface<interop::GPUCommandEncoder> createCommandEncoder(
Napi::Env env,
std::optional<interop::GPUCommandEncoderDescriptor> descriptor) override;
interop::Interface<interop::GPURenderBundleEncoder> createRenderBundleEncoder(
Napi::Env,
interop::GPURenderBundleEncoderDescriptor descriptor) override;
interop::Interface<interop::GPUQuerySet> createQuerySet(
Napi::Env,
interop::GPUQuerySetDescriptor descriptor) override;
interop::Promise<interop::Interface<interop::GPUDeviceLostInfo>> getLost(
Napi::Env env) override;
void pushErrorScope(Napi::Env, interop::GPUErrorFilter filter) override;
interop::Promise<std::optional<interop::GPUError>> popErrorScope(Napi::Env env) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
interop::Interface<interop::EventHandler> getOnuncapturederror(Napi::Env) override;
void setOnuncapturederror(Napi::Env,
interop::Interface<interop::EventHandler> value) override;
void addEventListener(
Napi::Env,
std::string type,
std::optional<interop::Interface<interop::EventListener>> callback,
std::optional<std::variant<interop::AddEventListenerOptions, bool>> options) override;
void removeEventListener(
Napi::Env,
std::string type,
std::optional<interop::Interface<interop::EventListener>> callback,
std::optional<std::variant<interop::EventListenerOptions, bool>> options) override;
bool dispatchEvent(Napi::Env, interop::Interface<interop::Event> event) override;
private:
void QueueTick();
Napi::Env env_;
wgpu::Device device_;
std::shared_ptr<AsyncRunner> async_;
std::vector<interop::Promise<interop::Interface<interop::GPUDeviceLostInfo>>>
lost_promises_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUDEVICE_H_

View File

@ -0,0 +1,46 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUPIPELINELAYOUT_H_
#define DAWN_NODE_BINDING_GPUPIPELINELAYOUT_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUPipelineLayout is an implementation of interop::GPUPipelineLayout that wraps a
// wgpu::PipelineLayout.
class GPUPipelineLayout final : public interop::GPUPipelineLayout {
public:
GPUPipelineLayout(wgpu::PipelineLayout layout);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::PipelineLayout &() const {
return layout_;
}
// interop::GPUPipelineLayout interface compliance
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::PipelineLayout layout_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUPIPELINELAYOUT_H_

View File

@ -0,0 +1,46 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUQUERYSET_H_
#define DAWN_NODE_BINDING_GPUQUERYSET_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUQuerySet is an implementation of interop::GPUQuerySet that wraps a wgpu::QuerySet.
class GPUQuerySet final : public interop::GPUQuerySet {
public:
GPUQuerySet(wgpu::QuerySet query_set);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::QuerySet &() const {
return query_set_;
}
// interop::GPUQuerySet interface compliance
void destroy(Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::QuerySet query_set_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUQUERYSET_H_

View File

@ -0,0 +1,61 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUQUEUE_H_
#define DAWN_NODE_BINDING_GPUQUEUE_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/binding/AsyncRunner.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUQueue is an implementation of interop::GPUQueue that wraps a wgpu::Queue.
class GPUQueue final : public interop::GPUQueue {
public:
GPUQueue(wgpu::Queue queue, std::shared_ptr<AsyncRunner> async);
// interop::GPUQueue interface compliance
void submit(
Napi::Env,
std::vector<interop::Interface<interop::GPUCommandBuffer>> commandBuffers) override;
interop::Promise<void> onSubmittedWorkDone(Napi::Env) override;
void writeBuffer(Napi::Env,
interop::Interface<interop::GPUBuffer> buffer,
interop::GPUSize64 bufferOffset,
interop::BufferSource data,
std::optional<interop::GPUSize64> dataOffset,
std::optional<interop::GPUSize64> size) override;
void writeTexture(Napi::Env,
interop::GPUImageCopyTexture destination,
interop::BufferSource data,
interop::GPUImageDataLayout dataLayout,
interop::GPUExtent3D size) override;
void copyExternalImageToTexture(Napi::Env,
interop::GPUImageCopyExternalImage source,
interop::GPUImageCopyTextureTagged destination,
interop::GPUExtent3D copySize) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::Queue queue_;
std::shared_ptr<AsyncRunner> async_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUQUEUE_H_

View File

@ -0,0 +1,46 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPURENDERBUNDLE_H_
#define DAWN_NODE_BINDING_GPURENDERBUNDLE_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPURenderBundle is an implementation of interop::GPURenderBundle that wraps a
// wgpu::RenderBundle.
class GPURenderBundle final : public interop::GPURenderBundle {
public:
GPURenderBundle(wgpu::RenderBundle bundle);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::RenderBundle &() const {
return bundle_;
}
// interop::GPURenderBundle interface compliance
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::RenderBundle bundle_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPURENDERBUNDLE_H_

View File

@ -0,0 +1,87 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPURENDERBUNDLEENCODER_H_
#define DAWN_NODE_BINDING_GPURENDERBUNDLEENCODER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPURenderBundleEncoder is an implementation of interop::GPURenderBundleEncoder that wraps a
// wgpu::RenderBundleEncoder.
class GPURenderBundleEncoder final : public interop::GPURenderBundleEncoder {
public:
GPURenderBundleEncoder(wgpu::RenderBundleEncoder enc);
// interop::GPURenderBundleEncoder interface compliance
interop::Interface<interop::GPURenderBundle> finish(
Napi::Env,
std::optional<interop::GPURenderBundleDescriptor> descriptor) override;
void setBindGroup(
Napi::Env,
interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup,
std::optional<std::vector<interop::GPUBufferDynamicOffset>> dynamicOffsets) override;
void setBindGroup(Napi::Env,
interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup,
interop::Uint32Array dynamicOffsetsData,
interop::GPUSize64 dynamicOffsetsDataStart,
interop::GPUSize32 dynamicOffsetsDataLength) override;
void pushDebugGroup(Napi::Env, std::string groupLabel) override;
void popDebugGroup(Napi::Env) override;
void insertDebugMarker(Napi::Env, std::string markerLabel) override;
void setPipeline(Napi::Env,
interop::Interface<interop::GPURenderPipeline> pipeline) override;
void setIndexBuffer(Napi::Env,
interop::Interface<interop::GPUBuffer> buffer,
interop::GPUIndexFormat indexFormat,
std::optional<interop::GPUSize64> offset,
std::optional<interop::GPUSize64> size) override;
void setVertexBuffer(Napi::Env,
interop::GPUIndex32 slot,
interop::Interface<interop::GPUBuffer> buffer,
std::optional<interop::GPUSize64> offset,
std::optional<interop::GPUSize64> size) override;
void draw(Napi::Env,
interop::GPUSize32 vertexCount,
std::optional<interop::GPUSize32> instanceCount,
std::optional<interop::GPUSize32> firstVertex,
std::optional<interop::GPUSize32> firstInstance) override;
void drawIndexed(Napi::Env,
interop::GPUSize32 indexCount,
std::optional<interop::GPUSize32> instanceCount,
std::optional<interop::GPUSize32> firstIndex,
std::optional<interop::GPUSignedOffset32> baseVertex,
std::optional<interop::GPUSize32> firstInstance) override;
void drawIndirect(Napi::Env,
interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override;
void drawIndexedIndirect(Napi::Env,
interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::RenderBundleEncoder enc_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPURENDERBUNDLEENCODER_H_

View File

@ -0,0 +1,116 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPURENDERPASSENCODER_H_
#define DAWN_NODE_BINDING_GPURENDERPASSENCODER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPURenderPassEncoder is an implementation of interop::GPURenderPassEncoder that wraps a
// wgpu::RenderPassEncoder.
class GPURenderPassEncoder final : public interop::GPURenderPassEncoder {
public:
GPURenderPassEncoder(wgpu::RenderPassEncoder enc);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::RenderPassEncoder &() const {
return enc_;
}
// interop::GPURenderPassEncoder interface compliance
void setViewport(Napi::Env,
float x,
float y,
float width,
float height,
float minDepth,
float maxDepth) override;
void setScissorRect(Napi::Env,
interop::GPUIntegerCoordinate x,
interop::GPUIntegerCoordinate y,
interop::GPUIntegerCoordinate width,
interop::GPUIntegerCoordinate height) override;
void setBlendConstant(Napi::Env, interop::GPUColor color) override;
void setStencilReference(Napi::Env, interop::GPUStencilValue reference) override;
void beginOcclusionQuery(Napi::Env, interop::GPUSize32 queryIndex) override;
void endOcclusionQuery(Napi::Env) override;
void beginPipelineStatisticsQuery(Napi::Env,
interop::Interface<interop::GPUQuerySet> querySet,
interop::GPUSize32 queryIndex) override;
void endPipelineStatisticsQuery(Napi::Env) override;
void writeTimestamp(Napi::Env,
interop::Interface<interop::GPUQuerySet> querySet,
interop::GPUSize32 queryIndex) override;
void executeBundles(
Napi::Env,
std::vector<interop::Interface<interop::GPURenderBundle>> bundles) override;
void endPass(Napi::Env) override;
void setBindGroup(
Napi::Env,
interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup,
std::optional<std::vector<interop::GPUBufferDynamicOffset>> dynamicOffsets) override;
void setBindGroup(Napi::Env,
interop::GPUIndex32 index,
interop::Interface<interop::GPUBindGroup> bindGroup,
interop::Uint32Array dynamicOffsetsData,
interop::GPUSize64 dynamicOffsetsDataStart,
interop::GPUSize32 dynamicOffsetsDataLength) override;
void pushDebugGroup(Napi::Env, std::string groupLabel) override;
void popDebugGroup(Napi::Env) override;
void insertDebugMarker(Napi::Env, std::string markerLabel) override;
void setPipeline(Napi::Env,
interop::Interface<interop::GPURenderPipeline> pipeline) override;
void setIndexBuffer(Napi::Env,
interop::Interface<interop::GPUBuffer> buffer,
interop::GPUIndexFormat indexFormat,
std::optional<interop::GPUSize64> offset,
std::optional<interop::GPUSize64> size) override;
void setVertexBuffer(Napi::Env,
interop::GPUIndex32 slot,
interop::Interface<interop::GPUBuffer> buffer,
std::optional<interop::GPUSize64> offset,
std::optional<interop::GPUSize64> size) override;
void draw(Napi::Env,
interop::GPUSize32 vertexCount,
std::optional<interop::GPUSize32> instanceCount,
std::optional<interop::GPUSize32> firstVertex,
std::optional<interop::GPUSize32> firstInstance) override;
void drawIndexed(Napi::Env,
interop::GPUSize32 indexCount,
std::optional<interop::GPUSize32> instanceCount,
std::optional<interop::GPUSize32> firstIndex,
std::optional<interop::GPUSignedOffset32> baseVertex,
std::optional<interop::GPUSize32> firstInstance) override;
void drawIndirect(Napi::Env,
interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override;
void drawIndexedIndirect(Napi::Env,
interop::Interface<interop::GPUBuffer> indirectBuffer,
interop::GPUSize64 indirectOffset) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::RenderPassEncoder enc_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPURENDERPASSENCODER_H_

View File

@ -0,0 +1,48 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPURENDERPIPELINE_H_
#define DAWN_NODE_BINDING_GPURENDERPIPELINE_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPURenderPipeline is an implementation of interop::GPURenderPipeline that wraps a
// wgpu::RenderPipeline.
class GPURenderPipeline final : public interop::GPURenderPipeline {
public:
GPURenderPipeline(wgpu::RenderPipeline pipeline);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::RenderPipeline &() const {
return pipeline_;
}
// interop::GPURenderPipeline interface compliance
interop::Interface<interop::GPUBindGroupLayout> getBindGroupLayout(Napi::Env,
uint32_t index) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::RenderPipeline pipeline_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPURENDERPIPELINE_H_

View File

@ -0,0 +1,44 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUSAMPLER_H_
#define DAWN_NODE_BINDING_GPUSAMPLER_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUSampler is an implementation of interop::GPUSampler that wraps a wgpu::Sampler.
class GPUSampler final : public interop::GPUSampler {
public:
GPUSampler(wgpu::Sampler sampler);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::Sampler &() const {
return sampler_;
}
// interop::GPUSampler interface compliance
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::Sampler sampler_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUSAMPLER_H_

View File

@ -0,0 +1,50 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUSHADERMODULE_H_
#define DAWN_NODE_BINDING_GPUSHADERMODULE_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/binding/AsyncRunner.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUShaderModule is an implementation of interop::GPUShaderModule that wraps a
// wgpu::ShaderModule.
class GPUShaderModule final : public interop::GPUShaderModule {
public:
GPUShaderModule(wgpu::ShaderModule shader, std::shared_ptr<AsyncRunner> async);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::ShaderModule &() const {
return shader_;
}
// interop::GPUShaderModule interface compliance
interop::Promise<interop::Interface<interop::GPUCompilationInfo>> compilationInfo(
Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::ShaderModule shader_;
std::shared_ptr<AsyncRunner> async_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUSHADERMODULE_H_

View File

@ -0,0 +1,59 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUSUPPORTEDLIMITS_H_
#define DAWN_NODE_BINDING_GPUSUPPORTEDLIMITS_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUSupportedLimits is an implementation of interop::GPUSupportedLimits.
class GPUSupportedLimits final : public interop::GPUSupportedLimits {
public:
// interop::GPUSupportedLimits interface compliance
uint32_t getMaxTextureDimension1D(Napi::Env) override;
uint32_t getMaxTextureDimension2D(Napi::Env) override;
uint32_t getMaxTextureDimension3D(Napi::Env) override;
uint32_t getMaxTextureArrayLayers(Napi::Env) override;
uint32_t getMaxBindGroups(Napi::Env) override;
uint32_t getMaxDynamicUniformBuffersPerPipelineLayout(Napi::Env) override;
uint32_t getMaxDynamicStorageBuffersPerPipelineLayout(Napi::Env) override;
uint32_t getMaxSampledTexturesPerShaderStage(Napi::Env) override;
uint32_t getMaxSamplersPerShaderStage(Napi::Env) override;
uint32_t getMaxStorageBuffersPerShaderStage(Napi::Env) override;
uint32_t getMaxStorageTexturesPerShaderStage(Napi::Env) override;
uint32_t getMaxUniformBuffersPerShaderStage(Napi::Env) override;
uint64_t getMaxUniformBufferBindingSize(Napi::Env) override;
uint64_t getMaxStorageBufferBindingSize(Napi::Env) override;
uint32_t getMinUniformBufferOffsetAlignment(Napi::Env) override;
uint32_t getMinStorageBufferOffsetAlignment(Napi::Env) override;
uint32_t getMaxVertexBuffers(Napi::Env) override;
uint32_t getMaxVertexAttributes(Napi::Env) override;
uint32_t getMaxVertexBufferArrayStride(Napi::Env) override;
uint32_t getMaxInterStageShaderComponents(Napi::Env) override;
uint32_t getMaxComputeWorkgroupStorageSize(Napi::Env) override;
uint32_t getMaxComputeInvocationsPerWorkgroup(Napi::Env) override;
uint32_t getMaxComputeWorkgroupSizeX(Napi::Env) override;
uint32_t getMaxComputeWorkgroupSizeY(Napi::Env) override;
uint32_t getMaxComputeWorkgroupSizeZ(Napi::Env) override;
uint32_t getMaxComputeWorkgroupsPerDimension(Napi::Env) override;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUSUPPORTEDLIMITS_H_

View File

@ -0,0 +1,49 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUTEXTURE_H_
#define DAWN_NODE_BINDING_GPUTEXTURE_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUTexture is an implementation of interop::GPUTexture that wraps a wgpu::Texture.
class GPUTexture final : public interop::GPUTexture {
public:
GPUTexture(wgpu::Texture texture);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::Texture &() const {
return texture_;
}
// interop::GPUTexture interface compliance
interop::Interface<interop::GPUTextureView> createView(
Napi::Env,
std::optional<interop::GPUTextureViewDescriptor> descriptor) override;
void destroy(Napi::Env) override;
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::Texture texture_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUTEXTURE_H_

View File

@ -0,0 +1,46 @@
// 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.
#ifndef DAWN_NODE_BINDING_GPUTEXTUREVIEW_H_
#define DAWN_NODE_BINDING_GPUTEXTUREVIEW_H_
#include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h"
#include "napi.h"
#include "src/dawn_node/interop/WebGPU.h"
namespace wgpu { namespace binding {
// GPUTextureView is an implementation of interop::GPUTextureView that wraps a
// wgpu::TextureView.
class GPUTextureView final : public interop::GPUTextureView {
public:
GPUTextureView(wgpu::TextureView view);
// Implicit cast operator to Dawn GPU object
inline operator const wgpu::TextureView &() const {
return view_;
}
// interop::GPUTextureView interface compliance
std::optional<std::string> getLabel(Napi::Env) override;
void setLabel(Napi::Env, std::optional<std::string> value) override;
private:
wgpu::TextureView view_;
};
}} // namespace wgpu::binding
#endif // DAWN_NODE_BINDING_GPUTEXTUREVIEW_H_