@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,129 @@
|
|
|
1
|
+
#include "GPUSupportedLimits.h"
|
|
2
|
+
|
|
3
|
+
namespace rnwgpu {
|
|
4
|
+
|
|
5
|
+
double GPUSupportedLimits::getMaxTextureDimension1D() {
|
|
6
|
+
return _instance.maxTextureDimension1D;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
double GPUSupportedLimits::getMaxTextureDimension2D() {
|
|
10
|
+
return _instance.maxTextureDimension2D;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
double GPUSupportedLimits::getMaxTextureDimension3D() {
|
|
14
|
+
return _instance.maxTextureDimension3D;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
double GPUSupportedLimits::getMaxTextureArrayLayers() {
|
|
18
|
+
return _instance.maxTextureArrayLayers;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
double GPUSupportedLimits::getMaxBindGroups() {
|
|
22
|
+
return _instance.maxBindGroups;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
double GPUSupportedLimits::getMaxBindGroupsPlusVertexBuffers() {
|
|
26
|
+
return _instance.maxBindGroupsPlusVertexBuffers;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
double GPUSupportedLimits::getMaxBindingsPerBindGroup() {
|
|
30
|
+
return _instance.maxBindingsPerBindGroup;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
double GPUSupportedLimits::getMaxDynamicUniformBuffersPerPipelineLayout() {
|
|
34
|
+
return _instance.maxDynamicUniformBuffersPerPipelineLayout;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
double GPUSupportedLimits::getMaxDynamicStorageBuffersPerPipelineLayout() {
|
|
38
|
+
return _instance.maxDynamicStorageBuffersPerPipelineLayout;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
double GPUSupportedLimits::getMaxSampledTexturesPerShaderStage() {
|
|
42
|
+
return _instance.maxSampledTexturesPerShaderStage;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
double GPUSupportedLimits::getMaxSamplersPerShaderStage() {
|
|
46
|
+
return _instance.maxSamplersPerShaderStage;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
double GPUSupportedLimits::getMaxStorageBuffersPerShaderStage() {
|
|
50
|
+
return _instance.maxStorageBuffersPerShaderStage;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
double GPUSupportedLimits::getMaxStorageTexturesPerShaderStage() {
|
|
54
|
+
return _instance.maxStorageTexturesPerShaderStage;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
double GPUSupportedLimits::getMaxUniformBuffersPerShaderStage() {
|
|
58
|
+
return _instance.maxUniformBuffersPerShaderStage;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
double GPUSupportedLimits::getMaxUniformBufferBindingSize() {
|
|
62
|
+
return _instance.maxUniformBufferBindingSize;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
double GPUSupportedLimits::getMaxStorageBufferBindingSize() {
|
|
66
|
+
return _instance.maxStorageBufferBindingSize;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
double GPUSupportedLimits::getMinUniformBufferOffsetAlignment() {
|
|
70
|
+
return _instance.minUniformBufferOffsetAlignment;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
double GPUSupportedLimits::getMinStorageBufferOffsetAlignment() {
|
|
74
|
+
return _instance.minStorageBufferOffsetAlignment;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
double GPUSupportedLimits::getMaxVertexBuffers() {
|
|
78
|
+
return _instance.maxVertexBuffers;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
double GPUSupportedLimits::getMaxBufferSize() {
|
|
82
|
+
return _instance.maxBufferSize;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
double GPUSupportedLimits::getMaxVertexAttributes() {
|
|
86
|
+
return _instance.maxVertexAttributes;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
double GPUSupportedLimits::getMaxVertexBufferArrayStride() {
|
|
90
|
+
return _instance.maxVertexBufferArrayStride;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
double GPUSupportedLimits::getMaxInterStageShaderVariables() {
|
|
94
|
+
return _instance.maxInterStageShaderVariables;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
double GPUSupportedLimits::getMaxColorAttachments() {
|
|
98
|
+
return _instance.maxColorAttachments;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
double GPUSupportedLimits::getMaxColorAttachmentBytesPerSample() {
|
|
102
|
+
return _instance.maxColorAttachmentBytesPerSample;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
double GPUSupportedLimits::getMaxComputeWorkgroupStorageSize() {
|
|
106
|
+
return _instance.maxComputeWorkgroupStorageSize;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
double GPUSupportedLimits::getMaxComputeInvocationsPerWorkgroup() {
|
|
110
|
+
return _instance.maxComputeInvocationsPerWorkgroup;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
double GPUSupportedLimits::getMaxComputeWorkgroupSizeX() {
|
|
114
|
+
return _instance.maxComputeWorkgroupSizeX;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
double GPUSupportedLimits::getMaxComputeWorkgroupSizeY() {
|
|
118
|
+
return _instance.maxComputeWorkgroupSizeY;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
double GPUSupportedLimits::getMaxComputeWorkgroupSizeZ() {
|
|
122
|
+
return _instance.maxComputeWorkgroupSizeZ;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
double GPUSupportedLimits::getMaxComputeWorkgroupsPerDimension() {
|
|
126
|
+
return _instance.maxComputeWorkgroupsPerDimension;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,131 @@
|
|
|
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 GPUSupportedLimits : public NativeObject<GPUSupportedLimits> {
|
|
16
|
+
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUSupportedLimits";
|
|
18
|
+
|
|
19
|
+
explicit GPUSupportedLimits(wgpu::Limits instance)
|
|
20
|
+
: NativeObject(CLASS_NAME), _instance(instance) {}
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
24
|
+
|
|
25
|
+
double getMaxTextureDimension1D();
|
|
26
|
+
double getMaxTextureDimension2D();
|
|
27
|
+
double getMaxTextureDimension3D();
|
|
28
|
+
double getMaxTextureArrayLayers();
|
|
29
|
+
double getMaxBindGroups();
|
|
30
|
+
double getMaxBindGroupsPlusVertexBuffers();
|
|
31
|
+
double getMaxBindingsPerBindGroup();
|
|
32
|
+
double getMaxDynamicUniformBuffersPerPipelineLayout();
|
|
33
|
+
double getMaxDynamicStorageBuffersPerPipelineLayout();
|
|
34
|
+
double getMaxSampledTexturesPerShaderStage();
|
|
35
|
+
double getMaxSamplersPerShaderStage();
|
|
36
|
+
double getMaxStorageBuffersPerShaderStage();
|
|
37
|
+
double getMaxStorageTexturesPerShaderStage();
|
|
38
|
+
double getMaxUniformBuffersPerShaderStage();
|
|
39
|
+
double getMaxUniformBufferBindingSize();
|
|
40
|
+
double getMaxStorageBufferBindingSize();
|
|
41
|
+
double getMinUniformBufferOffsetAlignment();
|
|
42
|
+
double getMinStorageBufferOffsetAlignment();
|
|
43
|
+
double getMaxVertexBuffers();
|
|
44
|
+
double getMaxBufferSize();
|
|
45
|
+
double getMaxVertexAttributes();
|
|
46
|
+
double getMaxVertexBufferArrayStride();
|
|
47
|
+
double getMaxInterStageShaderVariables();
|
|
48
|
+
double getMaxColorAttachments();
|
|
49
|
+
double getMaxColorAttachmentBytesPerSample();
|
|
50
|
+
double getMaxComputeWorkgroupStorageSize();
|
|
51
|
+
double getMaxComputeInvocationsPerWorkgroup();
|
|
52
|
+
double getMaxComputeWorkgroupSizeX();
|
|
53
|
+
double getMaxComputeWorkgroupSizeY();
|
|
54
|
+
double getMaxComputeWorkgroupSizeZ();
|
|
55
|
+
double getMaxComputeWorkgroupsPerDimension();
|
|
56
|
+
|
|
57
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
58
|
+
installGetter(runtime, prototype, "__brand", &GPUSupportedLimits::getBrand);
|
|
59
|
+
installGetter(runtime, prototype, "maxTextureDimension1D",
|
|
60
|
+
&GPUSupportedLimits::getMaxTextureDimension1D);
|
|
61
|
+
installGetter(runtime, prototype, "maxTextureDimension2D",
|
|
62
|
+
&GPUSupportedLimits::getMaxTextureDimension2D);
|
|
63
|
+
installGetter(runtime, prototype, "maxTextureDimension3D",
|
|
64
|
+
&GPUSupportedLimits::getMaxTextureDimension3D);
|
|
65
|
+
installGetter(runtime, prototype, "maxTextureArrayLayers",
|
|
66
|
+
&GPUSupportedLimits::getMaxTextureArrayLayers);
|
|
67
|
+
installGetter(runtime, prototype, "maxBindGroups",
|
|
68
|
+
&GPUSupportedLimits::getMaxBindGroups);
|
|
69
|
+
installGetter(runtime, prototype, "maxBindGroupsPlusVertexBuffers",
|
|
70
|
+
&GPUSupportedLimits::getMaxBindGroupsPlusVertexBuffers);
|
|
71
|
+
installGetter(runtime, prototype, "maxBindingsPerBindGroup",
|
|
72
|
+
&GPUSupportedLimits::getMaxBindingsPerBindGroup);
|
|
73
|
+
installGetter(
|
|
74
|
+
runtime, prototype, "maxDynamicUniformBuffersPerPipelineLayout",
|
|
75
|
+
&GPUSupportedLimits::getMaxDynamicUniformBuffersPerPipelineLayout);
|
|
76
|
+
installGetter(
|
|
77
|
+
runtime, prototype, "maxDynamicStorageBuffersPerPipelineLayout",
|
|
78
|
+
&GPUSupportedLimits::getMaxDynamicStorageBuffersPerPipelineLayout);
|
|
79
|
+
installGetter(runtime, prototype, "maxSampledTexturesPerShaderStage",
|
|
80
|
+
&GPUSupportedLimits::getMaxSampledTexturesPerShaderStage);
|
|
81
|
+
installGetter(runtime, prototype, "maxSamplersPerShaderStage",
|
|
82
|
+
&GPUSupportedLimits::getMaxSamplersPerShaderStage);
|
|
83
|
+
installGetter(runtime, prototype, "maxStorageBuffersPerShaderStage",
|
|
84
|
+
&GPUSupportedLimits::getMaxStorageBuffersPerShaderStage);
|
|
85
|
+
installGetter(runtime, prototype, "maxStorageTexturesPerShaderStage",
|
|
86
|
+
&GPUSupportedLimits::getMaxStorageTexturesPerShaderStage);
|
|
87
|
+
installGetter(runtime, prototype, "maxUniformBuffersPerShaderStage",
|
|
88
|
+
&GPUSupportedLimits::getMaxUniformBuffersPerShaderStage);
|
|
89
|
+
installGetter(runtime, prototype, "maxUniformBufferBindingSize",
|
|
90
|
+
&GPUSupportedLimits::getMaxUniformBufferBindingSize);
|
|
91
|
+
installGetter(runtime, prototype, "maxStorageBufferBindingSize",
|
|
92
|
+
&GPUSupportedLimits::getMaxStorageBufferBindingSize);
|
|
93
|
+
installGetter(runtime, prototype, "minUniformBufferOffsetAlignment",
|
|
94
|
+
&GPUSupportedLimits::getMinUniformBufferOffsetAlignment);
|
|
95
|
+
installGetter(runtime, prototype, "minStorageBufferOffsetAlignment",
|
|
96
|
+
&GPUSupportedLimits::getMinStorageBufferOffsetAlignment);
|
|
97
|
+
installGetter(runtime, prototype, "maxVertexBuffers",
|
|
98
|
+
&GPUSupportedLimits::getMaxVertexBuffers);
|
|
99
|
+
installGetter(runtime, prototype, "maxBufferSize",
|
|
100
|
+
&GPUSupportedLimits::getMaxBufferSize);
|
|
101
|
+
installGetter(runtime, prototype, "maxVertexAttributes",
|
|
102
|
+
&GPUSupportedLimits::getMaxVertexAttributes);
|
|
103
|
+
installGetter(runtime, prototype, "maxVertexBufferArrayStride",
|
|
104
|
+
&GPUSupportedLimits::getMaxVertexBufferArrayStride);
|
|
105
|
+
installGetter(runtime, prototype, "maxInterStageShaderVariables",
|
|
106
|
+
&GPUSupportedLimits::getMaxInterStageShaderVariables);
|
|
107
|
+
installGetter(runtime, prototype, "maxColorAttachments",
|
|
108
|
+
&GPUSupportedLimits::getMaxColorAttachments);
|
|
109
|
+
installGetter(runtime, prototype, "maxColorAttachmentBytesPerSample",
|
|
110
|
+
&GPUSupportedLimits::getMaxColorAttachmentBytesPerSample);
|
|
111
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupStorageSize",
|
|
112
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupStorageSize);
|
|
113
|
+
installGetter(runtime, prototype, "maxComputeInvocationsPerWorkgroup",
|
|
114
|
+
&GPUSupportedLimits::getMaxComputeInvocationsPerWorkgroup);
|
|
115
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupSizeX",
|
|
116
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupSizeX);
|
|
117
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupSizeY",
|
|
118
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupSizeY);
|
|
119
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupSizeZ",
|
|
120
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupSizeZ);
|
|
121
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupsPerDimension",
|
|
122
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupsPerDimension);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
inline const wgpu::Limits get() { return _instance; }
|
|
126
|
+
|
|
127
|
+
private:
|
|
128
|
+
wgpu::Limits _instance;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#include "GPUTexture.h"
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "Convertors.h"
|
|
6
|
+
|
|
7
|
+
namespace rnwgpu {
|
|
8
|
+
|
|
9
|
+
void GPUTexture::destroy() { _instance.Destroy(); }
|
|
10
|
+
|
|
11
|
+
std::shared_ptr<GPUTextureView> GPUTexture::createView(
|
|
12
|
+
std::optional<std::shared_ptr<GPUTextureViewDescriptor>> descriptor) {
|
|
13
|
+
wgpu::TextureViewDescriptor desc;
|
|
14
|
+
Convertor conv;
|
|
15
|
+
if (!conv(desc, descriptor)) {
|
|
16
|
+
throw std::runtime_error("GPUTextureView.createView(): couldn't access "
|
|
17
|
+
"GPUTextureViewDescriptor");
|
|
18
|
+
}
|
|
19
|
+
auto view = _instance.CreateView(&desc);
|
|
20
|
+
return std::make_shared<GPUTextureView>(
|
|
21
|
+
view,
|
|
22
|
+
descriptor.has_value() ? descriptor.value()->label.value_or("") : "");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
uint32_t GPUTexture::getWidth() { return _instance.GetWidth(); }
|
|
26
|
+
|
|
27
|
+
uint32_t GPUTexture::getHeight() { return _instance.GetHeight(); }
|
|
28
|
+
|
|
29
|
+
uint32_t GPUTexture::getDepthOrArrayLayers() {
|
|
30
|
+
return _instance.GetDepthOrArrayLayers();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
uint32_t GPUTexture::getMipLevelCount() { return _instance.GetMipLevelCount(); }
|
|
34
|
+
|
|
35
|
+
uint32_t GPUTexture::getSampleCount() { return _instance.GetSampleCount(); }
|
|
36
|
+
|
|
37
|
+
wgpu::TextureDimension GPUTexture::getDimension() {
|
|
38
|
+
return _instance.GetDimension();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
wgpu::TextureFormat GPUTexture::getFormat() { return _instance.GetFormat(); }
|
|
42
|
+
|
|
43
|
+
double GPUTexture::getUsage() {
|
|
44
|
+
return static_cast<double>(_instance.GetUsage());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "descriptors/Unions.h"
|
|
8
|
+
|
|
9
|
+
#include "jsi2/NativeObject.h"
|
|
10
|
+
|
|
11
|
+
#include "webgpu/webgpu_cpp.h"
|
|
12
|
+
|
|
13
|
+
#include "GPUTextureView.h"
|
|
14
|
+
#include "descriptors/GPUTextureViewDescriptor.h"
|
|
15
|
+
|
|
16
|
+
namespace rnwgpu {
|
|
17
|
+
|
|
18
|
+
namespace jsi = facebook::jsi;
|
|
19
|
+
|
|
20
|
+
class GPUTexture : public NativeObject<GPUTexture> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr const char *CLASS_NAME = "GPUTexture";
|
|
23
|
+
|
|
24
|
+
explicit GPUTexture(wgpu::Texture instance, std::string label)
|
|
25
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
29
|
+
|
|
30
|
+
std::shared_ptr<GPUTextureView> createView(
|
|
31
|
+
std::optional<std::shared_ptr<GPUTextureViewDescriptor>> descriptor);
|
|
32
|
+
void destroy();
|
|
33
|
+
|
|
34
|
+
uint32_t getWidth();
|
|
35
|
+
uint32_t getHeight();
|
|
36
|
+
uint32_t getDepthOrArrayLayers();
|
|
37
|
+
uint32_t getMipLevelCount();
|
|
38
|
+
uint32_t getSampleCount();
|
|
39
|
+
wgpu::TextureDimension getDimension();
|
|
40
|
+
wgpu::TextureFormat getFormat();
|
|
41
|
+
double getUsage();
|
|
42
|
+
|
|
43
|
+
std::string getLabel() { return _label; }
|
|
44
|
+
void setLabel(const std::string &label) {
|
|
45
|
+
_label = label;
|
|
46
|
+
_instance.SetLabel(_label.c_str());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
50
|
+
installGetter(runtime, prototype, "__brand", &GPUTexture::getBrand);
|
|
51
|
+
installMethod(runtime, prototype, "createView", &GPUTexture::createView);
|
|
52
|
+
installMethod(runtime, prototype, "destroy", &GPUTexture::destroy);
|
|
53
|
+
installGetter(runtime, prototype, "width", &GPUTexture::getWidth);
|
|
54
|
+
installGetter(runtime, prototype, "height", &GPUTexture::getHeight);
|
|
55
|
+
installGetter(runtime, prototype, "depthOrArrayLayers",
|
|
56
|
+
&GPUTexture::getDepthOrArrayLayers);
|
|
57
|
+
installGetter(runtime, prototype, "mipLevelCount",
|
|
58
|
+
&GPUTexture::getMipLevelCount);
|
|
59
|
+
installGetter(runtime, prototype, "sampleCount",
|
|
60
|
+
&GPUTexture::getSampleCount);
|
|
61
|
+
installGetter(runtime, prototype, "dimension", &GPUTexture::getDimension);
|
|
62
|
+
installGetter(runtime, prototype, "format", &GPUTexture::getFormat);
|
|
63
|
+
installGetter(runtime, prototype, "usage", &GPUTexture::getUsage);
|
|
64
|
+
installGetterSetter(runtime, prototype, "label", &GPUTexture::getLabel,
|
|
65
|
+
&GPUTexture::setLabel);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
inline const wgpu::Texture get() { return _instance; }
|
|
69
|
+
|
|
70
|
+
size_t getMemoryPressure() override {
|
|
71
|
+
// Calculate approximate memory usage based on texture properties
|
|
72
|
+
uint32_t width = getWidth();
|
|
73
|
+
uint32_t height = getHeight();
|
|
74
|
+
uint32_t depthOrArrayLayers = getDepthOrArrayLayers();
|
|
75
|
+
uint32_t mipLevelCount = getMipLevelCount();
|
|
76
|
+
uint32_t sampleCount = getSampleCount();
|
|
77
|
+
|
|
78
|
+
// Estimate bytes per pixel based on format
|
|
79
|
+
// This is a simplified estimate - actual values depend on the specific
|
|
80
|
+
// format
|
|
81
|
+
size_t bytesPerPixel = 4; // Default to RGBA8 format
|
|
82
|
+
wgpu::TextureFormat format = getFormat();
|
|
83
|
+
switch (format) {
|
|
84
|
+
case wgpu::TextureFormat::R8Unorm:
|
|
85
|
+
case wgpu::TextureFormat::R8Snorm:
|
|
86
|
+
case wgpu::TextureFormat::R8Uint:
|
|
87
|
+
case wgpu::TextureFormat::R8Sint:
|
|
88
|
+
bytesPerPixel = 1;
|
|
89
|
+
break;
|
|
90
|
+
case wgpu::TextureFormat::R16Uint:
|
|
91
|
+
case wgpu::TextureFormat::R16Sint:
|
|
92
|
+
case wgpu::TextureFormat::R16Float:
|
|
93
|
+
case wgpu::TextureFormat::RG8Unorm:
|
|
94
|
+
case wgpu::TextureFormat::RG8Snorm:
|
|
95
|
+
case wgpu::TextureFormat::RG8Uint:
|
|
96
|
+
case wgpu::TextureFormat::RG8Sint:
|
|
97
|
+
bytesPerPixel = 2;
|
|
98
|
+
break;
|
|
99
|
+
case wgpu::TextureFormat::RGBA8Unorm:
|
|
100
|
+
case wgpu::TextureFormat::RGBA8UnormSrgb:
|
|
101
|
+
case wgpu::TextureFormat::RGBA8Snorm:
|
|
102
|
+
case wgpu::TextureFormat::RGBA8Uint:
|
|
103
|
+
case wgpu::TextureFormat::RGBA8Sint:
|
|
104
|
+
case wgpu::TextureFormat::BGRA8Unorm:
|
|
105
|
+
case wgpu::TextureFormat::BGRA8UnormSrgb:
|
|
106
|
+
case wgpu::TextureFormat::RGB10A2Unorm:
|
|
107
|
+
case wgpu::TextureFormat::R32Float:
|
|
108
|
+
case wgpu::TextureFormat::R32Uint:
|
|
109
|
+
case wgpu::TextureFormat::R32Sint:
|
|
110
|
+
case wgpu::TextureFormat::RG16Uint:
|
|
111
|
+
case wgpu::TextureFormat::RG16Sint:
|
|
112
|
+
case wgpu::TextureFormat::RG16Float:
|
|
113
|
+
bytesPerPixel = 4;
|
|
114
|
+
break;
|
|
115
|
+
case wgpu::TextureFormat::RG32Float:
|
|
116
|
+
case wgpu::TextureFormat::RG32Uint:
|
|
117
|
+
case wgpu::TextureFormat::RG32Sint:
|
|
118
|
+
case wgpu::TextureFormat::RGBA16Uint:
|
|
119
|
+
case wgpu::TextureFormat::RGBA16Sint:
|
|
120
|
+
case wgpu::TextureFormat::RGBA16Float:
|
|
121
|
+
bytesPerPixel = 8;
|
|
122
|
+
break;
|
|
123
|
+
case wgpu::TextureFormat::RGBA32Float:
|
|
124
|
+
case wgpu::TextureFormat::RGBA32Uint:
|
|
125
|
+
case wgpu::TextureFormat::RGBA32Sint:
|
|
126
|
+
bytesPerPixel = 16;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
bytesPerPixel = 4; // Safe default
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Calculate total memory for all mip levels
|
|
134
|
+
size_t totalMemory = 0;
|
|
135
|
+
for (uint32_t mip = 0; mip < mipLevelCount; ++mip) {
|
|
136
|
+
uint32_t mipWidth = std::max(1u, width >> mip);
|
|
137
|
+
uint32_t mipHeight = std::max(1u, height >> mip);
|
|
138
|
+
totalMemory += static_cast<size_t>(mipWidth) * mipHeight *
|
|
139
|
+
depthOrArrayLayers * bytesPerPixel * sampleCount;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return totalMemory;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private:
|
|
146
|
+
wgpu::Texture _instance;
|
|
147
|
+
std::string _label;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,44 @@
|
|
|
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 GPUTextureView : public NativeObject<GPUTextureView> {
|
|
16
|
+
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUTextureView";
|
|
18
|
+
|
|
19
|
+
explicit GPUTextureView(wgpu::TextureView 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", &GPUTextureView::getBrand);
|
|
33
|
+
installGetterSetter(runtime, prototype, "label", &GPUTextureView::getLabel,
|
|
34
|
+
&GPUTextureView::setLabel);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
inline const wgpu::TextureView get() { return _instance; }
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
wgpu::TextureView _instance;
|
|
41
|
+
std::string _label;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,32 @@
|
|
|
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 GPUValidationError : public NativeObject<GPUValidationError> {
|
|
12
|
+
public:
|
|
13
|
+
static constexpr const char *CLASS_NAME = "GPUValidationError";
|
|
14
|
+
|
|
15
|
+
explicit GPUValidationError(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", &GPUValidationError::getBrand);
|
|
24
|
+
installGetter(runtime, prototype, "message",
|
|
25
|
+
&GPUValidationError::getMessage);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
std::string _message;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
#include "webgpu/webgpu_cpp.h"
|
|
8
|
+
|
|
9
|
+
#include "jsi2/JSIConverter.h"
|
|
10
|
+
|
|
11
|
+
#include "GPUBindGroupEntry.h"
|
|
12
|
+
#include "rnwgpu/api/GPUBindGroupLayout.h"
|
|
13
|
+
|
|
14
|
+
namespace jsi = facebook::jsi;
|
|
15
|
+
|
|
16
|
+
namespace rnwgpu {
|
|
17
|
+
|
|
18
|
+
struct GPUBindGroupDescriptor {
|
|
19
|
+
std::shared_ptr<GPUBindGroupLayout> layout; // GPUBindGroupLayout
|
|
20
|
+
std::vector<std::shared_ptr<GPUBindGroupEntry>>
|
|
21
|
+
entries; // Iterable<GPUBindGroupEntry>
|
|
22
|
+
std::optional<std::string> label; // string
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace rnwgpu
|
|
26
|
+
|
|
27
|
+
namespace rnwgpu {
|
|
28
|
+
|
|
29
|
+
template <>
|
|
30
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>> {
|
|
31
|
+
static std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>
|
|
32
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
33
|
+
auto result = std::make_unique<rnwgpu::GPUBindGroupDescriptor>();
|
|
34
|
+
if (!outOfBounds && arg.isObject()) {
|
|
35
|
+
auto value = arg.getObject(runtime);
|
|
36
|
+
if (value.hasProperty(runtime, "layout")) {
|
|
37
|
+
auto prop = value.getProperty(runtime, "layout");
|
|
38
|
+
result->layout =
|
|
39
|
+
JSIConverter<std::shared_ptr<GPUBindGroupLayout>>::fromJSI(
|
|
40
|
+
runtime, prop, false);
|
|
41
|
+
}
|
|
42
|
+
if (value.hasProperty(runtime, "entries")) {
|
|
43
|
+
auto prop = value.getProperty(runtime, "entries");
|
|
44
|
+
result->entries = JSIConverter<
|
|
45
|
+
std::vector<std::shared_ptr<GPUBindGroupEntry>>>::fromJSI(runtime,
|
|
46
|
+
prop,
|
|
47
|
+
false);
|
|
48
|
+
}
|
|
49
|
+
if (value.hasProperty(runtime, "label")) {
|
|
50
|
+
auto prop = value.getProperty(runtime, "label");
|
|
51
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
52
|
+
runtime, prop, false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
59
|
+
std::shared_ptr<rnwgpu::GPUBindGroupDescriptor> arg) {
|
|
60
|
+
throw std::runtime_error("Invalid GPUBindGroupDescriptor::toJSI()");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <variant>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "GPUBufferBinding.h"
|
|
9
|
+
#include "rnwgpu/api/GPUExternalTexture.h"
|
|
10
|
+
#include "rnwgpu/api/GPUSampler.h"
|
|
11
|
+
#include "rnwgpu/api/GPUTextureView.h"
|
|
12
|
+
#include "jsi2/JSIConverter.h"
|
|
13
|
+
|
|
14
|
+
namespace jsi = facebook::jsi;
|
|
15
|
+
|
|
16
|
+
namespace rnwgpu {
|
|
17
|
+
|
|
18
|
+
struct GPUBindGroupEntry {
|
|
19
|
+
double binding;
|
|
20
|
+
std::shared_ptr<GPUSampler> sampler = nullptr;
|
|
21
|
+
std::shared_ptr<GPUTextureView> textureView = nullptr;
|
|
22
|
+
std::shared_ptr<GPUBufferBinding> buffer = nullptr;
|
|
23
|
+
// external textures
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} // namespace rnwgpu
|
|
27
|
+
|
|
28
|
+
namespace rnwgpu {
|
|
29
|
+
|
|
30
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
|
|
31
|
+
static std::shared_ptr<rnwgpu::GPUBindGroupEntry>
|
|
32
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
33
|
+
auto result = std::make_unique<rnwgpu::GPUBindGroupEntry>();
|
|
34
|
+
if (!outOfBounds && arg.isObject()) {
|
|
35
|
+
auto value = arg.getObject(runtime);
|
|
36
|
+
if (value.hasProperty(runtime, "binding")) {
|
|
37
|
+
result->binding = value.getProperty(runtime, "binding").asNumber();
|
|
38
|
+
}
|
|
39
|
+
if (value.hasProperty(runtime, "resource")) {
|
|
40
|
+
auto prop = value.getProperty(runtime, "resource");
|
|
41
|
+
if (prop.isObject()) {
|
|
42
|
+
auto obj = prop.getObject(runtime);
|
|
43
|
+
if (obj.hasNativeState<rnwgpu::GPUSampler>(runtime)) {
|
|
44
|
+
result->sampler = obj.getNativeState<rnwgpu::GPUSampler>(runtime);
|
|
45
|
+
} else if (obj.hasNativeState<rnwgpu::GPUTextureView>(runtime)) {
|
|
46
|
+
result->textureView =
|
|
47
|
+
obj.getNativeState<rnwgpu::GPUTextureView>(runtime);
|
|
48
|
+
} else {
|
|
49
|
+
result->buffer = JSIConverter<
|
|
50
|
+
std::shared_ptr<rnwgpu::GPUBufferBinding>>::fromJSI(runtime,
|
|
51
|
+
prop,
|
|
52
|
+
false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// result->resource = JSIConverter<std::variant<
|
|
56
|
+
// std::shared_ptr<GPUSampler>, std::shared_ptr<GPUTextureView>,
|
|
57
|
+
// std::shared_ptr<GPUBufferBinding>,
|
|
58
|
+
// std::shared_ptr<GPUExternalTexture>>>::fromJSI(runtime, prop,
|
|
59
|
+
// false);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
66
|
+
std::shared_ptr<rnwgpu::GPUBindGroupEntry> arg) {
|
|
67
|
+
throw std::runtime_error("Invalid GPUBindGroupEntry::toJSI()");
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace rnwgpu
|