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,82 @@
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 GPUComputePipelineDescriptor {
17
+ public:
18
+ wgpu::ComputePipelineDescriptor *getInstance() { return &_instance; }
19
+
20
+ wgpu::ComputePipelineDescriptor _instance;
21
+
22
+ std::string label;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <>
29
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUComputePipelineDescriptor>> {
30
+ static std::shared_ptr<rnwgpu::GPUComputePipelineDescriptor>
31
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
32
+ auto result = std::make_unique<rnwgpu::GPUComputePipelineDescriptor>();
33
+ if (!outOfBounds && arg.isObject()) {
34
+ auto value = arg.getObject(runtime);
35
+ if (value.hasProperty(runtime, "compute")) {
36
+ auto compute = value.getProperty(runtime, "compute");
37
+
38
+ if (compute.isUndefined()) {
39
+ throw std::runtime_error(
40
+ "Property GPUComputePipelineDescriptor::compute is required");
41
+ }
42
+ } else {
43
+ throw std::runtime_error(
44
+ "Property GPUComputePipelineDescriptor::compute is not defined");
45
+ }
46
+ if (value.hasProperty(runtime, "layout")) {
47
+ auto layout = value.getProperty(runtime, "layout");
48
+
49
+ if (layout.isUndefined()) {
50
+ throw std::runtime_error(
51
+ "Property GPUComputePipelineDescriptor::layout is required");
52
+ }
53
+ } else {
54
+ throw std::runtime_error(
55
+ "Property GPUComputePipelineDescriptor::layout is not defined");
56
+ }
57
+ if (value.hasProperty(runtime, "label")) {
58
+ auto label = value.getProperty(runtime, "label");
59
+
60
+ if (label.isString()) {
61
+ auto str = label.asString(runtime).utf8(runtime);
62
+ result->label = str;
63
+ result->_instance.label = result->label.c_str();
64
+ }
65
+ }
66
+ }
67
+ rnwgpu::Logger::logToConsole("GPUComputePipelineDescriptor::compute = %f",
68
+ result->_instance.compute);
69
+ rnwgpu::Logger::logToConsole("GPUComputePipelineDescriptor::layout = %f",
70
+ result->_instance.layout);
71
+ rnwgpu::Logger::logToConsole("GPUComputePipelineDescriptor::label = %f",
72
+ result->_instance.label);
73
+ return result;
74
+ }
75
+ static jsi::Value
76
+ toJSI(jsi::Runtime &runtime,
77
+ std::shared_ptr<rnwgpu::GPUComputePipelineDescriptor> arg) {
78
+ // No conversions here
79
+ return jsi::Value::null();
80
+ }
81
+ };
82
+ } // namespace margelo
@@ -0,0 +1,126 @@
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 GPUDepthStencilState {
17
+ public:
18
+ wgpu::DepthStencilState *getInstance() { return &_instance; }
19
+
20
+ wgpu::DepthStencilState _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDepthStencilState>> {
27
+ static std::shared_ptr<rnwgpu::GPUDepthStencilState>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUDepthStencilState>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "format")) {
33
+ auto format = value.getProperty(runtime, "format");
34
+
35
+ if (format.isUndefined()) {
36
+ throw std::runtime_error(
37
+ "Property GPUDepthStencilState::format is required");
38
+ }
39
+ } else {
40
+ throw std::runtime_error(
41
+ "Property GPUDepthStencilState::format is not defined");
42
+ }
43
+ if (value.hasProperty(runtime, "depthWriteEnabled")) {
44
+ auto depthWriteEnabled =
45
+ value.getProperty(runtime, "depthWriteEnabled");
46
+ }
47
+ if (value.hasProperty(runtime, "depthCompare")) {
48
+ auto depthCompare = value.getProperty(runtime, "depthCompare");
49
+ }
50
+ if (value.hasProperty(runtime, "stencilFront")) {
51
+ auto stencilFront = value.getProperty(runtime, "stencilFront");
52
+ }
53
+ if (value.hasProperty(runtime, "stencilBack")) {
54
+ auto stencilBack = value.getProperty(runtime, "stencilBack");
55
+ }
56
+ if (value.hasProperty(runtime, "stencilReadMask")) {
57
+ auto stencilReadMask = value.getProperty(runtime, "stencilReadMask");
58
+
59
+ if (stencilReadMask.isNumber()) {
60
+ result->_instance.stencilReadMask =
61
+ static_cast<wgpu::StencilValue>(stencilReadMask.getNumber());
62
+ }
63
+ }
64
+ if (value.hasProperty(runtime, "stencilWriteMask")) {
65
+ auto stencilWriteMask = value.getProperty(runtime, "stencilWriteMask");
66
+
67
+ if (stencilWriteMask.isNumber()) {
68
+ result->_instance.stencilWriteMask =
69
+ static_cast<wgpu::StencilValue>(stencilWriteMask.getNumber());
70
+ }
71
+ }
72
+ if (value.hasProperty(runtime, "depthBias")) {
73
+ auto depthBias = value.getProperty(runtime, "depthBias");
74
+
75
+ if (depthBias.isNumber()) {
76
+ result->_instance.depthBias =
77
+ static_cast<wgpu::DepthBias>(depthBias.getNumber());
78
+ }
79
+ }
80
+ if (value.hasProperty(runtime, "depthBiasSlopeScale")) {
81
+ auto depthBiasSlopeScale =
82
+ value.getProperty(runtime, "depthBiasSlopeScale");
83
+
84
+ if (depthBiasSlopeScale.isNumber()) {
85
+ result->_instance.depthBiasSlopeScale =
86
+ depthBiasSlopeScale.getNumber();
87
+ }
88
+ }
89
+ if (value.hasProperty(runtime, "depthBiasClamp")) {
90
+ auto depthBiasClamp = value.getProperty(runtime, "depthBiasClamp");
91
+
92
+ if (depthBiasClamp.isNumber()) {
93
+ result->_instance.depthBiasClamp = depthBiasClamp.getNumber();
94
+ }
95
+ }
96
+ }
97
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::format = %f",
98
+ result->_instance.format);
99
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::depthWriteEnabled = %f",
100
+ result->_instance.depthWriteEnabled);
101
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::depthCompare = %f",
102
+ result->_instance.depthCompare);
103
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::stencilFront = %f",
104
+ result->_instance.stencilFront);
105
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::stencilBack = %f",
106
+ result->_instance.stencilBack);
107
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::stencilReadMask = %f",
108
+ result->_instance.stencilReadMask);
109
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::stencilWriteMask = %f",
110
+ result->_instance.stencilWriteMask);
111
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::depthBias = %f",
112
+ result->_instance.depthBias);
113
+ rnwgpu::Logger::logToConsole(
114
+ "GPUDepthStencilState::depthBiasSlopeScale = %f",
115
+ result->_instance.depthBiasSlopeScale);
116
+ rnwgpu::Logger::logToConsole("GPUDepthStencilState::depthBiasClamp = %f",
117
+ result->_instance.depthBiasClamp);
118
+ return result;
119
+ }
120
+ static jsi::Value toJSI(jsi::Runtime &runtime,
121
+ std::shared_ptr<rnwgpu::GPUDepthStencilState> arg) {
122
+ // No conversions here
123
+ return jsi::Value::null();
124
+ }
125
+ };
126
+ } // namespace margelo
@@ -0,0 +1,69 @@
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 GPUDeviceDescriptor {
17
+ public:
18
+ wgpu::DeviceDescriptor *getInstance() { return &_instance; }
19
+
20
+ wgpu::DeviceDescriptor _instance;
21
+
22
+ std::string label;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDeviceDescriptor>> {
29
+ static std::shared_ptr<rnwgpu::GPUDeviceDescriptor>
30
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
31
+ auto result = std::make_unique<rnwgpu::GPUDeviceDescriptor>();
32
+ if (!outOfBounds && arg.isObject()) {
33
+ auto value = arg.getObject(runtime);
34
+ if (value.hasProperty(runtime, "requiredFeatures")) {
35
+ auto requiredFeatures = value.getProperty(runtime, "requiredFeatures");
36
+ }
37
+ if (value.hasProperty(runtime, "requiredLimits")) {
38
+ auto requiredLimits = value.getProperty(runtime, "requiredLimits");
39
+ }
40
+ if (value.hasProperty(runtime, "defaultQueue")) {
41
+ auto defaultQueue = value.getProperty(runtime, "defaultQueue");
42
+ }
43
+ if (value.hasProperty(runtime, "label")) {
44
+ auto label = value.getProperty(runtime, "label");
45
+
46
+ if (label.isString()) {
47
+ auto str = label.asString(runtime).utf8(runtime);
48
+ result->label = str;
49
+ result->_instance.label = result->label.c_str();
50
+ }
51
+ }
52
+ }
53
+ rnwgpu::Logger::logToConsole("GPUDeviceDescriptor::requiredFeatures = %f",
54
+ result->_instance.requiredFeatures);
55
+ rnwgpu::Logger::logToConsole("GPUDeviceDescriptor::requiredLimits = %f",
56
+ result->_instance.requiredLimits);
57
+ rnwgpu::Logger::logToConsole("GPUDeviceDescriptor::defaultQueue = %f",
58
+ result->_instance.defaultQueue);
59
+ rnwgpu::Logger::logToConsole("GPUDeviceDescriptor::label = %f",
60
+ result->_instance.label);
61
+ return result;
62
+ }
63
+ static jsi::Value toJSI(jsi::Runtime &runtime,
64
+ std::shared_ptr<rnwgpu::GPUDeviceDescriptor> arg) {
65
+ // No conversions here
66
+ return jsi::Value::null();
67
+ }
68
+ };
69
+ } // namespace margelo
@@ -0,0 +1,76 @@
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 GPUExtent3DDict {
17
+ public:
18
+ wgpu::Extent3DDict *getInstance() { return &_instance; }
19
+
20
+ wgpu::Extent3DDict _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUExtent3DDict>> {
27
+ static std::shared_ptr<rnwgpu::GPUExtent3DDict>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUExtent3DDict>();
30
+ if (!outOfBounds && arg.isObject()) {
31
+ auto value = arg.getObject(runtime);
32
+ if (value.hasProperty(runtime, "width")) {
33
+ auto width = value.getProperty(runtime, "width");
34
+
35
+ if (width.isUndefined()) {
36
+ throw std::runtime_error(
37
+ "Property GPUExtent3DDict::width is required");
38
+ }
39
+ } else {
40
+ throw std::runtime_error(
41
+ "Property GPUExtent3DDict::width is not defined");
42
+ }
43
+ if (value.hasProperty(runtime, "height")) {
44
+ auto height = value.getProperty(runtime, "height");
45
+
46
+ if (height.isNumber()) {
47
+ result->_instance.height =
48
+ static_cast<wgpu::IntegerCoordinate>(height.getNumber());
49
+ }
50
+ }
51
+ if (value.hasProperty(runtime, "depthOrArrayLayers")) {
52
+ auto depthOrArrayLayers =
53
+ value.getProperty(runtime, "depthOrArrayLayers");
54
+
55
+ if (depthOrArrayLayers.isNumber()) {
56
+ result->_instance.depthOrArrayLayers =
57
+ static_cast<wgpu::IntegerCoordinate>(
58
+ depthOrArrayLayers.getNumber());
59
+ }
60
+ }
61
+ }
62
+ rnwgpu::Logger::logToConsole("GPUExtent3DDict::width = %f",
63
+ result->_instance.width);
64
+ rnwgpu::Logger::logToConsole("GPUExtent3DDict::height = %f",
65
+ result->_instance.height);
66
+ rnwgpu::Logger::logToConsole("GPUExtent3DDict::depthOrArrayLayers = %f",
67
+ result->_instance.depthOrArrayLayers);
68
+ return result;
69
+ }
70
+ static jsi::Value toJSI(jsi::Runtime &runtime,
71
+ std::shared_ptr<rnwgpu::GPUExtent3DDict> arg) {
72
+ // No conversions here
73
+ return jsi::Value::null();
74
+ }
75
+ };
76
+ } // namespace margelo
@@ -0,0 +1,91 @@
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 GPUExtent3DDictStrict {
17
+ public:
18
+ wgpu::Extent3DDictStrict *getInstance() { return &_instance; }
19
+
20
+ wgpu::Extent3DDictStrict _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUExtent3DDictStrict>> {
28
+ static std::shared_ptr<rnwgpu::GPUExtent3DDictStrict>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUExtent3DDictStrict>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "depth")) {
34
+ auto depth = value.getProperty(runtime, "depth");
35
+
36
+ if (depth.isUndefined()) {
37
+ throw std::runtime_error(
38
+ "Property GPUExtent3DDictStrict::depth is required");
39
+ }
40
+ } else {
41
+ throw std::runtime_error(
42
+ "Property GPUExtent3DDictStrict::depth is not defined");
43
+ }
44
+ if (value.hasProperty(runtime, "width")) {
45
+ auto width = value.getProperty(runtime, "width");
46
+
47
+ if (width.isUndefined()) {
48
+ throw std::runtime_error(
49
+ "Property GPUExtent3DDictStrict::width is required");
50
+ }
51
+ } else {
52
+ throw std::runtime_error(
53
+ "Property GPUExtent3DDictStrict::width is not defined");
54
+ }
55
+ if (value.hasProperty(runtime, "height")) {
56
+ auto height = value.getProperty(runtime, "height");
57
+
58
+ if (height.isNumber()) {
59
+ result->_instance.height =
60
+ static_cast<wgpu::IntegerCoordinate>(height.getNumber());
61
+ }
62
+ }
63
+ if (value.hasProperty(runtime, "depthOrArrayLayers")) {
64
+ auto depthOrArrayLayers =
65
+ value.getProperty(runtime, "depthOrArrayLayers");
66
+
67
+ if (depthOrArrayLayers.isNumber()) {
68
+ result->_instance.depthOrArrayLayers =
69
+ static_cast<wgpu::IntegerCoordinate>(
70
+ depthOrArrayLayers.getNumber());
71
+ }
72
+ }
73
+ }
74
+ rnwgpu::Logger::logToConsole("GPUExtent3DDictStrict::depth = %f",
75
+ result->_instance.depth);
76
+ rnwgpu::Logger::logToConsole("GPUExtent3DDictStrict::width = %f",
77
+ result->_instance.width);
78
+ rnwgpu::Logger::logToConsole("GPUExtent3DDictStrict::height = %f",
79
+ result->_instance.height);
80
+ rnwgpu::Logger::logToConsole(
81
+ "GPUExtent3DDictStrict::depthOrArrayLayers = %f",
82
+ result->_instance.depthOrArrayLayers);
83
+ return result;
84
+ }
85
+ static jsi::Value toJSI(jsi::Runtime &runtime,
86
+ std::shared_ptr<rnwgpu::GPUExtent3DDictStrict> arg) {
87
+ // No conversions here
88
+ return jsi::Value::null();
89
+ }
90
+ };
91
+ } // namespace margelo
@@ -0,0 +1,44 @@
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 GPUExternalTextureBindingLayout {
17
+ public:
18
+ wgpu::ExternalTextureBindingLayout *getInstance() { return &_instance; }
19
+
20
+ wgpu::ExternalTextureBindingLayout _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUExternalTextureBindingLayout>> {
28
+ static std::shared_ptr<rnwgpu::GPUExternalTextureBindingLayout>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUExternalTextureBindingLayout>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ }
34
+
35
+ return result;
36
+ }
37
+ static jsi::Value
38
+ toJSI(jsi::Runtime &runtime,
39
+ std::shared_ptr<rnwgpu::GPUExternalTextureBindingLayout> arg) {
40
+ // No conversions here
41
+ return jsi::Value::null();
42
+ }
43
+ };
44
+ } // 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 GPUExternalTextureDescriptor {
17
+ public:
18
+ wgpu::ExternalTextureDescriptor *getInstance() { return &_instance; }
19
+
20
+ wgpu::ExternalTextureDescriptor _instance;
21
+
22
+ std::string label;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <>
29
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor>> {
30
+ static std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor>
31
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
32
+ auto result = std::make_unique<rnwgpu::GPUExternalTextureDescriptor>();
33
+ if (!outOfBounds && arg.isObject()) {
34
+ auto value = arg.getObject(runtime);
35
+ if (value.hasProperty(runtime, "source")) {
36
+ auto source = value.getProperty(runtime, "source");
37
+
38
+ if (source.isUndefined()) {
39
+ throw std::runtime_error(
40
+ "Property GPUExternalTextureDescriptor::source is required");
41
+ }
42
+ } else {
43
+ throw std::runtime_error(
44
+ "Property GPUExternalTextureDescriptor::source is not defined");
45
+ }
46
+ if (value.hasProperty(runtime, "colorSpace")) {
47
+ auto colorSpace = value.getProperty(runtime, "colorSpace");
48
+ }
49
+ if (value.hasProperty(runtime, "label")) {
50
+ auto label = value.getProperty(runtime, "label");
51
+
52
+ if (label.isString()) {
53
+ auto str = label.asString(runtime).utf8(runtime);
54
+ result->label = str;
55
+ result->_instance.label = result->label.c_str();
56
+ }
57
+ }
58
+ }
59
+ rnwgpu::Logger::logToConsole("GPUExternalTextureDescriptor::source = %f",
60
+ result->_instance.source);
61
+ rnwgpu::Logger::logToConsole(
62
+ "GPUExternalTextureDescriptor::colorSpace = %f",
63
+ result->_instance.colorSpace);
64
+ rnwgpu::Logger::logToConsole("GPUExternalTextureDescriptor::label = %f",
65
+ result->_instance.label);
66
+ return result;
67
+ }
68
+ static jsi::Value
69
+ toJSI(jsi::Runtime &runtime,
70
+ std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor> arg) {
71
+ // No conversions here
72
+ return jsi::Value::null();
73
+ }
74
+ };
75
+ } // namespace margelo
@@ -0,0 +1,85 @@
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 GPUFragmentState {
17
+ public:
18
+ wgpu::FragmentState *getInstance() { return &_instance; }
19
+
20
+ wgpu::FragmentState _instance;
21
+
22
+ std::string entryPoint;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUFragmentState>> {
29
+ static std::shared_ptr<rnwgpu::GPUFragmentState>
30
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
31
+ auto result = std::make_unique<rnwgpu::GPUFragmentState>();
32
+ if (!outOfBounds && arg.isObject()) {
33
+ auto value = arg.getObject(runtime);
34
+ if (value.hasProperty(runtime, "targets")) {
35
+ auto targets = value.getProperty(runtime, "targets");
36
+
37
+ if (targets.isUndefined()) {
38
+ throw std::runtime_error(
39
+ "Property GPUFragmentState::targets is required");
40
+ }
41
+ } else {
42
+ throw std::runtime_error(
43
+ "Property GPUFragmentState::targets is not defined");
44
+ }
45
+ if (value.hasProperty(runtime, "module")) {
46
+ auto module = value.getProperty(runtime, "module");
47
+
48
+ if (module.isUndefined()) {
49
+ throw std::runtime_error(
50
+ "Property GPUFragmentState::module is required");
51
+ }
52
+ } else {
53
+ throw std::runtime_error(
54
+ "Property GPUFragmentState::module is not defined");
55
+ }
56
+ if (value.hasProperty(runtime, "entryPoint")) {
57
+ auto entryPoint = value.getProperty(runtime, "entryPoint");
58
+
59
+ if (entryPoint.isString()) {
60
+ auto str = entryPoint.asString(runtime).utf8(runtime);
61
+ result->entryPoint = str;
62
+ result->_instance.entryPoint = result->entryPoint.c_str();
63
+ }
64
+ }
65
+ if (value.hasProperty(runtime, "constants")) {
66
+ auto constants = value.getProperty(runtime, "constants");
67
+ }
68
+ }
69
+ rnwgpu::Logger::logToConsole("GPUFragmentState::targets = %f",
70
+ result->_instance.targets);
71
+ rnwgpu::Logger::logToConsole("GPUFragmentState::module = %f",
72
+ result->_instance.module);
73
+ rnwgpu::Logger::logToConsole("GPUFragmentState::entryPoint = %f",
74
+ result->_instance.entryPoint);
75
+ rnwgpu::Logger::logToConsole("GPUFragmentState::constants = %f",
76
+ result->_instance.constants);
77
+ return result;
78
+ }
79
+ static jsi::Value toJSI(jsi::Runtime &runtime,
80
+ std::shared_ptr<rnwgpu::GPUFragmentState> arg) {
81
+ // No conversions here
82
+ return jsi::Value::null();
83
+ }
84
+ };
85
+ } // namespace margelo