react-native-wgpu 0.1.12 → 0.1.14

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 (67) hide show
  1. package/android/CMakeLists.txt +7 -0
  2. package/android/build.gradle +4 -4
  3. package/android/cpp/cpp-adapter.cpp +10 -4
  4. package/android/cpp/platform/ThreadUtils.cpp +41 -0
  5. package/apple/ApplePlatformContext.h +19 -0
  6. package/apple/ApplePlatformContext.mm +86 -0
  7. package/apple/MetalView.h +13 -0
  8. package/apple/MetalView.mm +58 -0
  9. package/apple/WebGPUModule.h +19 -0
  10. package/apple/WebGPUModule.mm +93 -0
  11. package/apple/WebGPUView.h +15 -0
  12. package/apple/WebGPUView.mm +68 -0
  13. package/apple/WebGPUViewManager.mm +23 -0
  14. package/apple/platform/ThreadUtils.cpp +33 -0
  15. package/cpp/jsi/RNFJSIConverter.h +47 -28
  16. package/cpp/platform/ThreadUtils.h +30 -0
  17. package/cpp/rnwgpu/RNWebGPUManager.cpp +8 -0
  18. package/cpp/rnwgpu/api/Convertors.h +13 -14
  19. package/cpp/rnwgpu/api/GPU.cpp +4 -4
  20. package/cpp/rnwgpu/api/GPUAdapter.cpp +15 -14
  21. package/cpp/rnwgpu/api/GPUAdapterInfo.h +25 -4
  22. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +6 -4
  23. package/cpp/rnwgpu/api/GPUDevice.cpp +5 -5
  24. package/cpp/rnwgpu/api/GPUDevice.h +7 -1
  25. package/cpp/rnwgpu/api/GPUFeatures.h +4 -4
  26. package/cpp/rnwgpu/api/GPUShaderModule.cpp +2 -1
  27. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +9 -0
  28. package/cpp/threading/CallInvokerDispatcher.h +37 -0
  29. package/cpp/threading/Dispatcher.cpp +54 -0
  30. package/cpp/threading/Dispatcher.h +93 -0
  31. package/cpp/threading/ThreadPool.cpp +86 -0
  32. package/cpp/threading/ThreadPool.h +53 -0
  33. package/cpp/webgpu/webgpu.h +762 -758
  34. package/cpp/webgpu/webgpu_cpp.h +1827 -1626
  35. package/cpp/webgpu/webgpu_cpp_chained_struct.h +2 -0
  36. package/lib/commonjs/hooks.js +4 -2
  37. package/lib/commonjs/hooks.js.map +1 -1
  38. package/lib/module/hooks.js +4 -2
  39. package/lib/module/hooks.js.map +1 -1
  40. package/lib/typescript/lib/commonjs/hooks.d.ts.map +1 -1
  41. package/lib/typescript/lib/module/hooks.d.ts.map +1 -1
  42. package/lib/typescript/src/__tests__/Alpha.spec.d.ts +2 -0
  43. package/lib/typescript/src/__tests__/Alpha.spec.d.ts.map +1 -0
  44. package/lib/typescript/src/hooks.d.ts.map +1 -1
  45. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  46. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  47. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  48. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  49. package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  50. package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  51. package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
  52. package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
  53. package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
  54. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
  55. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  56. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  57. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
  58. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
  59. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
  60. package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
  61. package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  62. package/libs/dawn.json +270 -251
  63. package/package.json +2 -2
  64. package/src/__tests__/Alpha.spec.ts +28 -0
  65. package/src/__tests__/Device.spec.ts +31 -0
  66. package/src/__tests__/snapshots/semi-opaque-cyan.png +0 -0
  67. package/src/hooks.tsx +3 -2
@@ -0,0 +1,53 @@
1
+ //
2
+ // ThreadPool.hpp
3
+ // NitroModules
4
+ //
5
+ // Created by Marc Rousavy on 21.06.24.
6
+ //
7
+
8
+ #pragma once
9
+
10
+ #include <atomic>
11
+ #include <condition_variable>
12
+ #include <functional>
13
+ #include <memory>
14
+ #include <mutex>
15
+ #include <queue>
16
+ #include <string>
17
+ #include <thread>
18
+ #include <vector>
19
+
20
+ namespace margelo {
21
+
22
+ class ThreadPool final {
23
+ public:
24
+ /**
25
+ * Create a new ThreadPool with the given number of fixed workers/threads.
26
+ */
27
+ explicit ThreadPool(const char *const name, size_t numThreads);
28
+ ~ThreadPool();
29
+
30
+ /**
31
+ * Schedules the given task asynchronously on the ThreadPool.
32
+ * It will run once a worker is available.
33
+ */
34
+ void run(std::function<void()> &&task);
35
+
36
+ public:
37
+ /**
38
+ * Get a static singleton instance - a shared ThreadPool.
39
+ * The shared ThreadPool has 3 threads.
40
+ */
41
+ static std::shared_ptr<ThreadPool> getSharedPool();
42
+
43
+ private:
44
+ std::vector<std::thread> _workers;
45
+ std::queue<std::function<void()>> _tasks;
46
+ std::mutex _queueMutex;
47
+ std::condition_variable _condition;
48
+ std::atomic<bool> _isAlive;
49
+ const char *_name;
50
+ static constexpr auto TAG = "ThreadPool";
51
+ };
52
+
53
+ } // namespace margelo