react-native-webgpu 0.22.0 → 0.23.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 (129) hide show
  1. package/README.md +15 -2
  2. package/android/CMakeLists.txt +2 -1
  3. package/android/cpp/AndroidAnimationFrameSource.h +136 -0
  4. package/android/cpp/AndroidPlatformContext.h +55 -0
  5. package/android/cpp/cpp-adapter.cpp +148 -2
  6. package/android/src/main/java/com/webgpu/WebGPUModule.java +21 -4
  7. package/android/src/main/java/com/webgpu/WebGPUNativeBufferView.java +370 -0
  8. package/android/src/main/java/com/webgpu/WebGPUNativeBufferViewManager.java +56 -0
  9. package/android/src/main/java/com/webgpu/WebGPUTextureView.java +21 -0
  10. package/android/src/main/java/com/webgpu/WebGPUVideoPlayer.java +1 -1
  11. package/android/src/main/java/com/webgpu/WebGPUView.java +19 -3
  12. package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +2 -2
  13. package/android/src/newarch/com/webgpu/WebGPUNativeBufferViewManagerSpec.java +24 -0
  14. package/apple/AppleAnimationFrameSource.mm +208 -0
  15. package/apple/ApplePlatformContext.h +6 -0
  16. package/apple/ApplePlatformContext.mm +73 -0
  17. package/apple/NativeBufferFenceWait.mm +88 -0
  18. package/apple/WebGPUNativeBufferView.h +15 -0
  19. package/apple/WebGPUNativeBufferView.mm +200 -0
  20. package/cpp/rnwgpu/AnimationFrames.cpp +576 -0
  21. package/cpp/rnwgpu/AnimationFrames.h +233 -0
  22. package/cpp/rnwgpu/NativeBufferViewRegistry.cpp +396 -0
  23. package/cpp/rnwgpu/NativeBufferViewRegistry.h +163 -0
  24. package/cpp/rnwgpu/PlatformContext.h +20 -0
  25. package/cpp/rnwgpu/RNWebGPUManager.cpp +17 -4
  26. package/cpp/rnwgpu/api/GPUAdapter.cpp +1 -1
  27. package/cpp/rnwgpu/api/GPUDevice.cpp +16 -131
  28. package/cpp/rnwgpu/api/GPUDevice.h +0 -18
  29. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +35 -3
  30. package/cpp/rnwgpu/api/GPUExternalTexture.h +4 -4
  31. package/cpp/rnwgpu/api/GPUQueue.cpp +1 -1
  32. package/cpp/rnwgpu/api/GPUQueue.h +1 -1
  33. package/cpp/rnwgpu/api/GPUSharedFence.h +1 -0
  34. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +11 -5
  35. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +21 -2
  36. package/cpp/rnwgpu/api/GPUTexture.h +18 -0
  37. package/cpp/rnwgpu/api/NativeFrameFeatures.h +1 -1
  38. package/cpp/rnwgpu/api/NativeFrameImport.cpp +20 -17
  39. package/cpp/rnwgpu/api/NativeFrameImport.h +31 -20
  40. package/cpp/rnwgpu/api/RNWebGPU.h +201 -3
  41. package/cpp/rnwgpu/api/VideoFrame.h +5 -4
  42. package/cpp/rnwgpu/api/VideoFrameBlit.h +2 -2
  43. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +21 -14
  44. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +1 -1
  45. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +17 -9
  46. package/cpp/rnwgpu/async/RuntimeContext.cpp +21 -4
  47. package/cpp/rnwgpu/async/RuntimeContext.h +8 -0
  48. package/lib/commonjs/NativeBufferView.js +131 -0
  49. package/lib/commonjs/NativeBufferView.js.map +1 -0
  50. package/lib/commonjs/NativeBufferViewNativeComponent.js +10 -0
  51. package/lib/commonjs/NativeBufferViewNativeComponent.js.map +1 -0
  52. package/lib/commonjs/animationFrame.js +91 -0
  53. package/lib/commonjs/animationFrame.js.map +1 -0
  54. package/lib/commonjs/index.js +16 -1
  55. package/lib/commonjs/index.js.map +1 -1
  56. package/lib/commonjs/main/index.js +12 -0
  57. package/lib/commonjs/main/index.js.map +1 -1
  58. package/lib/commonjs/mock.js +30 -1
  59. package/lib/commonjs/mock.js.map +1 -1
  60. package/lib/commonjs/video.js +14 -4
  61. package/lib/commonjs/video.js.map +1 -1
  62. package/lib/module/NativeBufferView.js +122 -0
  63. package/lib/module/NativeBufferView.js.map +1 -0
  64. package/lib/module/NativeBufferViewNativeComponent.js +4 -0
  65. package/lib/module/NativeBufferViewNativeComponent.js.map +1 -0
  66. package/lib/module/animationFrame.js +83 -0
  67. package/lib/module/animationFrame.js.map +1 -0
  68. package/lib/module/index.js +1 -0
  69. package/lib/module/index.js.map +1 -1
  70. package/lib/module/main/index.js +1 -0
  71. package/lib/module/main/index.js.map +1 -1
  72. package/lib/module/mock.js +21 -0
  73. package/lib/module/mock.js.map +1 -1
  74. package/lib/module/video.js +11 -2
  75. package/lib/module/video.js.map +1 -1
  76. package/lib/typescript/lib/commonjs/NativeBufferView.d.ts +48 -0
  77. package/lib/typescript/lib/commonjs/NativeBufferView.d.ts.map +1 -0
  78. package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.d.ts +5 -0
  79. package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.d.ts.map +1 -0
  80. package/lib/typescript/lib/commonjs/animationFrame.d.ts +54 -0
  81. package/lib/typescript/lib/commonjs/animationFrame.d.ts.map +1 -0
  82. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  83. package/lib/typescript/lib/commonjs/mock.d.ts +12 -0
  84. package/lib/typescript/lib/commonjs/mock.d.ts.map +1 -1
  85. package/lib/typescript/lib/commonjs/video.d.ts +3 -2
  86. package/lib/typescript/lib/commonjs/video.d.ts.map +1 -1
  87. package/lib/typescript/lib/module/NativeBufferView.d.ts +14 -0
  88. package/lib/typescript/lib/module/NativeBufferView.d.ts.map +1 -0
  89. package/lib/typescript/lib/module/NativeBufferViewNativeComponent.d.ts +3 -0
  90. package/lib/typescript/lib/module/NativeBufferViewNativeComponent.d.ts.map +1 -0
  91. package/lib/typescript/lib/module/animationFrame.d.ts +3 -0
  92. package/lib/typescript/lib/module/animationFrame.d.ts.map +1 -0
  93. package/lib/typescript/lib/module/index.d.ts +1 -0
  94. package/lib/typescript/lib/module/main/index.d.ts +1 -0
  95. package/lib/typescript/lib/module/mock.d.ts +14 -0
  96. package/lib/typescript/lib/module/mock.d.ts.map +1 -1
  97. package/lib/typescript/lib/module/video.d.ts +3 -2
  98. package/lib/typescript/lib/module/video.d.ts.map +1 -1
  99. package/lib/typescript/src/NativeBufferView.d.ts +99 -0
  100. package/lib/typescript/src/NativeBufferView.d.ts.map +1 -0
  101. package/lib/typescript/src/NativeBufferViewNativeComponent.d.ts +13 -0
  102. package/lib/typescript/src/NativeBufferViewNativeComponent.d.ts.map +1 -0
  103. package/lib/typescript/src/animationFrame.d.ts +59 -0
  104. package/lib/typescript/src/animationFrame.d.ts.map +1 -0
  105. package/lib/typescript/src/index.d.ts +18 -8
  106. package/lib/typescript/src/index.d.ts.map +1 -1
  107. package/lib/typescript/src/main/index.d.ts +1 -0
  108. package/lib/typescript/src/main/index.d.ts.map +1 -1
  109. package/lib/typescript/src/mock.d.ts +11 -0
  110. package/lib/typescript/src/mock.d.ts.map +1 -1
  111. package/lib/typescript/src/types.d.ts +32 -31
  112. package/lib/typescript/src/types.d.ts.map +1 -1
  113. package/lib/typescript/src/video.d.ts +12 -4
  114. package/lib/typescript/src/video.d.ts.map +1 -1
  115. package/package.json +7 -2
  116. package/react-native-webgpu.podspec +1 -1
  117. package/src/NativeBufferView.tsx +199 -0
  118. package/src/NativeBufferViewNativeComponent.ts +20 -0
  119. package/src/animationFrame.ts +82 -0
  120. package/src/index.tsx +45 -39
  121. package/src/main/index.tsx +1 -0
  122. package/src/mock.ts +35 -0
  123. package/src/types.ts +61 -87
  124. package/src/video.ts +20 -7
  125. package/cpp/rnwgpu/api/GPUNativeBufferExternalTexture.h +0 -60
  126. package/cpp/rnwgpu/api/GPUNativeBufferTexture.h +0 -52
  127. package/cpp/rnwgpu/api/GPUNativeBufferWrapper.cpp +0 -144
  128. package/cpp/rnwgpu/api/GPUNativeBufferWrapper.h +0 -143
  129. package/cpp/rnwgpu/api/descriptors/GPUNativeBufferTextureDescriptor.h +0 -55
@@ -1,55 +0,0 @@
1
- #pragma once
2
-
3
- #include <memory>
4
- #include <optional>
5
- #include <stdexcept>
6
- #include <string>
7
-
8
- #include "webgpu/webgpu_cpp.h"
9
-
10
- #include "JSIConverter.h"
11
-
12
- namespace jsi = facebook::jsi;
13
-
14
- namespace rnwgpu {
15
-
16
- // The options of GPUDevice.createNativeBufferTexture(): the usage of the
17
- // texture (the usages the buffer allows by default, as
18
- // GPUSharedTextureMemory.createTexture() without a descriptor) and a label.
19
- struct GPUNativeBufferTextureDescriptor {
20
- std::optional<double> usage;
21
- std::optional<std::string> label;
22
- };
23
-
24
- template <>
25
- struct JSIConverter<std::shared_ptr<rnwgpu::GPUNativeBufferTextureDescriptor>> {
26
- static std::shared_ptr<rnwgpu::GPUNativeBufferTextureDescriptor>
27
- fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
28
- auto result = std::make_shared<rnwgpu::GPUNativeBufferTextureDescriptor>();
29
- if (!outOfBounds && arg.isObject()) {
30
- auto value = arg.getObject(runtime);
31
- if (value.hasProperty(runtime, "usage")) {
32
- auto prop = value.getProperty(runtime, "usage");
33
- if (prop.isNumber()) {
34
- result->usage = prop.asNumber();
35
- }
36
- }
37
- if (value.hasProperty(runtime, "label")) {
38
- auto prop = value.getProperty(runtime, "label");
39
- if (!prop.isUndefined()) {
40
- result->label = JSIConverter<std::optional<std::string>>::fromJSI(
41
- runtime, prop, false);
42
- }
43
- }
44
- }
45
- return result;
46
- }
47
- static jsi::Value
48
- toJSI(jsi::Runtime & /*runtime*/,
49
- std::shared_ptr<rnwgpu::GPUNativeBufferTextureDescriptor> /*arg*/) {
50
- throw std::runtime_error(
51
- "Invalid GPUNativeBufferTextureDescriptor::toJSI()");
52
- }
53
- };
54
-
55
- } // namespace rnwgpu