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,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 GPUVertexAttribute {
17
+ public:
18
+ wgpu::VertexAttribute *getInstance() { return &_instance; }
19
+
20
+ wgpu::VertexAttribute _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUVertexAttribute>> {
27
+ static std::shared_ptr<rnwgpu::GPUVertexAttribute>
28
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
29
+ auto result = std::make_unique<rnwgpu::GPUVertexAttribute>();
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 GPUVertexAttribute::format is required");
38
+ }
39
+ } else {
40
+ throw std::runtime_error(
41
+ "Property GPUVertexAttribute::format is not defined");
42
+ }
43
+ if (value.hasProperty(runtime, "offset")) {
44
+ auto offset = value.getProperty(runtime, "offset");
45
+
46
+ if (offset.isUndefined()) {
47
+ throw std::runtime_error(
48
+ "Property GPUVertexAttribute::offset is required");
49
+ }
50
+ } else {
51
+ throw std::runtime_error(
52
+ "Property GPUVertexAttribute::offset is not defined");
53
+ }
54
+ if (value.hasProperty(runtime, "shaderLocation")) {
55
+ auto shaderLocation = value.getProperty(runtime, "shaderLocation");
56
+
57
+ if (shaderLocation.isUndefined()) {
58
+ throw std::runtime_error(
59
+ "Property GPUVertexAttribute::shaderLocation is required");
60
+ }
61
+ } else {
62
+ throw std::runtime_error(
63
+ "Property GPUVertexAttribute::shaderLocation is not defined");
64
+ }
65
+ }
66
+ rnwgpu::Logger::logToConsole("GPUVertexAttribute::format = %f",
67
+ result->_instance.format);
68
+ rnwgpu::Logger::logToConsole("GPUVertexAttribute::offset = %f",
69
+ result->_instance.offset);
70
+ rnwgpu::Logger::logToConsole("GPUVertexAttribute::shaderLocation = %f",
71
+ result->_instance.shaderLocation);
72
+ return result;
73
+ }
74
+ static jsi::Value toJSI(jsi::Runtime &runtime,
75
+ std::shared_ptr<rnwgpu::GPUVertexAttribute> arg) {
76
+ // No conversions here
77
+ return jsi::Value::null();
78
+ }
79
+ };
80
+ } // namespace margelo
@@ -0,0 +1,73 @@
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 GPUVertexBufferLayout {
17
+ public:
18
+ wgpu::VertexBufferLayout *getInstance() { return &_instance; }
19
+
20
+ wgpu::VertexBufferLayout _instance;
21
+ };
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ template <>
27
+ struct JSIConverter<std::shared_ptr<rnwgpu::GPUVertexBufferLayout>> {
28
+ static std::shared_ptr<rnwgpu::GPUVertexBufferLayout>
29
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
30
+ auto result = std::make_unique<rnwgpu::GPUVertexBufferLayout>();
31
+ if (!outOfBounds && arg.isObject()) {
32
+ auto value = arg.getObject(runtime);
33
+ if (value.hasProperty(runtime, "arrayStride")) {
34
+ auto arrayStride = value.getProperty(runtime, "arrayStride");
35
+
36
+ if (arrayStride.isUndefined()) {
37
+ throw std::runtime_error(
38
+ "Property GPUVertexBufferLayout::arrayStride is required");
39
+ }
40
+ } else {
41
+ throw std::runtime_error(
42
+ "Property GPUVertexBufferLayout::arrayStride is not defined");
43
+ }
44
+ if (value.hasProperty(runtime, "stepMode")) {
45
+ auto stepMode = value.getProperty(runtime, "stepMode");
46
+ }
47
+ if (value.hasProperty(runtime, "attributes")) {
48
+ auto attributes = value.getProperty(runtime, "attributes");
49
+
50
+ if (attributes.isUndefined()) {
51
+ throw std::runtime_error(
52
+ "Property GPUVertexBufferLayout::attributes is required");
53
+ }
54
+ } else {
55
+ throw std::runtime_error(
56
+ "Property GPUVertexBufferLayout::attributes is not defined");
57
+ }
58
+ }
59
+ rnwgpu::Logger::logToConsole("GPUVertexBufferLayout::arrayStride = %f",
60
+ result->_instance.arrayStride);
61
+ rnwgpu::Logger::logToConsole("GPUVertexBufferLayout::stepMode = %f",
62
+ result->_instance.stepMode);
63
+ rnwgpu::Logger::logToConsole("GPUVertexBufferLayout::attributes = %f",
64
+ result->_instance.attributes);
65
+ return result;
66
+ }
67
+ static jsi::Value toJSI(jsi::Runtime &runtime,
68
+ std::shared_ptr<rnwgpu::GPUVertexBufferLayout> arg) {
69
+ // No conversions here
70
+ return jsi::Value::null();
71
+ }
72
+ };
73
+ } // namespace margelo
@@ -0,0 +1,77 @@
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 GPUVertexState {
17
+ public:
18
+ wgpu::VertexState *getInstance() { return &_instance; }
19
+
20
+ wgpu::VertexState _instance;
21
+
22
+ std::string entryPoint;
23
+ };
24
+ } // namespace rnwgpu
25
+
26
+ namespace margelo {
27
+
28
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUVertexState>> {
29
+ static std::shared_ptr<rnwgpu::GPUVertexState>
30
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
31
+ auto result = std::make_unique<rnwgpu::GPUVertexState>();
32
+ if (!outOfBounds && arg.isObject()) {
33
+ auto value = arg.getObject(runtime);
34
+ if (value.hasProperty(runtime, "buffers")) {
35
+ auto buffers = value.getProperty(runtime, "buffers");
36
+ }
37
+ if (value.hasProperty(runtime, "module")) {
38
+ auto module = value.getProperty(runtime, "module");
39
+
40
+ if (module.isUndefined()) {
41
+ throw std::runtime_error(
42
+ "Property GPUVertexState::module is required");
43
+ }
44
+ } else {
45
+ throw std::runtime_error(
46
+ "Property GPUVertexState::module is not defined");
47
+ }
48
+ if (value.hasProperty(runtime, "entryPoint")) {
49
+ auto entryPoint = value.getProperty(runtime, "entryPoint");
50
+
51
+ if (entryPoint.isString()) {
52
+ auto str = entryPoint.asString(runtime).utf8(runtime);
53
+ result->entryPoint = str;
54
+ result->_instance.entryPoint = result->entryPoint.c_str();
55
+ }
56
+ }
57
+ if (value.hasProperty(runtime, "constants")) {
58
+ auto constants = value.getProperty(runtime, "constants");
59
+ }
60
+ }
61
+ rnwgpu::Logger::logToConsole("GPUVertexState::buffers = %f",
62
+ result->_instance.buffers);
63
+ rnwgpu::Logger::logToConsole("GPUVertexState::module = %f",
64
+ result->_instance.module);
65
+ rnwgpu::Logger::logToConsole("GPUVertexState::entryPoint = %f",
66
+ result->_instance.entryPoint);
67
+ rnwgpu::Logger::logToConsole("GPUVertexState::constants = %f",
68
+ result->_instance.constants);
69
+ return result;
70
+ }
71
+ static jsi::Value toJSI(jsi::Runtime &runtime,
72
+ std::shared_ptr<rnwgpu::GPUVertexState> arg) {
73
+ // No conversions here
74
+ return jsi::Value::null();
75
+ }
76
+ };
77
+ } // namespace margelo