react-native-wgpu 0.1.0

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.
Files changed (208) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +31 -0
  3. package/android/CMakeLists.txt +74 -0
  4. package/android/build.gradle +166 -0
  5. package/android/cpp/cpp-adapter.cpp +12 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +3 -0
  8. package/android/src/main/AndroidManifestNew.xml +2 -0
  9. package/android/src/main/java/com/webgpu/WebGPUModule.java +39 -0
  10. package/android/src/main/java/com/webgpu/WebGPUView.java +24 -0
  11. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +31 -0
  12. package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +26 -0
  13. package/android/src/newarch/WgpuViewManagerSpec.java +24 -0
  14. package/android/src/oldarch/WebGPUViewManagerSpec.java +11 -0
  15. package/cpp/Logger.h +82 -0
  16. package/cpp/dawn/dawn_proc_table.h +308 -0
  17. package/cpp/dawn/webgpu.h +4201 -0
  18. package/cpp/dawn/webgpu_cpp.h +8985 -0
  19. package/cpp/dawn/webgpu_cpp_print.h +2460 -0
  20. package/cpp/dawn/wire/client/webgpu.h +339 -0
  21. package/cpp/dawn/wire/client/webgpu_cpp.h +9140 -0
  22. package/cpp/jsi/RNFEnumMapper.h +49 -0
  23. package/cpp/jsi/RNFHybridObject.cpp +145 -0
  24. package/cpp/jsi/RNFHybridObject.h +162 -0
  25. package/cpp/jsi/RNFJSIConverter.h +412 -0
  26. package/cpp/jsi/RNFJSIHelper.h +49 -0
  27. package/cpp/jsi/RNFPointerHolder.h +95 -0
  28. package/cpp/jsi/RNFPromise.cpp +45 -0
  29. package/cpp/jsi/RNFPromise.h +38 -0
  30. package/cpp/jsi/RNFRuntimeCache.cpp +57 -0
  31. package/cpp/jsi/RNFRuntimeCache.h +79 -0
  32. package/cpp/jsi/RNFWorkletRuntimeCollector.h +43 -0
  33. package/cpp/jsi/RNFWorkletRuntimeRegistry.cpp +11 -0
  34. package/cpp/jsi/RNFWorkletRuntimeRegistry.h +44 -0
  35. package/cpp/rnwgpu/MutableBuffer.h +48 -0
  36. package/cpp/rnwgpu/RNWebGPUManager.cpp +60 -0
  37. package/cpp/rnwgpu/RNWebGPUManager.h +30 -0
  38. package/cpp/rnwgpu/api/GPU.cpp +40 -0
  39. package/cpp/rnwgpu/api/GPU.h +43 -0
  40. package/cpp/rnwgpu/api/GPUAdapter.cpp +33 -0
  41. package/cpp/rnwgpu/api/GPUAdapter.h +40 -0
  42. package/cpp/rnwgpu/api/GPUAdapterInfo.h +33 -0
  43. package/cpp/rnwgpu/api/GPUBindGroup.h +38 -0
  44. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +39 -0
  45. package/cpp/rnwgpu/api/GPUBuffer.cpp +16 -0
  46. package/cpp/rnwgpu/api/GPUBuffer.h +44 -0
  47. package/cpp/rnwgpu/api/GPUCanvasContext.h +33 -0
  48. package/cpp/rnwgpu/api/GPUCommandBuffer.h +38 -0
  49. package/cpp/rnwgpu/api/GPUCommandEncoder.h +38 -0
  50. package/cpp/rnwgpu/api/GPUCompilationInfo.h +33 -0
  51. package/cpp/rnwgpu/api/GPUCompilationMessage.h +33 -0
  52. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +40 -0
  53. package/cpp/rnwgpu/api/GPUComputePipeline.h +39 -0
  54. package/cpp/rnwgpu/api/GPUDevice.cpp +12 -0
  55. package/cpp/rnwgpu/api/GPUDevice.h +45 -0
  56. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +33 -0
  57. package/cpp/rnwgpu/api/GPUExternalTexture.h +39 -0
  58. package/cpp/rnwgpu/api/GPUPipelineLayout.h +38 -0
  59. package/cpp/rnwgpu/api/GPUQuerySet.h +38 -0
  60. package/cpp/rnwgpu/api/GPUQueue.h +38 -0
  61. package/cpp/rnwgpu/api/GPURenderBundle.h +38 -0
  62. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +40 -0
  63. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +40 -0
  64. package/cpp/rnwgpu/api/GPURenderPipeline.h +38 -0
  65. package/cpp/rnwgpu/api/GPUSampler.h +38 -0
  66. package/cpp/rnwgpu/api/GPUShaderModule.h +38 -0
  67. package/cpp/rnwgpu/api/GPUSupportedLimits.h +33 -0
  68. package/cpp/rnwgpu/api/GPUTexture.h +38 -0
  69. package/cpp/rnwgpu/api/GPUTextureView.h +38 -0
  70. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +33 -0
  71. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +81 -0
  72. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +67 -0
  73. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +69 -0
  74. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +95 -0
  75. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +56 -0
  76. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +65 -0
  77. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +72 -0
  78. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +62 -0
  79. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +85 -0
  80. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +43 -0
  81. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +93 -0
  82. package/cpp/rnwgpu/api/descriptors/GPUColorDict.h +81 -0
  83. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +69 -0
  84. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +31 -0
  85. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +62 -0
  86. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +80 -0
  87. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +82 -0
  88. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +126 -0
  89. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +69 -0
  90. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDict.h +76 -0
  91. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDictStrict.h +91 -0
  92. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +44 -0
  93. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +75 -0
  94. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +85 -0
  95. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +83 -0
  96. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +66 -0
  97. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +74 -0
  98. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +88 -0
  99. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +70 -0
  100. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +25 -0
  101. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +68 -0
  102. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDict.h +61 -0
  103. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDictStrict.h +75 -0
  104. package/cpp/rnwgpu/api/descriptors/GPUOrigin3DDict.h +71 -0
  105. package/cpp/rnwgpu/api/descriptors/GPUPipelineErrorInit.h +54 -0
  106. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +72 -0
  107. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +66 -0
  108. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +72 -0
  109. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +81 -0
  110. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +102 -0
  111. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +105 -0
  112. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +118 -0
  113. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +100 -0
  114. package/cpp/rnwgpu/api/descriptors/GPURenderPassLayout.h +83 -0
  115. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +80 -0
  116. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +104 -0
  117. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +56 -0
  118. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +48 -0
  119. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +116 -0
  120. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +64 -0
  121. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +88 -0
  122. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +27 -0
  123. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +61 -0
  124. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +67 -0
  125. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +58 -0
  126. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +123 -0
  127. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +40 -0
  128. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +113 -0
  129. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +71 -0
  130. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +80 -0
  131. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +73 -0
  132. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +77 -0
  133. package/cpp/rnwgpu/api/descriptors/Unions.h +1645 -0
  134. package/cpp/webgpu/webgpu.h +33 -0
  135. package/cpp/webgpu/webgpu_cpp.h +33 -0
  136. package/cpp/webgpu/webgpu_cpp_chained_struct.h +55 -0
  137. package/cpp/webgpu/webgpu_enum_class_bitmasks.h +161 -0
  138. package/ios/RNFAppleLogger.mm +22 -0
  139. package/ios/Utils.h +5 -0
  140. package/ios/Utils.m +26 -0
  141. package/ios/WebGPUModule.h +18 -0
  142. package/ios/WebGPUModule.mm +77 -0
  143. package/ios/WebGPUView.h +15 -0
  144. package/ios/WebGPUView.mm +58 -0
  145. package/ios/WebGPUViewManager.mm +21 -0
  146. package/lib/commonjs/WebGPUNativeModule.js +10 -0
  147. package/lib/commonjs/WebGPUNativeModule.js.map +1 -0
  148. package/lib/commonjs/WebGPUViewNativeComponent.js +11 -0
  149. package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -0
  150. package/lib/commonjs/index.js +45 -0
  151. package/lib/commonjs/index.js.map +1 -0
  152. package/lib/module/WebGPUNativeModule.js +4 -0
  153. package/lib/module/WebGPUNativeModule.js.map +1 -0
  154. package/lib/module/WebGPUViewNativeComponent.js +4 -0
  155. package/lib/module/WebGPUViewNativeComponent.js.map +1 -0
  156. package/lib/module/index.js +9 -0
  157. package/lib/module/index.js.map +1 -0
  158. package/lib/typescript/babel.config.d.ts +2 -0
  159. package/lib/typescript/babel.config.d.ts.map +1 -0
  160. package/lib/typescript/jest.config.d.ts +5 -0
  161. package/lib/typescript/jest.config.d.ts.map +1 -0
  162. package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts +5 -0
  163. package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts.map +1 -0
  164. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts +4 -0
  165. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts.map +1 -0
  166. package/lib/typescript/lib/commonjs/index.d.ts +5 -0
  167. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
  168. package/lib/typescript/lib/module/WebGPUNativeModule.d.ts +3 -0
  169. package/lib/typescript/lib/module/WebGPUNativeModule.d.ts.map +1 -0
  170. package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts +4 -0
  171. package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts.map +1 -0
  172. package/lib/typescript/lib/module/index.d.ts +5 -0
  173. package/lib/typescript/lib/module/index.d.ts.map +1 -0
  174. package/lib/typescript/scripts/build/copy-artifacts.d.ts +2 -0
  175. package/lib/typescript/scripts/build/copy-artifacts.d.ts.map +1 -0
  176. package/lib/typescript/scripts/build/dawn.d.ts +2 -0
  177. package/lib/typescript/scripts/build/dawn.d.ts.map +1 -0
  178. package/lib/typescript/scripts/build/util.d.ts +13 -0
  179. package/lib/typescript/scripts/build/util.d.ts.map +1 -0
  180. package/lib/typescript/scripts/codegen/codegen.d.ts +2 -0
  181. package/lib/typescript/scripts/codegen/codegen.d.ts.map +1 -0
  182. package/lib/typescript/scripts/codegen/model/dawn.d.ts +2 -0
  183. package/lib/typescript/scripts/codegen/model/dawn.d.ts.map +1 -0
  184. package/lib/typescript/scripts/codegen/model/model.d.ts +8 -0
  185. package/lib/typescript/scripts/codegen/model/model.d.ts.map +1 -0
  186. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts +4 -0
  187. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts.map +1 -0
  188. package/lib/typescript/scripts/codegen/templates/Enum.d.ts +3 -0
  189. package/lib/typescript/scripts/codegen/templates/Enum.d.ts.map +1 -0
  190. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts +3 -0
  191. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts.map +1 -0
  192. package/lib/typescript/scripts/codegen/templates/Unions.d.ts +6 -0
  193. package/lib/typescript/scripts/codegen/templates/Unions.d.ts.map +1 -0
  194. package/lib/typescript/scripts/codegen/templates/common.d.ts +9 -0
  195. package/lib/typescript/scripts/codegen/templates/common.d.ts.map +1 -0
  196. package/lib/typescript/scripts/codegen/util.d.ts +2 -0
  197. package/lib/typescript/scripts/codegen/util.d.ts.map +1 -0
  198. package/lib/typescript/src/WebGPUNativeModule.d.ts +7 -0
  199. package/lib/typescript/src/WebGPUNativeModule.d.ts.map +1 -0
  200. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +8 -0
  201. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -0
  202. package/lib/typescript/src/index.d.ts +9 -0
  203. package/lib/typescript/src/index.d.ts.map +1 -0
  204. package/package.json +120 -0
  205. package/react-native-webgpu.podspec +56 -0
  206. package/src/WebGPUNativeModule.ts +9 -0
  207. package/src/WebGPUViewNativeComponent.ts +9 -0
  208. package/src/index.tsx +13 -0
@@ -0,0 +1,83 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUImageCopyBuffer {
17
+ public:
18
+ wgpu::ImageCopyBuffer *getInstance() { return &_instance; }
19
+
20
+ wgpu::ImageCopyBuffer _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyBuffer>> {
27
+ static std::shared_ptr<rnwgpu::GPUImageCopyBuffer>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUImageCopyBuffer>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "buffer")) {
33
+ auto buffer = value.getProperty(runtime, "buffer");
34
+
35
+ if (buffer.isUndefined()) {
36
+ throw std::runtime_error(
37
+ "Property GPUImageCopyBuffer::buffer is required");
38
+ }
39
+ } else {
40
+ throw std::runtime_error(
41
+ "Property GPUImageCopyBuffer::buffer is not defined");
42
+ }
43
+ if (value.hasProperty(runtime, "offset")) {
44
+ auto offset = value.getProperty(runtime, "offset");
45
+
46
+ if (offset.isNumber()) {
47
+ result->_instance.offset = offset.getNumber();
48
+ }
49
+ }
50
+ if (value.hasProperty(runtime, "bytesPerRow")) {
51
+ auto bytesPerRow = value.getProperty(runtime, "bytesPerRow");
52
+
53
+ if (bytesPerRow.isNumber()) {
54
+ result->_instance.bytesPerRow =
55
+ static_cast<wgpu::Size32>(bytesPerRow.getNumber());
56
+ }
57
+ }
58
+ if (value.hasProperty(runtime, "rowsPerImage")) {
59
+ auto rowsPerImage = value.getProperty(runtime, "rowsPerImage");
60
+
61
+ if (rowsPerImage.isNumber()) {
62
+ result->_instance.rowsPerImage =
63
+ static_cast<wgpu::Size32>(rowsPerImage.getNumber());
64
+ }
65
+ }
66
+ }
67
+ rnwgpu::Logger::logToConsole("GPUImageCopyBuffer::buffer = %f",
68
+ result->_instance.buffer);
69
+ rnwgpu::Logger::logToConsole("GPUImageCopyBuffer::offset = %f",
70
+ result->_instance.offset);
71
+ rnwgpu::Logger::logToConsole("GPUImageCopyBuffer::bytesPerRow = %f",
72
+ result->_instance.bytesPerRow);
73
+ rnwgpu::Logger::logToConsole("GPUImageCopyBuffer::rowsPerImage = %f",
74
+ result->_instance.rowsPerImage);
75
+ return result;
76
+ }
77
+ static jsi::Value toJSI(jsi::Runtime &runtime,
78
+ std::shared_ptr<rnwgpu::GPUImageCopyBuffer> arg) {
79
+ // No conversions here
80
+ return jsi::Value::null();
81
+ }
82
+ };
83
+ } // namespace margelo
@@ -0,0 +1,66 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUImageCopyExternalImage {
17
+ public:
18
+ wgpu::ImageCopyExternalImage *getInstance() { return &_instance; }
19
+
20
+ wgpu::ImageCopyExternalImage _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyExternalImage>> {
28
+ static std::shared_ptr<rnwgpu::GPUImageCopyExternalImage>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUImageCopyExternalImage>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "source")) {
34
+ auto source = value.getProperty(runtime, "source");
35
+
36
+ if (source.isUndefined()) {
37
+ throw std::runtime_error(
38
+ "Property GPUImageCopyExternalImage::source is required");
39
+ }
40
+ } else {
41
+ throw std::runtime_error(
42
+ "Property GPUImageCopyExternalImage::source is not defined");
43
+ }
44
+ if (value.hasProperty(runtime, "origin")) {
45
+ auto origin = value.getProperty(runtime, "origin");
46
+ }
47
+ if (value.hasProperty(runtime, "flipY")) {
48
+ auto flipY = value.getProperty(runtime, "flipY");
49
+ }
50
+ }
51
+ rnwgpu::Logger::logToConsole("GPUImageCopyExternalImage::source = %f",
52
+ result->_instance.source);
53
+ rnwgpu::Logger::logToConsole("GPUImageCopyExternalImage::origin = %f",
54
+ result->_instance.origin);
55
+ rnwgpu::Logger::logToConsole("GPUImageCopyExternalImage::flipY = %f",
56
+ result->_instance.flipY);
57
+ return result;
58
+ }
59
+ static jsi::Value
60
+ toJSI(jsi::Runtime &runtime,
61
+ std::shared_ptr<rnwgpu::GPUImageCopyExternalImage> arg) {
62
+ // No conversions here
63
+ return jsi::Value::null();
64
+ }
65
+ };
66
+ } // namespace margelo
@@ -0,0 +1,74 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUImageCopyTexture {
17
+ public:
18
+ wgpu::ImageCopyTexture *getInstance() { return &_instance; }
19
+
20
+ wgpu::ImageCopyTexture _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyTexture>> {
27
+ static std::shared_ptr<rnwgpu::GPUImageCopyTexture>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUImageCopyTexture>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "texture")) {
33
+ auto texture = value.getProperty(runtime, "texture");
34
+
35
+ if (texture.isUndefined()) {
36
+ throw std::runtime_error(
37
+ "Property GPUImageCopyTexture::texture is required");
38
+ }
39
+ } else {
40
+ throw std::runtime_error(
41
+ "Property GPUImageCopyTexture::texture is not defined");
42
+ }
43
+ if (value.hasProperty(runtime, "mipLevel")) {
44
+ auto mipLevel = value.getProperty(runtime, "mipLevel");
45
+
46
+ if (mipLevel.isNumber()) {
47
+ result->_instance.mipLevel =
48
+ static_cast<wgpu::IntegerCoordinate>(mipLevel.getNumber());
49
+ }
50
+ }
51
+ if (value.hasProperty(runtime, "origin")) {
52
+ auto origin = value.getProperty(runtime, "origin");
53
+ }
54
+ if (value.hasProperty(runtime, "aspect")) {
55
+ auto aspect = value.getProperty(runtime, "aspect");
56
+ }
57
+ }
58
+ rnwgpu::Logger::logToConsole("GPUImageCopyTexture::texture = %f",
59
+ result->_instance.texture);
60
+ rnwgpu::Logger::logToConsole("GPUImageCopyTexture::mipLevel = %f",
61
+ result->_instance.mipLevel);
62
+ rnwgpu::Logger::logToConsole("GPUImageCopyTexture::origin = %f",
63
+ result->_instance.origin);
64
+ rnwgpu::Logger::logToConsole("GPUImageCopyTexture::aspect = %f",
65
+ result->_instance.aspect);
66
+ return result;
67
+ }
68
+ static jsi::Value toJSI(jsi::Runtime &runtime,
69
+ std::shared_ptr<rnwgpu::GPUImageCopyTexture> arg) {
70
+ // No conversions here
71
+ return jsi::Value::null();
72
+ }
73
+ };
74
+ } // namespace margelo
@@ -0,0 +1,88 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUImageCopyTextureTagged {
17
+ public:
18
+ wgpu::ImageCopyTextureTagged *getInstance() { return &_instance; }
19
+
20
+ wgpu::ImageCopyTextureTagged _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyTextureTagged>> {
28
+ static std::shared_ptr<rnwgpu::GPUImageCopyTextureTagged>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUImageCopyTextureTagged>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "colorSpace")) {
34
+ auto colorSpace = value.getProperty(runtime, "colorSpace");
35
+ }
36
+ if (value.hasProperty(runtime, "premultipliedAlpha")) {
37
+ auto premultipliedAlpha =
38
+ value.getProperty(runtime, "premultipliedAlpha");
39
+ }
40
+ if (value.hasProperty(runtime, "texture")) {
41
+ auto texture = value.getProperty(runtime, "texture");
42
+
43
+ if (texture.isUndefined()) {
44
+ throw std::runtime_error(
45
+ "Property GPUImageCopyTextureTagged::texture is required");
46
+ }
47
+ } else {
48
+ throw std::runtime_error(
49
+ "Property GPUImageCopyTextureTagged::texture is not defined");
50
+ }
51
+ if (value.hasProperty(runtime, "mipLevel")) {
52
+ auto mipLevel = value.getProperty(runtime, "mipLevel");
53
+
54
+ if (mipLevel.isNumber()) {
55
+ result->_instance.mipLevel =
56
+ static_cast<wgpu::IntegerCoordinate>(mipLevel.getNumber());
57
+ }
58
+ }
59
+ if (value.hasProperty(runtime, "origin")) {
60
+ auto origin = value.getProperty(runtime, "origin");
61
+ }
62
+ if (value.hasProperty(runtime, "aspect")) {
63
+ auto aspect = value.getProperty(runtime, "aspect");
64
+ }
65
+ }
66
+ rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::colorSpace = %f",
67
+ result->_instance.colorSpace);
68
+ rnwgpu::Logger::logToConsole(
69
+ "GPUImageCopyTextureTagged::premultipliedAlpha = %f",
70
+ result->_instance.premultipliedAlpha);
71
+ rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::texture = %f",
72
+ result->_instance.texture);
73
+ rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::mipLevel = %f",
74
+ result->_instance.mipLevel);
75
+ rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::origin = %f",
76
+ result->_instance.origin);
77
+ rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::aspect = %f",
78
+ result->_instance.aspect);
79
+ return result;
80
+ }
81
+ static jsi::Value
82
+ toJSI(jsi::Runtime &runtime,
83
+ std::shared_ptr<rnwgpu::GPUImageCopyTextureTagged> arg) {
84
+ // No conversions here
85
+ return jsi::Value::null();
86
+ }
87
+ };
88
+ } // namespace margelo
@@ -0,0 +1,70 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUImageDataLayout {
17
+ public:
18
+ wgpu::ImageDataLayout *getInstance() { return &_instance; }
19
+
20
+ wgpu::ImageDataLayout _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageDataLayout>> {
27
+ static std::shared_ptr<rnwgpu::GPUImageDataLayout>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUImageDataLayout>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "offset")) {
33
+ auto offset = value.getProperty(runtime, "offset");
34
+
35
+ if (offset.isNumber()) {
36
+ result->_instance.offset = offset.getNumber();
37
+ }
38
+ }
39
+ if (value.hasProperty(runtime, "bytesPerRow")) {
40
+ auto bytesPerRow = value.getProperty(runtime, "bytesPerRow");
41
+
42
+ if (bytesPerRow.isNumber()) {
43
+ result->_instance.bytesPerRow =
44
+ static_cast<wgpu::Size32>(bytesPerRow.getNumber());
45
+ }
46
+ }
47
+ if (value.hasProperty(runtime, "rowsPerImage")) {
48
+ auto rowsPerImage = value.getProperty(runtime, "rowsPerImage");
49
+
50
+ if (rowsPerImage.isNumber()) {
51
+ result->_instance.rowsPerImage =
52
+ static_cast<wgpu::Size32>(rowsPerImage.getNumber());
53
+ }
54
+ }
55
+ }
56
+ rnwgpu::Logger::logToConsole("GPUImageDataLayout::offset = %f",
57
+ result->_instance.offset);
58
+ rnwgpu::Logger::logToConsole("GPUImageDataLayout::bytesPerRow = %f",
59
+ result->_instance.bytesPerRow);
60
+ rnwgpu::Logger::logToConsole("GPUImageDataLayout::rowsPerImage = %f",
61
+ result->_instance.rowsPerImage);
62
+ return result;
63
+ }
64
+ static jsi::Value toJSI(jsi::Runtime &runtime,
65
+ std::shared_ptr<rnwgpu::GPUImageDataLayout> arg) {
66
+ // No conversions here
67
+ return jsi::Value::null();
68
+ }
69
+ };
70
+ } // namespace margelo
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+ #include <string>
3
+
4
+ #include <RNFHybridObject.h>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ namespace rnwgpu {
9
+
10
+ namespace m = margelo;
11
+
12
+ class GPUMapMode : public m::HybridObject {
13
+ public:
14
+ GPUMapMode() : HybridObject("GPUMapMode") {}
15
+
16
+ public:
17
+ double Read() { return static_cast<double>(wgpu::MapMode::Read); }
18
+ double Write() { return static_cast<double>(wgpu::MapMode::Write); }
19
+
20
+ void loadHybridMethods() override {
21
+ registerHybridGetter("READ", &GPUMapMode::Read, this);
22
+ registerHybridGetter("WRITE", &GPUMapMode::Write, this);
23
+ }
24
+ };
25
+ } // namespace rnwgpu
@@ -0,0 +1,68 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUMultisampleState {
17
+ public:
18
+ wgpu::MultisampleState *getInstance() { return &_instance; }
19
+
20
+ wgpu::MultisampleState _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUMultisampleState>> {
27
+ static std::shared_ptr<rnwgpu::GPUMultisampleState>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUMultisampleState>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "count")) {
33
+ auto count = value.getProperty(runtime, "count");
34
+
35
+ if (count.isNumber()) {
36
+ result->_instance.count =
37
+ static_cast<wgpu::Size32>(count.getNumber());
38
+ }
39
+ }
40
+ if (value.hasProperty(runtime, "mask")) {
41
+ auto mask = value.getProperty(runtime, "mask");
42
+
43
+ if (mask.isNumber()) {
44
+ result->_instance.mask =
45
+ static_cast<wgpu::SampleMask>(mask.getNumber());
46
+ }
47
+ }
48
+ if (value.hasProperty(runtime, "alphaToCoverageEnabled")) {
49
+ auto alphaToCoverageEnabled =
50
+ value.getProperty(runtime, "alphaToCoverageEnabled");
51
+ }
52
+ }
53
+ rnwgpu::Logger::logToConsole("GPUMultisampleState::count = %f",
54
+ result->_instance.count);
55
+ rnwgpu::Logger::logToConsole("GPUMultisampleState::mask = %f",
56
+ result->_instance.mask);
57
+ rnwgpu::Logger::logToConsole(
58
+ "GPUMultisampleState::alphaToCoverageEnabled = %f",
59
+ result->_instance.alphaToCoverageEnabled);
60
+ return result;
61
+ }
62
+ static jsi::Value toJSI(jsi::Runtime &runtime,
63
+ std::shared_ptr<rnwgpu::GPUMultisampleState> arg) {
64
+ // No conversions here
65
+ return jsi::Value::null();
66
+ }
67
+ };
68
+ } // namespace margelo
@@ -0,0 +1,61 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUOrigin2DDict {
17
+ public:
18
+ wgpu::Origin2DDict *getInstance() { return &_instance; }
19
+
20
+ wgpu::Origin2DDict _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin2DDict>> {
27
+ static std::shared_ptr<rnwgpu::GPUOrigin2DDict>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUOrigin2DDict>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "x")) {
33
+ auto x = value.getProperty(runtime, "x");
34
+
35
+ if (x.isNumber()) {
36
+ result->_instance.x =
37
+ static_cast<wgpu::IntegerCoordinate>(x.getNumber());
38
+ }
39
+ }
40
+ if (value.hasProperty(runtime, "y")) {
41
+ auto y = value.getProperty(runtime, "y");
42
+
43
+ if (y.isNumber()) {
44
+ result->_instance.y =
45
+ static_cast<wgpu::IntegerCoordinate>(y.getNumber());
46
+ }
47
+ }
48
+ }
49
+ rnwgpu::Logger::logToConsole("GPUOrigin2DDict::x = %f",
50
+ result->_instance.x);
51
+ rnwgpu::Logger::logToConsole("GPUOrigin2DDict::y = %f",
52
+ result->_instance.y);
53
+ return result;
54
+ }
55
+ static jsi::Value toJSI(jsi::Runtime &runtime,
56
+ std::shared_ptr<rnwgpu::GPUOrigin2DDict> arg) {
57
+ // No conversions here
58
+ return jsi::Value::null();
59
+ }
60
+ };
61
+ } // namespace margelo
@@ -0,0 +1,75 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUOrigin2DDictStrict {
17
+ public:
18
+ wgpu::Origin2DDictStrict *getInstance() { return &_instance; }
19
+
20
+ wgpu::Origin2DDictStrict _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin2DDictStrict>> {
28
+ static std::shared_ptr<rnwgpu::GPUOrigin2DDictStrict>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUOrigin2DDictStrict>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "z")) {
34
+ auto z = value.getProperty(runtime, "z");
35
+
36
+ if (z.isUndefined()) {
37
+ throw std::runtime_error(
38
+ "Property GPUOrigin2DDictStrict::z is required");
39
+ }
40
+ } else {
41
+ throw std::runtime_error(
42
+ "Property GPUOrigin2DDictStrict::z is not defined");
43
+ }
44
+ if (value.hasProperty(runtime, "x")) {
45
+ auto x = value.getProperty(runtime, "x");
46
+
47
+ if (x.isNumber()) {
48
+ result->_instance.x =
49
+ static_cast<wgpu::IntegerCoordinate>(x.getNumber());
50
+ }
51
+ }
52
+ if (value.hasProperty(runtime, "y")) {
53
+ auto y = value.getProperty(runtime, "y");
54
+
55
+ if (y.isNumber()) {
56
+ result->_instance.y =
57
+ static_cast<wgpu::IntegerCoordinate>(y.getNumber());
58
+ }
59
+ }
60
+ }
61
+ rnwgpu::Logger::logToConsole("GPUOrigin2DDictStrict::z = %f",
62
+ result->_instance.z);
63
+ rnwgpu::Logger::logToConsole("GPUOrigin2DDictStrict::x = %f",
64
+ result->_instance.x);
65
+ rnwgpu::Logger::logToConsole("GPUOrigin2DDictStrict::y = %f",
66
+ result->_instance.y);
67
+ return result;
68
+ }
69
+ static jsi::Value toJSI(jsi::Runtime &runtime,
70
+ std::shared_ptr<rnwgpu::GPUOrigin2DDictStrict> arg) {
71
+ // No conversions here
72
+ return jsi::Value::null();
73
+ }
74
+ };
75
+ } // namespace margelo
@@ -0,0 +1,71 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "webgpu/webgpu_cpp.h"
7
+
8
+ #include "Logger.h"
9
+ #include "RNFJSIConverter.h"
10
+ #include <RNFHybridObject.h>
11
+
12
+ namespace jsi = facebook::jsi;
13
+
14
+ namespace rnwgpu {
15
+
16
+ class GPUOrigin3DDict {
17
+ public:
18
+ wgpu::Origin3DDict *getInstance() { return &_instance; }
19
+
20
+ wgpu::Origin3DDict _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin3DDict>> {
27
+ static std::shared_ptr<rnwgpu::GPUOrigin3DDict>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUOrigin3DDict>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "x")) {
33
+ auto x = value.getProperty(runtime, "x");
34
+
35
+ if (x.isNumber()) {
36
+ result->_instance.x =
37
+ static_cast<wgpu::IntegerCoordinate>(x.getNumber());
38
+ }
39
+ }
40
+ if (value.hasProperty(runtime, "y")) {
41
+ auto y = value.getProperty(runtime, "y");
42
+
43
+ if (y.isNumber()) {
44
+ result->_instance.y =
45
+ static_cast<wgpu::IntegerCoordinate>(y.getNumber());
46
+ }
47
+ }
48
+ if (value.hasProperty(runtime, "z")) {
49
+ auto z = value.getProperty(runtime, "z");
50
+
51
+ if (z.isNumber()) {
52
+ result->_instance.z =
53
+ static_cast<wgpu::IntegerCoordinate>(z.getNumber());
54
+ }
55
+ }
56
+ }
57
+ rnwgpu::Logger::logToConsole("GPUOrigin3DDict::x = %f",
58
+ result->_instance.x);
59
+ rnwgpu::Logger::logToConsole("GPUOrigin3DDict::y = %f",
60
+ result->_instance.y);
61
+ rnwgpu::Logger::logToConsole("GPUOrigin3DDict::z = %f",
62
+ result->_instance.z);
63
+ return result;
64
+ }
65
+ static jsi::Value toJSI(jsi::Runtime &runtime,
66
+ std::shared_ptr<rnwgpu::GPUOrigin3DDict> arg) {
67
+ // No conversions here
68
+ return jsi::Value::null();
69
+ }
70
+ };
71
+ } // namespace margelo