@shopify/react-native-skia 2.4.15 → 2.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +69 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +19 -7
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +7 -0
- package/apple/RNSkApplePlatformContext.mm +4 -0
- package/cpp/api/JsiSkApi.h +31 -0
- package/cpp/api/JsiSkImageFactory.h +69 -1
- package/cpp/api/JsiSkImageFilter.h +1 -0
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/jsi/RuntimeAwareCache.h +0 -2
- package/cpp/jsi2/EnumMapper.h +45 -0
- package/cpp/jsi2/JSIConverter.h +468 -0
- package/cpp/jsi2/NativeObject.h +598 -0
- package/cpp/jsi2/Promise.cpp +44 -0
- package/cpp/jsi2/Promise.h +35 -0
- package/cpp/rnskia/RNDawnContext.h +114 -0
- package/cpp/rnskia/RNSkManager.cpp +41 -1
- package/cpp/rnwgpu/ArrayBuffer.h +68 -0
- package/cpp/rnwgpu/api/Convertors.h +761 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +129 -0
- package/cpp/rnwgpu/api/GPU.h +57 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +178 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +434 -0
- package/cpp/rnwgpu/api/GPUDevice.h +174 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
- package/cpp/rnwgpu/api/GPUError.h +35 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
- package/cpp/rnwgpu/api/GPUFeatures.h +212 -0
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
- package/cpp/rnwgpu/api/GPUQueue.h +84 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
- package/cpp/rnwgpu/api/GPUSampler.h +44 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +150 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +97 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +52 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +99 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +38 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +43 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +101 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +110 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +53 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1984 -0
- package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
- package/cpp/rnwgpu/async/AsyncRunner.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncRunner.h +56 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
- package/lib/commonjs/Platform/Platform.web.js +1 -2
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -4
- package/lib/commonjs/renderer/Canvas.js +4 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +1 -2
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/FitBox.js +1 -2
- package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/commonjs/skia/types/ContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +17 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +6 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +4 -4
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/web/WithSkiaWeb.js +1 -2
- package/lib/commonjs/web/WithSkiaWeb.js.map +1 -1
- package/lib/module/external/reanimated/buffers.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +1 -4
- package/lib/module/renderer/Canvas.js +3 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/ContourMeasure.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +17 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/module/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +6 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js +4 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +3 -2
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -4
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +17 -0
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/package.json +20 -16
- package/react-native-skia.podspec +52 -13
- package/scripts/install-skia.mjs +99 -48
- package/src/external/reanimated/buffers.ts +1 -1
- package/src/renderer/Canvas.tsx +3 -2
- package/src/skia/types/ContourMeasure.tsx +1 -2
- package/src/skia/types/Image/ImageFactory.ts +22 -0
- package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -2
- package/src/skia/types/Skia.ts +17 -0
- package/src/skia/web/JsiSkImageFactory.ts +8 -0
- package/src/skia/web/JsiSkia.ts +6 -0
- package/src/sksg/Recorder/commands/ColorFilters.ts +3 -2
- package/src/sksg/Recorder/commands/ImageFilters.ts +3 -2
- package/src/sksg/Recorder/commands/PathEffects.ts +3 -2
- package/src/sksg/Recorder/commands/Shaders.ts +3 -2
- package/src/specs/SkiaPictureViewNativeComponent.ts +7 -0
- package/src/views/SkiaPictureView.web.tsx +4 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <unordered_set>
|
|
7
|
+
#include <utility>
|
|
8
|
+
#include <variant>
|
|
9
|
+
|
|
10
|
+
#include "descriptors/Unions.h"
|
|
11
|
+
|
|
12
|
+
#include "jsi2/NativeObject.h"
|
|
13
|
+
|
|
14
|
+
#include "rnwgpu/async/AsyncRunner.h"
|
|
15
|
+
#include "rnwgpu/async/AsyncTaskHandle.h"
|
|
16
|
+
|
|
17
|
+
#include "webgpu/webgpu_cpp.h"
|
|
18
|
+
|
|
19
|
+
#include "GPUBindGroup.h"
|
|
20
|
+
#include "descriptors/GPUBindGroupDescriptor.h"
|
|
21
|
+
#include "GPUBindGroupLayout.h"
|
|
22
|
+
#include "descriptors/GPUBindGroupLayoutDescriptor.h"
|
|
23
|
+
#include "GPUBuffer.h"
|
|
24
|
+
#include "descriptors/GPUBufferDescriptor.h"
|
|
25
|
+
#include "GPUCommandEncoder.h"
|
|
26
|
+
#include "descriptors/GPUCommandEncoderDescriptor.h"
|
|
27
|
+
#include "GPUComputePipeline.h"
|
|
28
|
+
#include "descriptors/GPUComputePipelineDescriptor.h"
|
|
29
|
+
#include "GPUDeviceLostInfo.h"
|
|
30
|
+
#include "GPUError.h"
|
|
31
|
+
#include "GPUExternalTexture.h"
|
|
32
|
+
#include "descriptors/GPUExternalTextureDescriptor.h"
|
|
33
|
+
#include "GPUPipelineLayout.h"
|
|
34
|
+
#include "descriptors/GPUPipelineLayoutDescriptor.h"
|
|
35
|
+
#include "GPUQuerySet.h"
|
|
36
|
+
#include "descriptors/GPUQuerySetDescriptor.h"
|
|
37
|
+
#include "GPUQueue.h"
|
|
38
|
+
#include "GPURenderBundleEncoder.h"
|
|
39
|
+
#include "descriptors/GPURenderBundleEncoderDescriptor.h"
|
|
40
|
+
#include "GPURenderPipeline.h"
|
|
41
|
+
#include "descriptors/GPURenderPipelineDescriptor.h"
|
|
42
|
+
#include "GPUSampler.h"
|
|
43
|
+
#include "descriptors/GPUSamplerDescriptor.h"
|
|
44
|
+
#include "GPUShaderModule.h"
|
|
45
|
+
#include "descriptors/GPUShaderModuleDescriptor.h"
|
|
46
|
+
#include "GPUSupportedLimits.h"
|
|
47
|
+
#include "GPUTexture.h"
|
|
48
|
+
#include "descriptors/GPUTextureDescriptor.h"
|
|
49
|
+
|
|
50
|
+
namespace rnwgpu {
|
|
51
|
+
|
|
52
|
+
namespace jsi = facebook::jsi;
|
|
53
|
+
|
|
54
|
+
class GPUDevice : public NativeObject<GPUDevice> {
|
|
55
|
+
public:
|
|
56
|
+
static constexpr const char *CLASS_NAME = "GPUDevice";
|
|
57
|
+
|
|
58
|
+
explicit GPUDevice(wgpu::Device instance,
|
|
59
|
+
std::shared_ptr<async::AsyncRunner> async,
|
|
60
|
+
std::string label)
|
|
61
|
+
: NativeObject(CLASS_NAME), _instance(instance), _async(async),
|
|
62
|
+
_label(label) {}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
66
|
+
|
|
67
|
+
void destroy();
|
|
68
|
+
std::shared_ptr<GPUBuffer>
|
|
69
|
+
createBuffer(std::shared_ptr<GPUBufferDescriptor> descriptor);
|
|
70
|
+
std::shared_ptr<GPUTexture>
|
|
71
|
+
createTexture(std::shared_ptr<GPUTextureDescriptor> descriptor);
|
|
72
|
+
std::shared_ptr<GPUSampler> createSampler(
|
|
73
|
+
std::optional<std::shared_ptr<GPUSamplerDescriptor>> descriptor);
|
|
74
|
+
std::shared_ptr<GPUExternalTexture> importExternalTexture(
|
|
75
|
+
std::shared_ptr<GPUExternalTextureDescriptor> descriptor);
|
|
76
|
+
std::shared_ptr<GPUBindGroupLayout> createBindGroupLayout(
|
|
77
|
+
std::shared_ptr<GPUBindGroupLayoutDescriptor> descriptor);
|
|
78
|
+
std::shared_ptr<GPUPipelineLayout>
|
|
79
|
+
createPipelineLayout(std::shared_ptr<GPUPipelineLayoutDescriptor> descriptor);
|
|
80
|
+
std::shared_ptr<GPUBindGroup>
|
|
81
|
+
createBindGroup(std::shared_ptr<GPUBindGroupDescriptor> descriptor);
|
|
82
|
+
std::shared_ptr<GPUShaderModule>
|
|
83
|
+
createShaderModule(std::shared_ptr<GPUShaderModuleDescriptor> descriptor);
|
|
84
|
+
std::shared_ptr<GPUComputePipeline> createComputePipeline(
|
|
85
|
+
std::shared_ptr<GPUComputePipelineDescriptor> descriptor);
|
|
86
|
+
std::shared_ptr<GPURenderPipeline>
|
|
87
|
+
createRenderPipeline(std::shared_ptr<GPURenderPipelineDescriptor> descriptor);
|
|
88
|
+
async::AsyncTaskHandle createComputePipelineAsync(
|
|
89
|
+
std::shared_ptr<GPUComputePipelineDescriptor> descriptor);
|
|
90
|
+
async::AsyncTaskHandle createRenderPipelineAsync(
|
|
91
|
+
std::shared_ptr<GPURenderPipelineDescriptor> descriptor);
|
|
92
|
+
std::shared_ptr<GPUCommandEncoder> createCommandEncoder(
|
|
93
|
+
std::optional<std::shared_ptr<GPUCommandEncoderDescriptor>> descriptor);
|
|
94
|
+
std::shared_ptr<GPURenderBundleEncoder> createRenderBundleEncoder(
|
|
95
|
+
std::shared_ptr<GPURenderBundleEncoderDescriptor> descriptor);
|
|
96
|
+
std::shared_ptr<GPUQuerySet>
|
|
97
|
+
createQuerySet(std::shared_ptr<GPUQuerySetDescriptor> descriptor);
|
|
98
|
+
void pushErrorScope(wgpu::ErrorFilter filter);
|
|
99
|
+
async::AsyncTaskHandle popErrorScope();
|
|
100
|
+
|
|
101
|
+
std::unordered_set<std::string> getFeatures();
|
|
102
|
+
std::shared_ptr<GPUSupportedLimits> getLimits();
|
|
103
|
+
std::shared_ptr<GPUQueue> getQueue();
|
|
104
|
+
async::AsyncTaskHandle getLost();
|
|
105
|
+
void notifyDeviceLost(wgpu::DeviceLostReason reason, std::string message);
|
|
106
|
+
void forceLossForTesting();
|
|
107
|
+
|
|
108
|
+
std::string getLabel() { return _label; }
|
|
109
|
+
void setLabel(const std::string &label) {
|
|
110
|
+
_label = label;
|
|
111
|
+
_instance.SetLabel(_label.c_str());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
115
|
+
installGetter(runtime, prototype, "__brand", &GPUDevice::getBrand);
|
|
116
|
+
installMethod(runtime, prototype, "destroy", &GPUDevice::destroy);
|
|
117
|
+
installMethod(runtime, prototype, "createBuffer", &GPUDevice::createBuffer);
|
|
118
|
+
installMethod(runtime, prototype, "createTexture",
|
|
119
|
+
&GPUDevice::createTexture);
|
|
120
|
+
installMethod(runtime, prototype, "createSampler",
|
|
121
|
+
&GPUDevice::createSampler);
|
|
122
|
+
installMethod(runtime, prototype, "importExternalTexture",
|
|
123
|
+
&GPUDevice::importExternalTexture);
|
|
124
|
+
installMethod(runtime, prototype, "createBindGroupLayout",
|
|
125
|
+
&GPUDevice::createBindGroupLayout);
|
|
126
|
+
installMethod(runtime, prototype, "createPipelineLayout",
|
|
127
|
+
&GPUDevice::createPipelineLayout);
|
|
128
|
+
installMethod(runtime, prototype, "createBindGroup",
|
|
129
|
+
&GPUDevice::createBindGroup);
|
|
130
|
+
installMethod(runtime, prototype, "createShaderModule",
|
|
131
|
+
&GPUDevice::createShaderModule);
|
|
132
|
+
installMethod(runtime, prototype, "createComputePipeline",
|
|
133
|
+
&GPUDevice::createComputePipeline);
|
|
134
|
+
installMethod(runtime, prototype, "createRenderPipeline",
|
|
135
|
+
&GPUDevice::createRenderPipeline);
|
|
136
|
+
installMethod(runtime, prototype, "createComputePipelineAsync",
|
|
137
|
+
&GPUDevice::createComputePipelineAsync);
|
|
138
|
+
installMethod(runtime, prototype, "createRenderPipelineAsync",
|
|
139
|
+
&GPUDevice::createRenderPipelineAsync);
|
|
140
|
+
installMethod(runtime, prototype, "createCommandEncoder",
|
|
141
|
+
&GPUDevice::createCommandEncoder);
|
|
142
|
+
installMethod(runtime, prototype, "createRenderBundleEncoder",
|
|
143
|
+
&GPUDevice::createRenderBundleEncoder);
|
|
144
|
+
installMethod(runtime, prototype, "createQuerySet",
|
|
145
|
+
&GPUDevice::createQuerySet);
|
|
146
|
+
installMethod(runtime, prototype, "pushErrorScope",
|
|
147
|
+
&GPUDevice::pushErrorScope);
|
|
148
|
+
installMethod(runtime, prototype, "popErrorScope",
|
|
149
|
+
&GPUDevice::popErrorScope);
|
|
150
|
+
installGetter(runtime, prototype, "features", &GPUDevice::getFeatures);
|
|
151
|
+
installGetter(runtime, prototype, "limits", &GPUDevice::getLimits);
|
|
152
|
+
installGetter(runtime, prototype, "queue", &GPUDevice::getQueue);
|
|
153
|
+
installGetter(runtime, prototype, "lost", &GPUDevice::getLost);
|
|
154
|
+
installGetterSetter(runtime, prototype, "label", &GPUDevice::getLabel,
|
|
155
|
+
&GPUDevice::setLabel);
|
|
156
|
+
installMethod(runtime, prototype, "forceLossForTesting",
|
|
157
|
+
&GPUDevice::forceLossForTesting);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
inline const wgpu::Device get() { return _instance; }
|
|
161
|
+
|
|
162
|
+
private:
|
|
163
|
+
friend class GPUAdapter;
|
|
164
|
+
|
|
165
|
+
wgpu::Device _instance;
|
|
166
|
+
std::shared_ptr<async::AsyncRunner> _async;
|
|
167
|
+
std::string _label;
|
|
168
|
+
std::optional<async::AsyncTaskHandle> _lostHandle;
|
|
169
|
+
std::shared_ptr<GPUDeviceLostInfo> _lostInfo;
|
|
170
|
+
bool _lostSettled = false;
|
|
171
|
+
std::optional<async::AsyncTaskHandle::ResolveFunction> _lostResolve;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include "descriptors/Unions.h"
|
|
6
|
+
|
|
7
|
+
#include "jsi2/NativeObject.h"
|
|
8
|
+
|
|
9
|
+
#include "webgpu/webgpu_cpp.h"
|
|
10
|
+
|
|
11
|
+
namespace rnwgpu {
|
|
12
|
+
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
|
+
|
|
15
|
+
class GPUDeviceLostInfo : public NativeObject<GPUDeviceLostInfo> {
|
|
16
|
+
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUDeviceLostInfo";
|
|
18
|
+
|
|
19
|
+
explicit GPUDeviceLostInfo(wgpu::DeviceLostReason reason, std::string message)
|
|
20
|
+
: NativeObject(CLASS_NAME), _reason(reason), _message(message) {}
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
24
|
+
|
|
25
|
+
wgpu::DeviceLostReason getReason() { return _reason; }
|
|
26
|
+
std::string getMessage() { return _message; }
|
|
27
|
+
|
|
28
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
29
|
+
installGetter(runtime, prototype, "__brand", &GPUDeviceLostInfo::getBrand);
|
|
30
|
+
installGetter(runtime, prototype, "reason", &GPUDeviceLostInfo::getReason);
|
|
31
|
+
installGetter(runtime, prototype, "message",
|
|
32
|
+
&GPUDeviceLostInfo::getMessage);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
wgpu::DeviceLostReason _reason;
|
|
37
|
+
std::string _message;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include "jsi2/NativeObject.h"
|
|
6
|
+
|
|
7
|
+
namespace rnwgpu {
|
|
8
|
+
|
|
9
|
+
namespace jsi = facebook::jsi;
|
|
10
|
+
|
|
11
|
+
class GPUError : public NativeObject<GPUError> {
|
|
12
|
+
public:
|
|
13
|
+
static constexpr const char *CLASS_NAME = "GPUError";
|
|
14
|
+
|
|
15
|
+
explicit GPUError(std::string message)
|
|
16
|
+
: NativeObject(CLASS_NAME), _message(std::move(message)) {}
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
20
|
+
std::string getMessage() { return _message; }
|
|
21
|
+
|
|
22
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
23
|
+
installGetter(runtime, prototype, "__brand", &GPUError::getBrand);
|
|
24
|
+
installGetter(runtime, prototype, "message", &GPUError::getMessage);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected:
|
|
28
|
+
// Protected constructor for subclasses
|
|
29
|
+
GPUError(const char *className, std::string message)
|
|
30
|
+
: NativeObject(className), _message(std::move(message)) {}
|
|
31
|
+
|
|
32
|
+
std::string _message;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "jsi2/JSIConverter.h"
|
|
6
|
+
|
|
7
|
+
#include "webgpu/webgpu_cpp.h"
|
|
8
|
+
|
|
9
|
+
namespace rnwgpu {
|
|
10
|
+
|
|
11
|
+
struct GPUExtent3D {
|
|
12
|
+
double width;
|
|
13
|
+
double height = 1;
|
|
14
|
+
double depthOrArrayLayers = 1;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
template <> struct JSIConverter<std::shared_ptr<GPUExtent3D>> {
|
|
18
|
+
static std::shared_ptr<GPUExtent3D>
|
|
19
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
20
|
+
auto result = std::make_unique<GPUExtent3D>();
|
|
21
|
+
if (!outOfBounds && arg.isObject()) {
|
|
22
|
+
if (arg.getObject(runtime).isArray(runtime)) {
|
|
23
|
+
auto array = arg.getObject(runtime).asArray(runtime);
|
|
24
|
+
auto size = array.size(runtime);
|
|
25
|
+
if (size == 0) {
|
|
26
|
+
throw std::runtime_error(
|
|
27
|
+
"Expected an array of size >1 for GPUTExtent3D");
|
|
28
|
+
}
|
|
29
|
+
if (size > 0) {
|
|
30
|
+
result->width = array.getValueAtIndex(runtime, 0).asNumber();
|
|
31
|
+
}
|
|
32
|
+
if (size > 1) {
|
|
33
|
+
result->height = array.getValueAtIndex(runtime, 1).asNumber();
|
|
34
|
+
}
|
|
35
|
+
if (size > 2) {
|
|
36
|
+
result->depthOrArrayLayers =
|
|
37
|
+
array.getValueAtIndex(runtime, 2).asNumber();
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
auto object = arg.getObject(runtime);
|
|
41
|
+
if (object.hasProperty(runtime, "width")) {
|
|
42
|
+
result->width = object.getProperty(runtime, "width").asNumber();
|
|
43
|
+
} else {
|
|
44
|
+
throw std::runtime_error("Property GPUTExtent3D::width is required");
|
|
45
|
+
}
|
|
46
|
+
if (object.hasProperty(runtime, "height")) {
|
|
47
|
+
result->height = object.getProperty(runtime, "height").asNumber();
|
|
48
|
+
}
|
|
49
|
+
if (object.hasProperty(runtime, "depthOrArrayLayers")) {
|
|
50
|
+
result->depthOrArrayLayers =
|
|
51
|
+
object.getProperty(runtime, "depthOrArrayLayers").asNumber();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
throw std::runtime_error("Expected an object for GPUTExtent3D");
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
60
|
+
std::shared_ptr<GPUExtent3D> arg) {
|
|
61
|
+
// No conversions here
|
|
62
|
+
return jsi::Value::null();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include "descriptors/Unions.h"
|
|
6
|
+
|
|
7
|
+
#include "jsi2/NativeObject.h"
|
|
8
|
+
|
|
9
|
+
#include "webgpu/webgpu_cpp.h"
|
|
10
|
+
|
|
11
|
+
namespace rnwgpu {
|
|
12
|
+
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
|
+
|
|
15
|
+
class GPUExternalTexture : public NativeObject<GPUExternalTexture> {
|
|
16
|
+
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUExternalTexture";
|
|
18
|
+
|
|
19
|
+
explicit GPUExternalTexture(wgpu::ExternalTexture instance, std::string label)
|
|
20
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
24
|
+
|
|
25
|
+
std::string getLabel() { return _label; }
|
|
26
|
+
void setLabel(const std::string &label) {
|
|
27
|
+
_label = label;
|
|
28
|
+
_instance.SetLabel(_label.c_str());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
32
|
+
installGetter(runtime, prototype, "__brand", &GPUExternalTexture::getBrand);
|
|
33
|
+
installGetterSetter(runtime, prototype, "label",
|
|
34
|
+
&GPUExternalTexture::getLabel,
|
|
35
|
+
&GPUExternalTexture::setLabel);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
inline const wgpu::ExternalTexture get() { return _instance; }
|
|
39
|
+
|
|
40
|
+
private:
|
|
41
|
+
wgpu::ExternalTexture _instance;
|
|
42
|
+
std::string _label;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include <cstdio>
|
|
6
|
+
|
|
7
|
+
#include "webgpu/webgpu_cpp.h"
|
|
8
|
+
|
|
9
|
+
namespace rnwgpu {
|
|
10
|
+
|
|
11
|
+
static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
|
|
12
|
+
std::string *outUnion) {
|
|
13
|
+
switch (inEnum) {
|
|
14
|
+
case wgpu::FeatureName::DepthClipControl:
|
|
15
|
+
*outUnion = "depth-clip-control";
|
|
16
|
+
break;
|
|
17
|
+
case wgpu::FeatureName::Depth32FloatStencil8:
|
|
18
|
+
*outUnion = "depth32float-stencil8";
|
|
19
|
+
break;
|
|
20
|
+
case wgpu::FeatureName::TimestampQuery:
|
|
21
|
+
*outUnion = "timestamp-query";
|
|
22
|
+
break;
|
|
23
|
+
case wgpu::FeatureName::TextureCompressionBC:
|
|
24
|
+
*outUnion = "texture-compression-bc";
|
|
25
|
+
break;
|
|
26
|
+
case wgpu::FeatureName::TextureCompressionETC2:
|
|
27
|
+
*outUnion = "texture-compression-etc2";
|
|
28
|
+
break;
|
|
29
|
+
case wgpu::FeatureName::TextureCompressionASTC:
|
|
30
|
+
*outUnion = "texture-compression-astc";
|
|
31
|
+
break;
|
|
32
|
+
case wgpu::FeatureName::IndirectFirstInstance:
|
|
33
|
+
*outUnion = "indirect-first-instance";
|
|
34
|
+
break;
|
|
35
|
+
case wgpu::FeatureName::ShaderF16:
|
|
36
|
+
*outUnion = "shader-f16";
|
|
37
|
+
break;
|
|
38
|
+
case wgpu::FeatureName::RG11B10UfloatRenderable:
|
|
39
|
+
*outUnion = "rg11b10ufloat-renderable";
|
|
40
|
+
break;
|
|
41
|
+
case wgpu::FeatureName::BGRA8UnormStorage:
|
|
42
|
+
*outUnion = "bgra8unorm-storage";
|
|
43
|
+
break;
|
|
44
|
+
case wgpu::FeatureName::Float32Filterable:
|
|
45
|
+
*outUnion = "float32-filterable";
|
|
46
|
+
break;
|
|
47
|
+
case wgpu::FeatureName::Subgroups:
|
|
48
|
+
*outUnion = "subgroups";
|
|
49
|
+
break;
|
|
50
|
+
case wgpu::FeatureName::DawnInternalUsages:
|
|
51
|
+
*outUnion = "dawn-internal-usages";
|
|
52
|
+
break;
|
|
53
|
+
case wgpu::FeatureName::DawnMultiPlanarFormats:
|
|
54
|
+
*outUnion = "dawn-multi-planar-formats";
|
|
55
|
+
break;
|
|
56
|
+
case wgpu::FeatureName::DawnNative:
|
|
57
|
+
*outUnion = "dawn-native";
|
|
58
|
+
break;
|
|
59
|
+
case wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses:
|
|
60
|
+
*outUnion = "chromium-experimental-timestamp-query-inside-passes";
|
|
61
|
+
break;
|
|
62
|
+
case wgpu::FeatureName::ImplicitDeviceSynchronization:
|
|
63
|
+
*outUnion = "implicit-device-synchronization";
|
|
64
|
+
break;
|
|
65
|
+
case wgpu::FeatureName::TransientAttachments:
|
|
66
|
+
*outUnion = "transient-attachments";
|
|
67
|
+
break;
|
|
68
|
+
case wgpu::FeatureName::MSAARenderToSingleSampled:
|
|
69
|
+
*outUnion = "msaa-render-to-single-sampled";
|
|
70
|
+
break;
|
|
71
|
+
case wgpu::FeatureName::DualSourceBlending:
|
|
72
|
+
*outUnion = "dual-source-blending";
|
|
73
|
+
break;
|
|
74
|
+
case wgpu::FeatureName::D3D11MultithreadProtected:
|
|
75
|
+
*outUnion = "d3d11-multithread-protected";
|
|
76
|
+
break;
|
|
77
|
+
case wgpu::FeatureName::ANGLETextureSharing:
|
|
78
|
+
*outUnion = "angle-texture-sharing";
|
|
79
|
+
break;
|
|
80
|
+
case wgpu::FeatureName::ChromiumExperimentalSubgroupMatrix:
|
|
81
|
+
*outUnion = "chromium-experimental-subgroups-matrix";
|
|
82
|
+
break;
|
|
83
|
+
case wgpu::FeatureName::PixelLocalStorageCoherent:
|
|
84
|
+
*outUnion = "pixel-local-storage-coherent";
|
|
85
|
+
break;
|
|
86
|
+
case wgpu::FeatureName::PixelLocalStorageNonCoherent:
|
|
87
|
+
*outUnion = "pixel-local-storage-non-coherent";
|
|
88
|
+
break;
|
|
89
|
+
case wgpu::FeatureName::Unorm16TextureFormats:
|
|
90
|
+
*outUnion = "unorm16-texture-formats";
|
|
91
|
+
break;
|
|
92
|
+
case wgpu::FeatureName::Snorm16TextureFormats:
|
|
93
|
+
*outUnion = "snorm16-texture-formats";
|
|
94
|
+
break;
|
|
95
|
+
case wgpu::FeatureName::MultiPlanarFormatExtendedUsages:
|
|
96
|
+
*outUnion = "multi-planar-format-extended-usages";
|
|
97
|
+
break;
|
|
98
|
+
case wgpu::FeatureName::MultiPlanarFormatP010:
|
|
99
|
+
*outUnion = "multi-planar-format-p010";
|
|
100
|
+
break;
|
|
101
|
+
case wgpu::FeatureName::HostMappedPointer:
|
|
102
|
+
*outUnion = "host-mapped-pointer";
|
|
103
|
+
break;
|
|
104
|
+
case wgpu::FeatureName::MultiPlanarRenderTargets:
|
|
105
|
+
*outUnion = "multi-planar-render-targets";
|
|
106
|
+
break;
|
|
107
|
+
case wgpu::FeatureName::MultiPlanarFormatNv12a:
|
|
108
|
+
*outUnion = "multi-planar-format-nv12a";
|
|
109
|
+
break;
|
|
110
|
+
case wgpu::FeatureName::FramebufferFetch:
|
|
111
|
+
*outUnion = "framebuffer-fetch";
|
|
112
|
+
break;
|
|
113
|
+
case wgpu::FeatureName::BufferMapExtendedUsages:
|
|
114
|
+
*outUnion = "buffer-map-extended-usages";
|
|
115
|
+
break;
|
|
116
|
+
case wgpu::FeatureName::AdapterPropertiesMemoryHeaps:
|
|
117
|
+
*outUnion = "adapter-properties-memory-heaps";
|
|
118
|
+
break;
|
|
119
|
+
case wgpu::FeatureName::AdapterPropertiesD3D:
|
|
120
|
+
*outUnion = "adapter-properties-d3d";
|
|
121
|
+
break;
|
|
122
|
+
case wgpu::FeatureName::AdapterPropertiesVk:
|
|
123
|
+
*outUnion = "adapter-properties-vk";
|
|
124
|
+
break;
|
|
125
|
+
case wgpu::FeatureName::R8UnormStorage:
|
|
126
|
+
*outUnion = "r8unorm-storage";
|
|
127
|
+
break;
|
|
128
|
+
case wgpu::FeatureName::DawnFormatCapabilities:
|
|
129
|
+
*outUnion = "format-capabilities";
|
|
130
|
+
break;
|
|
131
|
+
case wgpu::FeatureName::DawnDrmFormatCapabilities:
|
|
132
|
+
*outUnion = "drm-format-capabilities";
|
|
133
|
+
break;
|
|
134
|
+
case wgpu::FeatureName::Norm16TextureFormats:
|
|
135
|
+
*outUnion = "norm16-texture-formats";
|
|
136
|
+
break;
|
|
137
|
+
case wgpu::FeatureName::MultiPlanarFormatNv16:
|
|
138
|
+
*outUnion = "multi-planar-format-nv16";
|
|
139
|
+
break;
|
|
140
|
+
case wgpu::FeatureName::MultiPlanarFormatNv24:
|
|
141
|
+
*outUnion = "multi-planar-format-nv24";
|
|
142
|
+
break;
|
|
143
|
+
case wgpu::FeatureName::MultiPlanarFormatP210:
|
|
144
|
+
*outUnion = "multi-planar-format-p210";
|
|
145
|
+
break;
|
|
146
|
+
case wgpu::FeatureName::MultiPlanarFormatP410:
|
|
147
|
+
*outUnion = "multi-planar-format-p410";
|
|
148
|
+
break;
|
|
149
|
+
case wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation:
|
|
150
|
+
*outUnion = "shared-texture-memory-vk-dedicated-allocation";
|
|
151
|
+
break;
|
|
152
|
+
case wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer:
|
|
153
|
+
*outUnion = "shared-texture-memory-ahardware-buffer";
|
|
154
|
+
break;
|
|
155
|
+
case wgpu::FeatureName::SharedTextureMemoryDmaBuf:
|
|
156
|
+
*outUnion = "shared-texture-memory-dma-buf";
|
|
157
|
+
break;
|
|
158
|
+
case wgpu::FeatureName::SharedTextureMemoryOpaqueFD:
|
|
159
|
+
*outUnion = "shared-texture-memory-opaque-fd";
|
|
160
|
+
break;
|
|
161
|
+
case wgpu::FeatureName::SharedTextureMemoryZirconHandle:
|
|
162
|
+
*outUnion = "shared-texture-memory-zircon-handle";
|
|
163
|
+
break;
|
|
164
|
+
case wgpu::FeatureName::SharedTextureMemoryDXGISharedHandle:
|
|
165
|
+
*outUnion = "shared-texture-memory-dxgi-shared-handle";
|
|
166
|
+
break;
|
|
167
|
+
case wgpu::FeatureName::SharedTextureMemoryD3D11Texture2D:
|
|
168
|
+
*outUnion = "shared-texture-memory-d3d11-texture2d";
|
|
169
|
+
break;
|
|
170
|
+
case wgpu::FeatureName::SharedTextureMemoryIOSurface:
|
|
171
|
+
*outUnion = "shared-texture-memory-iosurface";
|
|
172
|
+
break;
|
|
173
|
+
case wgpu::FeatureName::SharedTextureMemoryEGLImage:
|
|
174
|
+
*outUnion = "shared-texture-memory-egl-image";
|
|
175
|
+
break;
|
|
176
|
+
case wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD:
|
|
177
|
+
*outUnion = "shared-fence-vk-semaphore-opaque-fd";
|
|
178
|
+
break;
|
|
179
|
+
case wgpu::FeatureName::SharedFenceSyncFD:
|
|
180
|
+
*outUnion = "shared-fence-vk-semaphore-sync-fd";
|
|
181
|
+
break;
|
|
182
|
+
case wgpu::FeatureName::SharedFenceVkSemaphoreZirconHandle:
|
|
183
|
+
*outUnion = "shared-fence-vk-semaphore-zircon-handle";
|
|
184
|
+
break;
|
|
185
|
+
case wgpu::FeatureName::SharedFenceDXGISharedHandle:
|
|
186
|
+
*outUnion = "shared-fence-dxgi-shared-handle";
|
|
187
|
+
break;
|
|
188
|
+
case wgpu::FeatureName::SharedFenceMTLSharedEvent:
|
|
189
|
+
*outUnion = "shared-fence-mtl-shared-event";
|
|
190
|
+
break;
|
|
191
|
+
case wgpu::FeatureName::SharedBufferMemoryD3D12Resource:
|
|
192
|
+
*outUnion = "shared-buffer-memory-d3d12-resource";
|
|
193
|
+
break;
|
|
194
|
+
case wgpu::FeatureName::StaticSamplers:
|
|
195
|
+
*outUnion = "static-samplers";
|
|
196
|
+
break;
|
|
197
|
+
case wgpu::FeatureName::YCbCrVulkanSamplers:
|
|
198
|
+
*outUnion = "ycbcr-vulkan-samplers";
|
|
199
|
+
break;
|
|
200
|
+
case wgpu::FeatureName::ShaderModuleCompilationOptions:
|
|
201
|
+
*outUnion = "shader-module-compilation-options";
|
|
202
|
+
break;
|
|
203
|
+
case wgpu::FeatureName::DawnLoadResolveTexture:
|
|
204
|
+
*outUnion = "dawn-load-resolve-texture";
|
|
205
|
+
break;
|
|
206
|
+
default:
|
|
207
|
+
fprintf(stderr, "Unknown feature name %d\n", static_cast<int>(inEnum));
|
|
208
|
+
*outUnion = "";
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include "jsi2/NativeObject.h"
|
|
6
|
+
|
|
7
|
+
namespace rnwgpu {
|
|
8
|
+
|
|
9
|
+
namespace jsi = facebook::jsi;
|
|
10
|
+
|
|
11
|
+
class GPUInternalError : public NativeObject<GPUInternalError> {
|
|
12
|
+
public:
|
|
13
|
+
static constexpr const char *CLASS_NAME = "GPUInternalError";
|
|
14
|
+
|
|
15
|
+
explicit GPUInternalError(std::string message)
|
|
16
|
+
: NativeObject(CLASS_NAME), _message(std::move(message)) {}
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
20
|
+
std::string getMessage() { return _message; }
|
|
21
|
+
|
|
22
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
23
|
+
installGetter(runtime, prototype, "__brand", &GPUInternalError::getBrand);
|
|
24
|
+
installGetter(runtime, prototype, "message", &GPUInternalError::getMessage);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private:
|
|
28
|
+
std::string _message;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "jsi2/JSIConverter.h"
|
|
6
|
+
|
|
7
|
+
#include "webgpu/webgpu_cpp.h"
|
|
8
|
+
|
|
9
|
+
namespace rnwgpu {
|
|
10
|
+
|
|
11
|
+
struct GPUOrigin2D {
|
|
12
|
+
double x = 0;
|
|
13
|
+
double y = 0;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
template <> struct JSIConverter<std::shared_ptr<GPUOrigin2D>> {
|
|
17
|
+
static std::shared_ptr<GPUOrigin2D>
|
|
18
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
19
|
+
auto result = std::make_unique<GPUOrigin2D>();
|
|
20
|
+
if (!outOfBounds && arg.isObject()) {
|
|
21
|
+
if (arg.getObject(runtime).isArray(runtime)) {
|
|
22
|
+
auto array = arg.getObject(runtime).asArray(runtime);
|
|
23
|
+
auto size = array.size(runtime);
|
|
24
|
+
if (size == 0) {
|
|
25
|
+
throw std::runtime_error(
|
|
26
|
+
"Expected an array of size >1 for GPUTExtent2D");
|
|
27
|
+
}
|
|
28
|
+
if (size > 0) {
|
|
29
|
+
result->x = array.getValueAtIndex(runtime, 0).asNumber();
|
|
30
|
+
}
|
|
31
|
+
if (size > 1) {
|
|
32
|
+
result->y = array.getValueAtIndex(runtime, 1).asNumber();
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
auto object = arg.getObject(runtime);
|
|
36
|
+
if (object.hasProperty(runtime, "x")) {
|
|
37
|
+
result->x = object.getProperty(runtime, "x").asNumber();
|
|
38
|
+
}
|
|
39
|
+
if (object.hasProperty(runtime, "y")) {
|
|
40
|
+
result->y = object.getProperty(runtime, "y").asNumber();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
throw std::runtime_error("Expected an object for GPUOrigin3D");
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
49
|
+
std::shared_ptr<GPUOrigin2D> arg) {
|
|
50
|
+
// No conversions here
|
|
51
|
+
return jsi::Value::null();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace rnwgpu
|