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,100 @@
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 GPURenderPassDescriptor {
17
+ public:
18
+ wgpu::RenderPassDescriptor *getInstance() { return &_instance; }
19
+
20
+ wgpu::RenderPassDescriptor _instance;
21
+
22
+ std::string label;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <>
29
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPassDescriptor>> {
30
+ static std::shared_ptr<rnwgpu::GPURenderPassDescriptor>
31
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
32
+ auto result = std::make_unique<rnwgpu::GPURenderPassDescriptor>();
33
+ if (!outOfBounds && arg.isObject()) {
34
+ auto value = arg.getObject(runtime);
35
+ if (value.hasProperty(runtime, "colorAttachments")) {
36
+ auto colorAttachments = value.getProperty(runtime, "colorAttachments");
37
+
38
+ if (colorAttachments.isUndefined()) {
39
+ throw std::runtime_error(
40
+ "Property GPURenderPassDescriptor::colorAttachments is required");
41
+ }
42
+ } else {
43
+ throw std::runtime_error(
44
+ "Property GPURenderPassDescriptor::colorAttachments is not "
45
+ "defined");
46
+ }
47
+ if (value.hasProperty(runtime, "depthStencilAttachment")) {
48
+ auto depthStencilAttachment =
49
+ value.getProperty(runtime, "depthStencilAttachment");
50
+ }
51
+ if (value.hasProperty(runtime, "occlusionQuerySet")) {
52
+ auto occlusionQuerySet =
53
+ value.getProperty(runtime, "occlusionQuerySet");
54
+ }
55
+ if (value.hasProperty(runtime, "timestampWrites")) {
56
+ auto timestampWrites = value.getProperty(runtime, "timestampWrites");
57
+ }
58
+ if (value.hasProperty(runtime, "maxDrawCount")) {
59
+ auto maxDrawCount = value.getProperty(runtime, "maxDrawCount");
60
+
61
+ if (maxDrawCount.isNumber()) {
62
+ result->_instance.maxDrawCount = maxDrawCount.getNumber();
63
+ }
64
+ }
65
+ if (value.hasProperty(runtime, "label")) {
66
+ auto label = value.getProperty(runtime, "label");
67
+
68
+ if (label.isString()) {
69
+ auto str = label.asString(runtime).utf8(runtime);
70
+ result->label = str;
71
+ result->_instance.label = result->label.c_str();
72
+ }
73
+ }
74
+ }
75
+ rnwgpu::Logger::logToConsole(
76
+ "GPURenderPassDescriptor::colorAttachments = %f",
77
+ result->_instance.colorAttachments);
78
+ rnwgpu::Logger::logToConsole(
79
+ "GPURenderPassDescriptor::depthStencilAttachment = %f",
80
+ result->_instance.depthStencilAttachment);
81
+ rnwgpu::Logger::logToConsole(
82
+ "GPURenderPassDescriptor::occlusionQuerySet = %f",
83
+ result->_instance.occlusionQuerySet);
84
+ rnwgpu::Logger::logToConsole(
85
+ "GPURenderPassDescriptor::timestampWrites = %f",
86
+ result->_instance.timestampWrites);
87
+ rnwgpu::Logger::logToConsole("GPURenderPassDescriptor::maxDrawCount = %f",
88
+ result->_instance.maxDrawCount);
89
+ rnwgpu::Logger::logToConsole("GPURenderPassDescriptor::label = %f",
90
+ result->_instance.label);
91
+ return result;
92
+ }
93
+ static jsi::Value
94
+ toJSI(jsi::Runtime &runtime,
95
+ std::shared_ptr<rnwgpu::GPURenderPassDescriptor> arg) {
96
+ // No conversions here
97
+ return jsi::Value::null();
98
+ }
99
+ };
100
+ } // namespace margelo
@@ -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 GPURenderPassLayout {
17
+ public:
18
+ wgpu::RenderPassLayout *getInstance() { return &_instance; }
19
+
20
+ wgpu::RenderPassLayout _instance;
21
+
22
+ std::string label;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPassLayout>> {
29
+ static std::shared_ptr<rnwgpu::GPURenderPassLayout>
30
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
31
+ auto result = std::make_unique<rnwgpu::GPURenderPassLayout>();
32
+ if (!outOfBounds && arg.isObject()) {
33
+ auto value = arg.getObject(runtime);
34
+ if (value.hasProperty(runtime, "colorFormats")) {
35
+ auto colorFormats = value.getProperty(runtime, "colorFormats");
36
+
37
+ if (colorFormats.isUndefined()) {
38
+ throw std::runtime_error(
39
+ "Property GPURenderPassLayout::colorFormats is required");
40
+ }
41
+ } else {
42
+ throw std::runtime_error(
43
+ "Property GPURenderPassLayout::colorFormats is not defined");
44
+ }
45
+ if (value.hasProperty(runtime, "depthStencilFormat")) {
46
+ auto depthStencilFormat =
47
+ value.getProperty(runtime, "depthStencilFormat");
48
+ }
49
+ if (value.hasProperty(runtime, "sampleCount")) {
50
+ auto sampleCount = value.getProperty(runtime, "sampleCount");
51
+
52
+ if (sampleCount.isNumber()) {
53
+ result->_instance.sampleCount =
54
+ static_cast<wgpu::Size32>(sampleCount.getNumber());
55
+ }
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("GPURenderPassLayout::colorFormats = %f",
68
+ result->_instance.colorFormats);
69
+ rnwgpu::Logger::logToConsole("GPURenderPassLayout::depthStencilFormat = %f",
70
+ result->_instance.depthStencilFormat);
71
+ rnwgpu::Logger::logToConsole("GPURenderPassLayout::sampleCount = %f",
72
+ result->_instance.sampleCount);
73
+ rnwgpu::Logger::logToConsole("GPURenderPassLayout::label = %f",
74
+ result->_instance.label);
75
+ return result;
76
+ }
77
+ static jsi::Value toJSI(jsi::Runtime &runtime,
78
+ std::shared_ptr<rnwgpu::GPURenderPassLayout> arg) {
79
+ // No conversions here
80
+ return jsi::Value::null();
81
+ }
82
+ };
83
+ } // namespace margelo
@@ -0,0 +1,80 @@
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 GPURenderPassTimestampWrites {
17
+ public:
18
+ wgpu::RenderPassTimestampWrites *getInstance() { return &_instance; }
19
+
20
+ wgpu::RenderPassTimestampWrites _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPassTimestampWrites>> {
28
+ static std::shared_ptr<rnwgpu::GPURenderPassTimestampWrites>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPURenderPassTimestampWrites>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "querySet")) {
34
+ auto querySet = value.getProperty(runtime, "querySet");
35
+
36
+ if (querySet.isUndefined()) {
37
+ throw std::runtime_error(
38
+ "Property GPURenderPassTimestampWrites::querySet is required");
39
+ }
40
+ } else {
41
+ throw std::runtime_error(
42
+ "Property GPURenderPassTimestampWrites::querySet is not defined");
43
+ }
44
+ if (value.hasProperty(runtime, "beginningOfPassWriteIndex")) {
45
+ auto beginningOfPassWriteIndex =
46
+ value.getProperty(runtime, "beginningOfPassWriteIndex");
47
+
48
+ if (beginningOfPassWriteIndex.isNumber()) {
49
+ result->_instance.beginningOfPassWriteIndex =
50
+ static_cast<wgpu::Size32>(beginningOfPassWriteIndex.getNumber());
51
+ }
52
+ }
53
+ if (value.hasProperty(runtime, "endOfPassWriteIndex")) {
54
+ auto endOfPassWriteIndex =
55
+ value.getProperty(runtime, "endOfPassWriteIndex");
56
+
57
+ if (endOfPassWriteIndex.isNumber()) {
58
+ result->_instance.endOfPassWriteIndex =
59
+ static_cast<wgpu::Size32>(endOfPassWriteIndex.getNumber());
60
+ }
61
+ }
62
+ }
63
+ rnwgpu::Logger::logToConsole("GPURenderPassTimestampWrites::querySet = %f",
64
+ result->_instance.querySet);
65
+ rnwgpu::Logger::logToConsole(
66
+ "GPURenderPassTimestampWrites::beginningOfPassWriteIndex = %f",
67
+ result->_instance.beginningOfPassWriteIndex);
68
+ rnwgpu::Logger::logToConsole(
69
+ "GPURenderPassTimestampWrites::endOfPassWriteIndex = %f",
70
+ result->_instance.endOfPassWriteIndex);
71
+ return result;
72
+ }
73
+ static jsi::Value
74
+ toJSI(jsi::Runtime &runtime,
75
+ std::shared_ptr<rnwgpu::GPURenderPassTimestampWrites> arg) {
76
+ // No conversions here
77
+ return jsi::Value::null();
78
+ }
79
+ };
80
+ } // namespace margelo
@@ -0,0 +1,104 @@
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 GPURenderPipelineDescriptor {
17
+ public:
18
+ wgpu::RenderPipelineDescriptor *getInstance() { return &_instance; }
19
+
20
+ wgpu::RenderPipelineDescriptor _instance;
21
+
22
+ std::string label;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <>
29
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPipelineDescriptor>> {
30
+ static std::shared_ptr<rnwgpu::GPURenderPipelineDescriptor>
31
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
32
+ auto result = std::make_unique<rnwgpu::GPURenderPipelineDescriptor>();
33
+ if (!outOfBounds && arg.isObject()) {
34
+ auto value = arg.getObject(runtime);
35
+ if (value.hasProperty(runtime, "vertex")) {
36
+ auto vertex = value.getProperty(runtime, "vertex");
37
+
38
+ if (vertex.isUndefined()) {
39
+ throw std::runtime_error(
40
+ "Property GPURenderPipelineDescriptor::vertex is required");
41
+ }
42
+ } else {
43
+ throw std::runtime_error(
44
+ "Property GPURenderPipelineDescriptor::vertex is not defined");
45
+ }
46
+ if (value.hasProperty(runtime, "primitive")) {
47
+ auto primitive = value.getProperty(runtime, "primitive");
48
+ }
49
+ if (value.hasProperty(runtime, "depthStencil")) {
50
+ auto depthStencil = value.getProperty(runtime, "depthStencil");
51
+ }
52
+ if (value.hasProperty(runtime, "multisample")) {
53
+ auto multisample = value.getProperty(runtime, "multisample");
54
+ }
55
+ if (value.hasProperty(runtime, "fragment")) {
56
+ auto fragment = value.getProperty(runtime, "fragment");
57
+ }
58
+ if (value.hasProperty(runtime, "layout")) {
59
+ auto layout = value.getProperty(runtime, "layout");
60
+
61
+ if (layout.isUndefined()) {
62
+ throw std::runtime_error(
63
+ "Property GPURenderPipelineDescriptor::layout is required");
64
+ }
65
+ } else {
66
+ throw std::runtime_error(
67
+ "Property GPURenderPipelineDescriptor::layout is not defined");
68
+ }
69
+ if (value.hasProperty(runtime, "label")) {
70
+ auto label = value.getProperty(runtime, "label");
71
+
72
+ if (label.isString()) {
73
+ auto str = label.asString(runtime).utf8(runtime);
74
+ result->label = str;
75
+ result->_instance.label = result->label.c_str();
76
+ }
77
+ }
78
+ }
79
+ rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::vertex = %f",
80
+ result->_instance.vertex);
81
+ rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::primitive = %f",
82
+ result->_instance.primitive);
83
+ rnwgpu::Logger::logToConsole(
84
+ "GPURenderPipelineDescriptor::depthStencil = %f",
85
+ result->_instance.depthStencil);
86
+ rnwgpu::Logger::logToConsole(
87
+ "GPURenderPipelineDescriptor::multisample = %f",
88
+ result->_instance.multisample);
89
+ rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::fragment = %f",
90
+ result->_instance.fragment);
91
+ rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::layout = %f",
92
+ result->_instance.layout);
93
+ rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::label = %f",
94
+ result->_instance.label);
95
+ return result;
96
+ }
97
+ static jsi::Value
98
+ toJSI(jsi::Runtime &runtime,
99
+ std::shared_ptr<rnwgpu::GPURenderPipelineDescriptor> arg) {
100
+ // No conversions here
101
+ return jsi::Value::null();
102
+ }
103
+ };
104
+ } // namespace margelo
@@ -0,0 +1,56 @@
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 GPURequestAdapterOptions {
17
+ public:
18
+ wgpu::RequestAdapterOptions *getInstance() { return &_instance; }
19
+
20
+ wgpu::RequestAdapterOptions _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPURequestAdapterOptions>> {
28
+ static std::shared_ptr<rnwgpu::GPURequestAdapterOptions>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPURequestAdapterOptions>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "powerPreference")) {
34
+ auto powerPreference = value.getProperty(runtime, "powerPreference");
35
+ }
36
+ if (value.hasProperty(runtime, "forceFallbackAdapter")) {
37
+ auto forceFallbackAdapter =
38
+ value.getProperty(runtime, "forceFallbackAdapter");
39
+ }
40
+ }
41
+ rnwgpu::Logger::logToConsole(
42
+ "GPURequestAdapterOptions::powerPreference = %f",
43
+ result->_instance.powerPreference);
44
+ rnwgpu::Logger::logToConsole(
45
+ "GPURequestAdapterOptions::forceFallbackAdapter = %f",
46
+ result->_instance.forceFallbackAdapter);
47
+ return result;
48
+ }
49
+ static jsi::Value
50
+ toJSI(jsi::Runtime &runtime,
51
+ std::shared_ptr<rnwgpu::GPURequestAdapterOptions> arg) {
52
+ // No conversions here
53
+ return jsi::Value::null();
54
+ }
55
+ };
56
+ } // namespace margelo
@@ -0,0 +1,48 @@
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 GPUSamplerBindingLayout {
17
+ public:
18
+ wgpu::SamplerBindingLayout *getInstance() { return &_instance; }
19
+
20
+ wgpu::SamplerBindingLayout _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUSamplerBindingLayout>> {
28
+ static std::shared_ptr<rnwgpu::GPUSamplerBindingLayout>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUSamplerBindingLayout>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "type")) {
34
+ auto type = value.getProperty(runtime, "type");
35
+ }
36
+ }
37
+ rnwgpu::Logger::logToConsole("GPUSamplerBindingLayout::type = %f",
38
+ result->_instance.type);
39
+ return result;
40
+ }
41
+ static jsi::Value
42
+ toJSI(jsi::Runtime &runtime,
43
+ std::shared_ptr<rnwgpu::GPUSamplerBindingLayout> arg) {
44
+ // No conversions here
45
+ return jsi::Value::null();
46
+ }
47
+ };
48
+ } // namespace margelo
@@ -0,0 +1,116 @@
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 GPUSamplerDescriptor {
17
+ public:
18
+ wgpu::SamplerDescriptor *getInstance() { return &_instance; }
19
+
20
+ wgpu::SamplerDescriptor _instance;
21
+
22
+ std::string label;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUSamplerDescriptor>> {
29
+ static std::shared_ptr<rnwgpu::GPUSamplerDescriptor>
30
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
31
+ auto result = std::make_unique<rnwgpu::GPUSamplerDescriptor>();
32
+ if (!outOfBounds && arg.isObject()) {
33
+ auto value = arg.getObject(runtime);
34
+ if (value.hasProperty(runtime, "addressModeU")) {
35
+ auto addressModeU = value.getProperty(runtime, "addressModeU");
36
+ }
37
+ if (value.hasProperty(runtime, "addressModeV")) {
38
+ auto addressModeV = value.getProperty(runtime, "addressModeV");
39
+ }
40
+ if (value.hasProperty(runtime, "addressModeW")) {
41
+ auto addressModeW = value.getProperty(runtime, "addressModeW");
42
+ }
43
+ if (value.hasProperty(runtime, "magFilter")) {
44
+ auto magFilter = value.getProperty(runtime, "magFilter");
45
+ }
46
+ if (value.hasProperty(runtime, "minFilter")) {
47
+ auto minFilter = value.getProperty(runtime, "minFilter");
48
+ }
49
+ if (value.hasProperty(runtime, "mipmapFilter")) {
50
+ auto mipmapFilter = value.getProperty(runtime, "mipmapFilter");
51
+ }
52
+ if (value.hasProperty(runtime, "lodMinClamp")) {
53
+ auto lodMinClamp = value.getProperty(runtime, "lodMinClamp");
54
+
55
+ if (lodMinClamp.isNumber()) {
56
+ result->_instance.lodMinClamp = lodMinClamp.getNumber();
57
+ }
58
+ }
59
+ if (value.hasProperty(runtime, "lodMaxClamp")) {
60
+ auto lodMaxClamp = value.getProperty(runtime, "lodMaxClamp");
61
+
62
+ if (lodMaxClamp.isNumber()) {
63
+ result->_instance.lodMaxClamp = lodMaxClamp.getNumber();
64
+ }
65
+ }
66
+ if (value.hasProperty(runtime, "compare")) {
67
+ auto compare = value.getProperty(runtime, "compare");
68
+ }
69
+ if (value.hasProperty(runtime, "maxAnisotropy")) {
70
+ auto maxAnisotropy = value.getProperty(runtime, "maxAnisotropy");
71
+
72
+ if (maxAnisotropy.isNumber()) {
73
+ result->_instance.maxAnisotropy = maxAnisotropy.getNumber();
74
+ }
75
+ }
76
+ if (value.hasProperty(runtime, "label")) {
77
+ auto label = value.getProperty(runtime, "label");
78
+
79
+ if (label.isString()) {
80
+ auto str = label.asString(runtime).utf8(runtime);
81
+ result->label = str;
82
+ result->_instance.label = result->label.c_str();
83
+ }
84
+ }
85
+ }
86
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::addressModeU = %f",
87
+ result->_instance.addressModeU);
88
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::addressModeV = %f",
89
+ result->_instance.addressModeV);
90
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::addressModeW = %f",
91
+ result->_instance.addressModeW);
92
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::magFilter = %f",
93
+ result->_instance.magFilter);
94
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::minFilter = %f",
95
+ result->_instance.minFilter);
96
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::mipmapFilter = %f",
97
+ result->_instance.mipmapFilter);
98
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::lodMinClamp = %f",
99
+ result->_instance.lodMinClamp);
100
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::lodMaxClamp = %f",
101
+ result->_instance.lodMaxClamp);
102
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::compare = %f",
103
+ result->_instance.compare);
104
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::maxAnisotropy = %f",
105
+ result->_instance.maxAnisotropy);
106
+ rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::label = %f",
107
+ result->_instance.label);
108
+ return result;
109
+ }
110
+ static jsi::Value toJSI(jsi::Runtime &runtime,
111
+ std::shared_ptr<rnwgpu::GPUSamplerDescriptor> arg) {
112
+ // No conversions here
113
+ return jsi::Value::null();
114
+ }
115
+ };
116
+ } // namespace margelo
@@ -0,0 +1,64 @@
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 GPUShaderModuleCompilationHint {
17
+ public:
18
+ wgpu::ShaderModuleCompilationHint *getInstance() { return &_instance; }
19
+
20
+ wgpu::ShaderModuleCompilationHint _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUShaderModuleCompilationHint>> {
28
+ static std::shared_ptr<rnwgpu::GPUShaderModuleCompilationHint>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUShaderModuleCompilationHint>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "entryPoint")) {
34
+ auto entryPoint = value.getProperty(runtime, "entryPoint");
35
+
36
+ if (entryPoint.isUndefined()) {
37
+ throw std::runtime_error(
38
+ "Property GPUShaderModuleCompilationHint::entryPoint is "
39
+ "required");
40
+ }
41
+ } else {
42
+ throw std::runtime_error(
43
+ "Property GPUShaderModuleCompilationHint::entryPoint is not "
44
+ "defined");
45
+ }
46
+ if (value.hasProperty(runtime, "layout")) {
47
+ auto layout = value.getProperty(runtime, "layout");
48
+ }
49
+ }
50
+ rnwgpu::Logger::logToConsole(
51
+ "GPUShaderModuleCompilationHint::entryPoint = %f",
52
+ result->_instance.entryPoint);
53
+ rnwgpu::Logger::logToConsole("GPUShaderModuleCompilationHint::layout = %f",
54
+ result->_instance.layout);
55
+ return result;
56
+ }
57
+ static jsi::Value
58
+ toJSI(jsi::Runtime &runtime,
59
+ std::shared_ptr<rnwgpu::GPUShaderModuleCompilationHint> arg) {
60
+ // No conversions here
61
+ return jsi::Value::null();
62
+ }
63
+ };
64
+ } // namespace margelo