react-native-wgpu 0.3.1 → 0.4.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 (116) hide show
  1. package/README.md +7 -5
  2. package/apple/MetalView.mm +1 -1
  3. package/cpp/rnwgpu/api/GPU.h +0 -1
  4. package/cpp/rnwgpu/api/GPUAdapter.cpp +7 -7
  5. package/cpp/webgpu/webgpu.h +4827 -5
  6. package/cpp/webgpu/webgpu_cpp.h +10140 -5
  7. package/cpp/webgpu/webgpu_cpp_print.h +2687 -5
  8. package/lib/commonjs/Canvas.js +10 -3
  9. package/lib/commonjs/Canvas.js.map +1 -1
  10. package/lib/commonjs/WebGPUViewNativeComponent.web.js +99 -0
  11. package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +1 -0
  12. package/lib/commonjs/WebPolyfillGPUModule.js +40 -0
  13. package/lib/commonjs/WebPolyfillGPUModule.js.map +1 -0
  14. package/lib/commonjs/index.js +4 -208
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/main/index.js +227 -0
  17. package/lib/commonjs/main/index.js.map +1 -0
  18. package/lib/commonjs/main/index.web.js +51 -0
  19. package/lib/commonjs/main/index.web.js.map +1 -0
  20. package/lib/commonjs/types.js +2 -0
  21. package/lib/commonjs/types.js.map +1 -0
  22. package/lib/commonjs/utils.js +11 -0
  23. package/lib/commonjs/utils.js.map +1 -0
  24. package/lib/module/Canvas.js +11 -4
  25. package/lib/module/Canvas.js.map +1 -1
  26. package/lib/module/WebGPUViewNativeComponent.web.js +93 -0
  27. package/lib/module/WebGPUViewNativeComponent.web.js.map +1 -0
  28. package/lib/module/WebPolyfillGPUModule.js +38 -0
  29. package/lib/module/WebPolyfillGPUModule.js.map +1 -0
  30. package/lib/module/index.js +3 -160
  31. package/lib/module/index.js.map +1 -1
  32. package/lib/module/main/index.js +168 -0
  33. package/lib/module/main/index.js.map +1 -0
  34. package/lib/module/main/index.web.js +8 -0
  35. package/lib/module/main/index.web.js.map +1 -0
  36. package/lib/module/types.js +2 -0
  37. package/lib/module/types.js.map +1 -0
  38. package/lib/module/utils.js +5 -0
  39. package/lib/module/utils.js.map +1 -0
  40. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts +5 -0
  41. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +1 -0
  42. package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts +2 -0
  43. package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts.map +1 -0
  44. package/lib/typescript/lib/commonjs/index.d.ts +0 -1
  45. package/lib/typescript/lib/commonjs/main/index.d.ts +3 -0
  46. package/lib/typescript/lib/commonjs/main/index.d.ts.map +1 -0
  47. package/lib/typescript/lib/commonjs/main/index.web.d.ts +2 -0
  48. package/lib/typescript/lib/commonjs/main/index.web.d.ts.map +1 -0
  49. package/lib/typescript/lib/commonjs/types.d.ts +1 -0
  50. package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
  51. package/lib/typescript/lib/commonjs/utils.d.ts +3 -0
  52. package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -0
  53. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  54. package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts +2 -0
  55. package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts.map +1 -0
  56. package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts +2 -0
  57. package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts.map +1 -0
  58. package/lib/typescript/lib/module/index.d.ts +1 -5
  59. package/lib/typescript/lib/module/main/index.d.ts +6 -0
  60. package/lib/typescript/lib/module/main/index.d.ts.map +1 -0
  61. package/lib/typescript/lib/module/main/index.web.d.ts +5 -0
  62. package/lib/typescript/lib/module/main/index.web.d.ts.map +1 -0
  63. package/lib/typescript/lib/module/types.d.ts +1 -0
  64. package/lib/typescript/lib/module/types.d.ts.map +1 -0
  65. package/lib/typescript/lib/module/utils.d.ts +2 -0
  66. package/lib/typescript/lib/module/utils.d.ts.map +1 -0
  67. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  68. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +1 -1
  69. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  70. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +118 -0
  71. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -0
  72. package/lib/typescript/src/WebPolyfillGPUModule.d.ts +2 -0
  73. package/lib/typescript/src/WebPolyfillGPUModule.d.ts.map +1 -0
  74. package/lib/typescript/src/index.d.ts +16 -5
  75. package/lib/typescript/src/index.d.ts.map +1 -1
  76. package/lib/typescript/src/main/index.d.ts +6 -0
  77. package/lib/typescript/src/main/index.d.ts.map +1 -0
  78. package/lib/typescript/src/main/index.web.d.ts +6 -0
  79. package/lib/typescript/src/main/index.web.d.ts.map +1 -0
  80. package/lib/typescript/src/types.d.ts +19 -0
  81. package/lib/typescript/src/types.d.ts.map +1 -0
  82. package/lib/typescript/src/utils.d.ts +2 -0
  83. package/lib/typescript/src/utils.d.ts.map +1 -0
  84. package/package.json +2 -1
  85. package/src/Canvas.tsx +12 -4
  86. package/src/WebGPUViewNativeComponent.ts +1 -1
  87. package/src/WebGPUViewNativeComponent.web.ts +108 -0
  88. package/src/WebPolyfillGPUModule.ts +53 -0
  89. package/src/index.tsx +25 -196
  90. package/src/main/index.tsx +204 -0
  91. package/src/main/index.web.tsx +8 -0
  92. package/src/types.ts +20 -0
  93. package/src/utils.ts +4 -0
  94. package/cpp/dawn/dawn_proc_table.h +0 -313
  95. package/cpp/dawn/native/DawnNative.h +0 -361
  96. package/cpp/dawn/native/NullBackend.h +0 -39
  97. package/cpp/dawn/native/OpenGLBackend.h +0 -82
  98. package/cpp/dawn/native/VulkanBackend.h +0 -183
  99. package/cpp/dawn/native/dawn_native_export.h +0 -49
  100. package/cpp/dawn/webgpu.h +0 -4855
  101. package/cpp/dawn/webgpu_cpp.h +0 -10168
  102. package/cpp/dawn/webgpu_cpp_print.h +0 -2715
  103. package/cpp/dawn/wire/client/webgpu.h +0 -354
  104. package/cpp/dawn/wire/client/webgpu_cpp.h +0 -10343
  105. package/cpp/dawn/wire/client/webgpu_cpp_print.h +0 -2715
  106. package/lib/commonjs/WebGPUView.js +0 -2
  107. package/lib/commonjs/WebGPUView.js.map +0 -1
  108. package/lib/module/WebGPUView.js +0 -2
  109. package/lib/module/WebGPUView.js.map +0 -1
  110. package/lib/typescript/lib/commonjs/WebGPUView.d.ts +0 -1
  111. package/lib/typescript/lib/commonjs/WebGPUView.d.ts.map +0 -1
  112. package/lib/typescript/lib/module/WebGPUView.d.ts +0 -1
  113. package/lib/typescript/lib/module/WebGPUView.d.ts.map +0 -1
  114. package/lib/typescript/src/WebGPUView.d.ts +0 -1
  115. package/lib/typescript/src/WebGPUView.d.ts.map +0 -1
  116. package/src/WebGPUView.tsx +0 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # React Native WebGPU
2
2
 
3
- React Native implementation of WebGPU using [Dawn](https://dawn.googlesource.com/dawn).
4
- This is currently a technical preview for early adopters.
3
+ React Native implementation of WebGPU using [Dawn](https://dawn.googlesource.com/dawn).
4
+ This is currently a technical preview for early adopters.
5
5
 
6
6
  React Native WebGPU requires React Native 0.81 or newer and doesn't run on legacy architecture.
7
7
 
@@ -13,6 +13,8 @@ Please note that the package name is `react-native-wgpu`.
13
13
  npm install react-native-wgpu
14
14
  ```
15
15
 
16
+ Note that if you use pnpm, you MUST use a `node-linker = hoisted` so that the external reference to the Dawn webgpu library can successfully link it.
17
+
16
18
  Below are some examples from the [example app](/apps/example/).
17
19
 
18
20
  https://github.com/user-attachments/assets/116a41b2-2cf8-49f1-9f16-a5c83637c198
@@ -156,8 +158,8 @@ From there you will be able to run the example app properly.
156
158
 
157
159
  ## Similarities and Differences with the Web
158
160
 
159
- The API has been designed to be completely symmetric with the Web.
160
- For instance, you can access the WebGPU context synchronously, as well as the canvas size.
161
+ The API has been designed to be completely symmetric with the Web.
162
+ For instance, you can access the WebGPU context synchronously, as well as the canvas size.
161
163
  Pixel density and canvas resizing are handled exactly like on the Web as well.
162
164
 
163
165
  ```tsx
@@ -171,7 +173,7 @@ ctx.canvas.height = ctx.canvas.clientHeight * PixelRatio.get();
171
173
 
172
174
  ### Frame Scheduling
173
175
 
174
- In React Native, we want to keep frame presentation as a manual operation as we plan to provide more advanced rendering options that are React Native specific.
176
+ In React Native, we want to keep frame presentation as a manual operation as we plan to provide more advanced rendering options that are React Native specific.
175
177
  This means that when you are ready to present a frame, you need to call `present` on the context.
176
178
 
177
179
  ```tsx
@@ -1,5 +1,5 @@
1
1
  #import "MetalView.h"
2
- #import "webgpu_cpp.h"
2
+ #import "webgpu/webgpu_cpp.h"
3
3
 
4
4
  @implementation MetalView {
5
5
  BOOL _isConfigured;
@@ -12,7 +12,6 @@
12
12
  #include "rnwgpu/async/AsyncRunner.h"
13
13
  #include "rnwgpu/async/AsyncTaskHandle.h"
14
14
 
15
- #include "dawn/native/DawnNative.h"
16
15
  #include "webgpu/webgpu_cpp.h"
17
16
 
18
17
  #include "GPUAdapter.h"
@@ -82,16 +82,16 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
82
82
  auto creationRuntime = getCreationRuntime();
83
83
  return _async->postTask(
84
84
  [this, aDescriptor, descriptor, label = std::move(label),
85
- deviceLostBinding,
86
- creationRuntime](const async::AsyncTaskHandle::ResolveFunction &resolve,
87
- const async::AsyncTaskHandle::RejectFunction &reject) {
85
+ deviceLostBinding, creationRuntime](
86
+ const async::AsyncTaskHandle::ResolveFunction &resolve,
87
+ const async::AsyncTaskHandle::RejectFunction &reject) {
88
88
  (void)descriptor;
89
89
  _instance.RequestDevice(
90
90
  &aDescriptor, wgpu::CallbackMode::AllowProcessEvents,
91
- [asyncRunner = _async, resolve, reject, label, creationRuntime,
92
- deviceLostBinding](wgpu::RequestDeviceStatus status,
93
- wgpu::Device device,
94
- wgpu::StringView message) mutable {
91
+ [asyncRunner = _async, resolve, reject, label,
92
+ creationRuntime, deviceLostBinding](
93
+ wgpu::RequestDeviceStatus status, wgpu::Device device,
94
+ wgpu::StringView message) mutable {
95
95
  if (message.length) {
96
96
  fprintf(stderr, "%s", message.data);
97
97
  }