react-native-wgpu 0.1.13 → 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 (54) 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/platform/ThreadUtils.cpp +33 -0
  6. package/cpp/jsi/RNFJSIConverter.h +47 -28
  7. package/cpp/platform/ThreadUtils.h +30 -0
  8. package/cpp/rnwgpu/RNWebGPUManager.cpp +8 -0
  9. package/cpp/rnwgpu/api/Convertors.h +13 -5
  10. package/cpp/rnwgpu/api/GPU.cpp +4 -4
  11. package/cpp/rnwgpu/api/GPUAdapter.cpp +15 -14
  12. package/cpp/rnwgpu/api/GPUAdapterInfo.h +25 -4
  13. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +3 -2
  14. package/cpp/rnwgpu/api/GPUDevice.cpp +5 -5
  15. package/cpp/rnwgpu/api/GPUDevice.h +7 -1
  16. package/cpp/rnwgpu/api/GPUFeatures.h +4 -4
  17. package/cpp/rnwgpu/api/GPUShaderModule.cpp +2 -1
  18. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +3 -1
  19. package/cpp/threading/CallInvokerDispatcher.h +37 -0
  20. package/cpp/threading/Dispatcher.cpp +54 -0
  21. package/cpp/threading/Dispatcher.h +93 -0
  22. package/cpp/threading/ThreadPool.cpp +86 -0
  23. package/cpp/threading/ThreadPool.h +53 -0
  24. package/cpp/webgpu/webgpu.h +762 -758
  25. package/cpp/webgpu/webgpu_cpp.h +1827 -1626
  26. package/cpp/webgpu/webgpu_cpp_chained_struct.h +2 -0
  27. package/lib/commonjs/hooks.js +4 -2
  28. package/lib/commonjs/hooks.js.map +1 -1
  29. package/lib/module/hooks.js +4 -2
  30. package/lib/module/hooks.js.map +1 -1
  31. package/lib/typescript/lib/commonjs/hooks.d.ts.map +1 -1
  32. package/lib/typescript/lib/module/hooks.d.ts.map +1 -1
  33. package/lib/typescript/src/hooks.d.ts.map +1 -1
  34. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  35. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  36. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  37. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  38. package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  39. package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  40. package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
  41. package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
  42. package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
  43. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
  44. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  45. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  46. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
  47. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
  48. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
  49. package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
  50. package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  51. package/libs/dawn.json +270 -251
  52. package/package.json +1 -1
  53. package/src/__tests__/Device.spec.ts +31 -0
  54. package/src/hooks.tsx +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wgpu",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "React Native WebGPU",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -32,4 +32,35 @@ describe("Device", () => {
32
32
  );
33
33
  expect(["unknown", "destroyed"].includes(result.reason)).toBe(true);
34
34
  });
35
+
36
+ it("times out device.lost if the device has not been destroyed", async () => {
37
+ const isDeviceLost = await client.eval(({ device }) => {
38
+ const timeout = new Promise((resolve) => {
39
+ setTimeout(() => {
40
+ resolve(false);
41
+ }, 50);
42
+ });
43
+
44
+ return Promise.race([device.lost.then(() => true), timeout]);
45
+ });
46
+
47
+ expect(isDeviceLost).toBeFalsy();
48
+ });
49
+
50
+ it("resolves an awaited device.lost when device.destroy is called", async () => {
51
+ const result = await client.eval(({ adapter }) =>
52
+ adapter.requestDevice({ label: "myGPU2" }).then((device) => {
53
+ setTimeout(() => {
54
+ device.destroy();
55
+ }, 50);
56
+
57
+ return device.lost.then((r) => ({
58
+ reason: r.reason,
59
+ message: r.message,
60
+ }));
61
+ }),
62
+ );
63
+
64
+ expect(["unknown", "destroyed"].includes(result.reason)).toBeTruthy();
65
+ });
35
66
  });
package/src/hooks.tsx CHANGED
@@ -6,9 +6,10 @@ import type { RNCanvasContext, CanvasRef, NativeCanvas } from "./Canvas";
6
6
  type Unsubscribe = () => void;
7
7
 
8
8
  export const warnIfNotHardwareAccelerated = (adapter: GPUAdapter) => {
9
- if (adapter.info.architecture === "swiftshader") {
9
+ if (adapter.isFallbackAdapter) {
10
10
  console.warn(
11
- "GPUAdapter is not hardware accelerated. This is common on Android emulators. Rendering will be slow.",
11
+ // eslint-disable-next-line max-len
12
+ "GPUAdapter is not hardware accelerated. This is common on Android emulators. Rendering will be slow. Some features may be unavailable.",
12
13
  );
13
14
  }
14
15
  };