react-native-wgpu 0.1.18 → 0.1.20
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.
- package/android/build.gradle +1 -1
- package/android/cpp/AndroidPlatformContext.h +1 -1
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +41 -33
- package/android/src/main/java/com/webgpu/{SurfaceView2.java → WebGPUSurfaceViewWithSC.java} +3 -3
- package/android/src/main/java/com/webgpu/WebGPUView.java +15 -42
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +3 -3
- package/android/src/oldarch/com/webgpu/WebGPUViewManagerSpec.java +1 -1
- package/apple/ApplePlatformContext.mm +11 -3
- package/apple/MetalView.h +2 -2
- package/apple/MetalView.mm +12 -0
- package/apple/RNWGUIKit.h +11 -0
- package/apple/WebGPUModule.mm +3 -12
- package/apple/WebGPUViewManager.mm +3 -2
- package/cpp/dawn/dawn_proc.h +50 -0
- package/cpp/dawn/dawn_proc_table.h +300 -0
- package/cpp/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/native/D3D11Backend.h +64 -0
- package/cpp/dawn/native/D3D12Backend.h +68 -0
- package/cpp/dawn/native/D3DBackend.h +59 -0
- package/cpp/dawn/native/DawnNative.h +313 -0
- package/cpp/dawn/native/MetalBackend.h +55 -0
- package/cpp/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/native/OpenGLBackend.h +82 -0
- package/cpp/dawn/native/VulkanBackend.h +183 -0
- package/cpp/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/platform/DawnPlatform.h +165 -0
- package/cpp/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/webgpu_cpp_print.h +2484 -0
- package/cpp/rnwgpu/api/GPU.h +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +4 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -16
- package/cpp/webgpu/webgpu_glfw.h +71 -0
- package/lib/commonjs/Canvas.js +2 -5
- package/lib/commonjs/Canvas.js.map +1 -1
- package/lib/module/Canvas.js +2 -5
- package/lib/module/Canvas.js.map +1 -1
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/Canvas.d.ts +1 -2
- package/lib/typescript/src/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
- package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/package.json +2 -1
- package/react-native-wgpu.podspec +1 -1
- package/src/Canvas.tsx +51 -65
- package/src/WebGPUViewNativeComponent.ts +2 -2
- package/cpp/rnwgpu/api/WebGPUCanvasContextFactory.h +0 -59
package/cpp/rnwgpu/api/GPU.h
CHANGED
|
@@ -17,22 +17,6 @@
|
|
|
17
17
|
#include "GPUTexture.h"
|
|
18
18
|
#include "SurfaceRegistry.h"
|
|
19
19
|
|
|
20
|
-
#ifdef __APPLE__
|
|
21
|
-
|
|
22
|
-
namespace dawn {
|
|
23
|
-
namespace native {
|
|
24
|
-
namespace metal {
|
|
25
|
-
|
|
26
|
-
// See
|
|
27
|
-
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/dawn/include/dawn/native/MetalBackend.h;l=41
|
|
28
|
-
void WaitForCommandsToBeScheduled(WGPUDevice device);
|
|
29
|
-
|
|
30
|
-
} // namespace metal
|
|
31
|
-
} // namespace native
|
|
32
|
-
} // namespace dawn
|
|
33
|
-
|
|
34
|
-
#endif
|
|
35
|
-
|
|
36
20
|
namespace rnwgpu {
|
|
37
21
|
|
|
38
22
|
namespace m = margelo;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright 2022 The Dawn & Tint Authors
|
|
2
|
+
//
|
|
3
|
+
// Redistribution and use in source and binary forms, with or without
|
|
4
|
+
// modification, are permitted provided that the following conditions are met:
|
|
5
|
+
//
|
|
6
|
+
// 1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
// list of conditions and the following disclaimer.
|
|
8
|
+
//
|
|
9
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
// this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
// and/or other materials provided with the distribution.
|
|
12
|
+
//
|
|
13
|
+
// 3. Neither the name of the copyright holder nor the names of its
|
|
14
|
+
// contributors may be used to endorse or promote products derived from
|
|
15
|
+
// this software without specific prior written permission.
|
|
16
|
+
//
|
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
#ifndef INCLUDE_WEBGPU_WEBGPU_GLFW_H_
|
|
29
|
+
#define INCLUDE_WEBGPU_WEBGPU_GLFW_H_
|
|
30
|
+
|
|
31
|
+
#include <memory>
|
|
32
|
+
|
|
33
|
+
#include "webgpu/webgpu_cpp.h"
|
|
34
|
+
|
|
35
|
+
#if defined(WGPU_GLFW_SHARED_LIBRARY)
|
|
36
|
+
#if defined(_WIN32)
|
|
37
|
+
#if defined(WGPU_GLFW_IMPLEMENTATION)
|
|
38
|
+
#define WGPU_GLFW_EXPORT __declspec(dllexport)
|
|
39
|
+
#else
|
|
40
|
+
#define WGPU_GLFW_EXPORT __declspec(dllimport)
|
|
41
|
+
#endif
|
|
42
|
+
#else // defined(_WIN32)
|
|
43
|
+
#if defined(WGPU_GLFW_IMPLEMENTATION)
|
|
44
|
+
#define WGPU_GLFW_EXPORT __attribute__((visibility("default")))
|
|
45
|
+
#else
|
|
46
|
+
#define WGPU_GLFW_EXPORT
|
|
47
|
+
#endif
|
|
48
|
+
#endif // defined(_WIN32)
|
|
49
|
+
#else // defined(WGPU_GLFW_SHARED_LIBRARY)
|
|
50
|
+
#define WGPU_GLFW_EXPORT
|
|
51
|
+
#endif // defined(WGPU_GLFW_SHARED_LIBRARY)
|
|
52
|
+
|
|
53
|
+
struct GLFWwindow;
|
|
54
|
+
|
|
55
|
+
namespace wgpu::glfw {
|
|
56
|
+
|
|
57
|
+
// Does the necessary setup on the GLFWwindow to allow creating a wgpu::Surface with it and
|
|
58
|
+
// calls `instance.CreateSurface` with the correct descriptor for this window.
|
|
59
|
+
// Returns a null wgpu::Surface on failure.
|
|
60
|
+
WGPU_GLFW_EXPORT wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance,
|
|
61
|
+
GLFWwindow* window);
|
|
62
|
+
|
|
63
|
+
// Use for testing only. Does everything that CreateSurfaceForWindow does except the call to
|
|
64
|
+
// CreateSurface. Useful to be able to modify the descriptor for testing, or when trying to
|
|
65
|
+
// avoid using the global proc table.
|
|
66
|
+
WGPU_GLFW_EXPORT std::unique_ptr<wgpu::ChainedStruct, void (*)(wgpu::ChainedStruct*)>
|
|
67
|
+
SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window);
|
|
68
|
+
|
|
69
|
+
} // namespace wgpu::glfw
|
|
70
|
+
|
|
71
|
+
#endif // INCLUDE_WEBGPU_WEBGPU_GLFW_H_
|
package/lib/commonjs/Canvas.js
CHANGED
|
@@ -55,8 +55,7 @@ const useSizePaper = _ref => {
|
|
|
55
55
|
};
|
|
56
56
|
const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
57
57
|
onLayout: _onLayout,
|
|
58
|
-
|
|
59
|
-
androidExperimental,
|
|
58
|
+
transparent,
|
|
60
59
|
...props
|
|
61
60
|
}, ref) => {
|
|
62
61
|
const viewRef = (0, _react.useRef)(null);
|
|
@@ -107,9 +106,7 @@ const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
107
106
|
flex: 1
|
|
108
107
|
},
|
|
109
108
|
contextId: contextId,
|
|
110
|
-
|
|
111
|
-
// eslint-disable-next-line no-nested-ternary
|
|
112
|
-
androidExperimental ? androidTransparency ? "HardwareBuffer" : "SurfaceView2" : androidTransparency ? "TextureView" : "SurfaceView"
|
|
109
|
+
transparent: !!transparent
|
|
113
110
|
}));
|
|
114
111
|
});
|
|
115
112
|
//# sourceMappingURL=Canvas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_WebGPUViewNativeComponent","_interopRequireDefault","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","CONTEXT_COUNTER","generateContextId","useSizeFabric","ref","size","setSize","useState","useLayoutEffect","current","Error","measureInWindow","_x","_y","width","height","onLayout","undefined","useSizePaper","_ref","useCallback","nativeEvent","layout","Canvas","exports","forwardRef","_onLayout","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_WebGPUViewNativeComponent","_interopRequireDefault","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","CONTEXT_COUNTER","generateContextId","useSizeFabric","ref","size","setSize","useState","useLayoutEffect","current","Error","measureInWindow","_x","_y","width","height","onLayout","undefined","useSizePaper","_ref","useCallback","nativeEvent","layout","Canvas","exports","forwardRef","_onLayout","transparent","props","viewRef","useRef","FABRIC","RNWebGPU","fabric","useSize","contextId","_","cb","useEffect","useImperativeHandle","getContextId","getNativeSurface","whenReady","callback","getContext","contextName","MakeWebGPUCanvasContext","React","createElement","View","collapsable","style","flex"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAWA,IAAAE,0BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA2D,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAA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AM,IAAIK,KAAK,CAAC,2CAA2C,CAAC;MAC9D;MACA,OAAOsB,QAAQ,CAACS,gBAAgB,CAACN,SAAS,CAAC;IAC7C,CAAC;IACDO,SAASA,CAACC,QAAoB,EAAE;MAC9B,IAAItC,IAAI,KAAK,IAAI,EAAE;QACjBgC,EAAE,CAAC5B,OAAO,GAAGkC,QAAQ;MACvB,CAAC,MAAM;QACLA,QAAQ,CAAC,CAAC;MACZ;IACF,CAAC;IACDC,UAAUA,CAACC,WAAqB,EAA0B;MACxD,IAAIA,WAAW,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAInC,KAAK,CAAC,iCAAiCmC,WAAW,EAAE,CAAC;MACjE;MACA,IAAIxC,IAAI,KAAK,IAAI,EAAE;QACjB,MAAM,IAAIK,KAAK,CAAC,2CAA2C,CAAC;MAC9D;MACA,OAAOsB,QAAQ,CAACc,uBAAuB,CACrCX,SAAS,EACT9B,IAAI,CAACS,KAAK,EACVT,IAAI,CAACU,MACP,CAAC;IACH;EACF,CAAC,CAAC,CAAC;EACH,oBACEgC,KAAA,CAAAC,aAAA,CAACnE,YAAA,CAAAoE,IAAI,EAAA5D,QAAA;IAAC6D,WAAW,EAAE,KAAM;IAAC9C,GAAG,EAAEyB,OAAQ;IAACb,QAAQ,EAAEA;EAAS,GAAKY,KAAK,gBACnEmB,KAAA,CAAAC,aAAA,CAAChE,0BAAA,CAAAI,OAAgB;IACf+D,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAE,CAAE;IACnBjB,SAAS,EAAEA,SAAU;IACrBR,WAAW,EAAE,CAAC,CAACA;EAAY,CAC5B,CACG,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/Canvas.js
CHANGED
|
@@ -48,8 +48,7 @@ const useSizePaper = _ref => {
|
|
|
48
48
|
};
|
|
49
49
|
export const Canvas = /*#__PURE__*/forwardRef(({
|
|
50
50
|
onLayout: _onLayout,
|
|
51
|
-
|
|
52
|
-
androidExperimental,
|
|
51
|
+
transparent,
|
|
53
52
|
...props
|
|
54
53
|
}, ref) => {
|
|
55
54
|
const viewRef = useRef(null);
|
|
@@ -100,9 +99,7 @@ export const Canvas = /*#__PURE__*/forwardRef(({
|
|
|
100
99
|
flex: 1
|
|
101
100
|
},
|
|
102
101
|
contextId: contextId,
|
|
103
|
-
|
|
104
|
-
// eslint-disable-next-line no-nested-ternary
|
|
105
|
-
androidExperimental ? androidTransparency ? "HardwareBuffer" : "SurfaceView2" : androidTransparency ? "TextureView" : "SurfaceView"
|
|
102
|
+
transparent: !!transparent
|
|
106
103
|
}));
|
|
107
104
|
});
|
|
108
105
|
//# sourceMappingURL=Canvas.js.map
|
package/lib/module/Canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","forwardRef","useEffect","useImperativeHandle","useRef","useState","useLayoutEffect","useCallback","WebGPUNativeView","CONTEXT_COUNTER","generateContextId","useSizeFabric","ref","size","setSize","current","Error","measureInWindow","_x","_y","width","height","onLayout","undefined","useSizePaper","_ref","nativeEvent","layout","Canvas","_onLayout","
|
|
1
|
+
{"version":3,"names":["View","forwardRef","useEffect","useImperativeHandle","useRef","useState","useLayoutEffect","useCallback","WebGPUNativeView","CONTEXT_COUNTER","generateContextId","useSizeFabric","ref","size","setSize","current","Error","measureInWindow","_x","_y","width","height","onLayout","undefined","useSizePaper","_ref","nativeEvent","layout","Canvas","_onLayout","transparent","props","viewRef","FABRIC","RNWebGPU","fabric","useSize","contextId","_","cb","getContextId","getNativeSurface","whenReady","callback","getContext","contextName","MakeWebGPUCanvasContext","React","createElement","_extends","collapsable","style","flex"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";AACA,SAASA,IAAI,QAAQ,cAAc;AACnC,SACEC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,EACRC,eAAe,EACfC,WAAW,QACN,OAAO;AAGd,OAAOC,gBAAgB,MAAM,6BAA6B;AAE1D,IAAIC,eAAe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CT,SAAS,EACTxB,IAAI,CAACO,KAAK,EACVP,IAAI,CAACQ,MACP,CAAC;IACH;EACF,CAAC,CAAC,CAAC;EACH,oBACE0B,KAAA,CAAAC,aAAA,CAAChD,IAAI,EAAAiD,QAAA;IAACC,WAAW,EAAE,KAAM;IAACtC,GAAG,EAAEoB,OAAQ;IAACV,QAAQ,EAAEA;EAAS,GAAKS,KAAK,gBACnEgB,KAAA,CAAAC,aAAA,CAACxC,gBAAgB;IACf2C,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAE,CAAE;IACnBf,SAAS,EAAEA,SAAU;IACrBP,WAAW,EAAE,CAAC,CAACA;EAAY,CAC5B,CACG,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AAgDA,
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AAgDA,mGAuDG"}
|
|
@@ -27,8 +27,7 @@ export interface CanvasRef {
|
|
|
27
27
|
whenReady: (callback: () => void) => void;
|
|
28
28
|
}
|
|
29
29
|
export declare const Canvas: import("react").ForwardRefExoticComponent<ViewProps & {
|
|
30
|
-
|
|
31
|
-
androidExperimental?: boolean;
|
|
30
|
+
transparent?: boolean;
|
|
32
31
|
} & import("react").RefAttributes<CanvasRef>>;
|
|
33
32
|
export {};
|
|
34
33
|
//# sourceMappingURL=Canvas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,cAAc,CAAC;AAoBjE,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,QAAQ,EAAE;QACZ,GAAG,EAAE,GAAG,CAAC;QACT,MAAM,EAAE,OAAO,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AE,CACvB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,KACX,eAAe,CAAC;QACrB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,GAAG,WAAW,KAAK,MAAM,CAAC;QACvE,iBAAiB,EAAE,OAAO,iBAAiB,CAAC;KAC7C,CAAC;CACH;AAED,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,UAAU,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC;IAC1D,gBAAgB,EAAE,MAAM,YAAY,CAAC;IACrC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CAC3C;AAqCD,eAAO,MAAM,MAAM;kBAEW,OAAO;6CAmDnC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ViewProps } from "react-native";
|
|
2
2
|
import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
3
3
|
interface NativeProps extends ViewProps {
|
|
4
|
-
contextId
|
|
5
|
-
|
|
4
|
+
contextId: Int32;
|
|
5
|
+
transparent: boolean;
|
|
6
6
|
}
|
|
7
7
|
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
8
8
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGPUViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAEvE,UAAU,WAAY,SAAQ,SAAS;IACrC,SAAS,
|
|
1
|
+
{"version":3,"file":"WebGPUViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAEvE,UAAU,WAAY,SAAQ,SAAS;IACrC,SAAS,EAAE,KAAK,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;;AAGD,wBAAiE"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -8,36 +8,38 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>libwebgpu_dawn.a</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>
|
|
11
|
+
<string>xros-arm64</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>libwebgpu_dawn.a</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
-
<string>x86_64</string>
|
|
18
17
|
</array>
|
|
19
18
|
<key>SupportedPlatform</key>
|
|
20
|
-
<string>
|
|
19
|
+
<string>xros</string>
|
|
21
20
|
</dict>
|
|
22
21
|
<dict>
|
|
23
22
|
<key>BinaryPath</key>
|
|
24
23
|
<string>libwebgpu_dawn.a</string>
|
|
25
24
|
<key>LibraryIdentifier</key>
|
|
26
|
-
<string>ios-
|
|
25
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
27
26
|
<key>LibraryPath</key>
|
|
28
27
|
<string>libwebgpu_dawn.a</string>
|
|
29
28
|
<key>SupportedArchitectures</key>
|
|
30
29
|
<array>
|
|
31
30
|
<string>arm64</string>
|
|
31
|
+
<string>x86_64</string>
|
|
32
32
|
</array>
|
|
33
33
|
<key>SupportedPlatform</key>
|
|
34
34
|
<string>ios</string>
|
|
35
|
+
<key>SupportedPlatformVariant</key>
|
|
36
|
+
<string>simulator</string>
|
|
35
37
|
</dict>
|
|
36
38
|
<dict>
|
|
37
39
|
<key>BinaryPath</key>
|
|
38
40
|
<string>libwebgpu_dawn.a</string>
|
|
39
41
|
<key>LibraryIdentifier</key>
|
|
40
|
-
<string>
|
|
42
|
+
<string>macos-arm64_x86_64</string>
|
|
41
43
|
<key>LibraryPath</key>
|
|
42
44
|
<string>libwebgpu_dawn.a</string>
|
|
43
45
|
<key>SupportedArchitectures</key>
|
|
@@ -46,15 +48,13 @@
|
|
|
46
48
|
<string>x86_64</string>
|
|
47
49
|
</array>
|
|
48
50
|
<key>SupportedPlatform</key>
|
|
49
|
-
<string>
|
|
50
|
-
<key>SupportedPlatformVariant</key>
|
|
51
|
-
<string>simulator</string>
|
|
51
|
+
<string>macos</string>
|
|
52
52
|
</dict>
|
|
53
53
|
<dict>
|
|
54
54
|
<key>BinaryPath</key>
|
|
55
55
|
<string>libwebgpu_dawn.a</string>
|
|
56
56
|
<key>LibraryIdentifier</key>
|
|
57
|
-
<string>
|
|
57
|
+
<string>ios-arm64</string>
|
|
58
58
|
<key>LibraryPath</key>
|
|
59
59
|
<string>libwebgpu_dawn.a</string>
|
|
60
60
|
<key>SupportedArchitectures</key>
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
<string>arm64</string>
|
|
63
63
|
</array>
|
|
64
64
|
<key>SupportedPlatform</key>
|
|
65
|
-
<string>
|
|
65
|
+
<string>ios</string>
|
|
66
66
|
</dict>
|
|
67
67
|
<dict>
|
|
68
68
|
<key>BinaryPath</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wgpu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"tsc": "tsc --noEmit",
|
|
27
27
|
"build": "bob build",
|
|
28
28
|
"build-dawn": "ts-node scripts/build/dawn.ts",
|
|
29
|
+
"copy-headers": "ts-node scripts/build/copy-headers.ts",
|
|
29
30
|
"clean-dawn": "rimraf ./libs && rimraf ../../externals/dawn/out",
|
|
30
31
|
"clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
|
|
31
32
|
"clang-format-ios": "find apple/ -iname \"*.h\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.license = package["license"]
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
|
-
s.platforms = { :ios => min_ios_version_supported, :visionos => "1.0" }
|
|
14
|
+
s.platforms = { :ios => min_ios_version_supported, :osx => "10.15", :visionos => "1.0" }
|
|
15
15
|
s.source = { :git => "https://github.com/wcandillon/react-native-webgpu.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = [
|
package/src/Canvas.tsx
CHANGED
|
@@ -92,69 +92,55 @@ const useSizePaper = (_ref: RefObject<View>) => {
|
|
|
92
92
|
|
|
93
93
|
export const Canvas = forwardRef<
|
|
94
94
|
CanvasRef,
|
|
95
|
-
ViewProps & {
|
|
96
|
-
>(
|
|
97
|
-
(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
) =>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
95
|
+
ViewProps & { transparent?: boolean }
|
|
96
|
+
>(({ onLayout: _onLayout, transparent, ...props }, ref) => {
|
|
97
|
+
const viewRef = useRef(null);
|
|
98
|
+
const FABRIC = RNWebGPU.fabric;
|
|
99
|
+
const useSize = FABRIC ? useSizeFabric : useSizePaper;
|
|
100
|
+
const [contextId, _] = useState(() => generateContextId());
|
|
101
|
+
const cb = useRef<() => void>();
|
|
102
|
+
const { size, onLayout } = useSize(viewRef);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (size && cb.current) {
|
|
105
|
+
cb.current();
|
|
106
|
+
}
|
|
107
|
+
}, [size]);
|
|
108
|
+
useImperativeHandle(ref, () => ({
|
|
109
|
+
getContextId: () => contextId,
|
|
110
|
+
getNativeSurface: () => {
|
|
111
|
+
if (size === null) {
|
|
112
|
+
throw new Error("[WebGPU] Canvas size is not available yet");
|
|
110
113
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
style={{ flex: 1 }}
|
|
145
|
-
contextId={contextId}
|
|
146
|
-
androidView={
|
|
147
|
-
// eslint-disable-next-line no-nested-ternary
|
|
148
|
-
androidExperimental
|
|
149
|
-
? androidTransparency
|
|
150
|
-
? "HardwareBuffer"
|
|
151
|
-
: "SurfaceView2"
|
|
152
|
-
: androidTransparency
|
|
153
|
-
? "TextureView"
|
|
154
|
-
: "SurfaceView"
|
|
155
|
-
}
|
|
156
|
-
/>
|
|
157
|
-
</View>
|
|
158
|
-
);
|
|
159
|
-
},
|
|
160
|
-
);
|
|
114
|
+
return RNWebGPU.getNativeSurface(contextId);
|
|
115
|
+
},
|
|
116
|
+
whenReady(callback: () => void) {
|
|
117
|
+
if (size === null) {
|
|
118
|
+
cb.current = callback;
|
|
119
|
+
} else {
|
|
120
|
+
callback();
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
getContext(contextName: "webgpu"): RNCanvasContext | null {
|
|
124
|
+
if (contextName !== "webgpu") {
|
|
125
|
+
throw new Error(`[WebGPU] Unsupported context: ${contextName}`);
|
|
126
|
+
}
|
|
127
|
+
if (size === null) {
|
|
128
|
+
throw new Error("[WebGPU] Canvas size is not available yet");
|
|
129
|
+
}
|
|
130
|
+
return RNWebGPU.MakeWebGPUCanvasContext(
|
|
131
|
+
contextId,
|
|
132
|
+
size.width,
|
|
133
|
+
size.height,
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
}));
|
|
137
|
+
return (
|
|
138
|
+
<View collapsable={false} ref={viewRef} onLayout={onLayout} {...props}>
|
|
139
|
+
<WebGPUNativeView
|
|
140
|
+
style={{ flex: 1 }}
|
|
141
|
+
contextId={contextId}
|
|
142
|
+
transparent={!!transparent}
|
|
143
|
+
/>
|
|
144
|
+
</View>
|
|
145
|
+
);
|
|
146
|
+
});
|
|
@@ -3,8 +3,8 @@ import type { ViewProps } from "react-native";
|
|
|
3
3
|
import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
4
4
|
|
|
5
5
|
interface NativeProps extends ViewProps {
|
|
6
|
-
contextId
|
|
7
|
-
|
|
6
|
+
contextId: Int32;
|
|
7
|
+
transparent: boolean;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
// eslint-disable-next-line import/no-default-export
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
#include <string>
|
|
5
|
-
#include <utility>
|
|
6
|
-
|
|
7
|
-
#include "Unions.h"
|
|
8
|
-
|
|
9
|
-
#include "webgpu/webgpu_cpp.h"
|
|
10
|
-
|
|
11
|
-
#include "RNFHybridObject.h"
|
|
12
|
-
|
|
13
|
-
#include "AsyncRunner.h"
|
|
14
|
-
|
|
15
|
-
#include "GPUCanvasContext.h"
|
|
16
|
-
|
|
17
|
-
#ifdef __APPLE__
|
|
18
|
-
#include "WebGPUModule.h"
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
namespace rnwgpu {
|
|
22
|
-
|
|
23
|
-
namespace m = margelo;
|
|
24
|
-
|
|
25
|
-
class WebGPUCanvasContextFactory : public m::HybridObject {
|
|
26
|
-
public:
|
|
27
|
-
GPUCanvasContextFactory() : HybridObject("GPUCanvasContextFactory") {}
|
|
28
|
-
|
|
29
|
-
public:
|
|
30
|
-
std::shared_ptr<GPUCanvasContext> Make(uint64_t surface, int width,
|
|
31
|
-
int height) {
|
|
32
|
-
#ifdef __APPLE__
|
|
33
|
-
wgpu::SurfaceDescriptorFromMetalLayer metalSurfaceDesc;
|
|
34
|
-
metalSurfaceDesc.layer = reinterpret_cast<void *>(surface);
|
|
35
|
-
|
|
36
|
-
wgpu::SurfaceDescriptor surfaceDescriptor;
|
|
37
|
-
surfaceDescriptor.nextInChain = &metalSurfaceDesc;
|
|
38
|
-
|
|
39
|
-
auto surfaceGpu = std::make_unique<wgpu::Surface>(
|
|
40
|
-
WebGPUModule::getManager()->getGPU()->get().CreateSurface(
|
|
41
|
-
&surfaceDescriptor));
|
|
42
|
-
const float scaleFactor = 1;
|
|
43
|
-
const float scaledWidth = width * scaleFactor;
|
|
44
|
-
const float scaledHeight = height * scaleFactor;
|
|
45
|
-
|
|
46
|
-
rnwgpu::SurfaceData surfaceData{scaledWidth, scaledHeight,
|
|
47
|
-
std::move(surfaceGpu)};
|
|
48
|
-
#elif __ANDROID__
|
|
49
|
-
throw std::runtime_error("Not implemented");
|
|
50
|
-
#endif
|
|
51
|
-
return std::make_shared<rnwgpu::GPUCanvasContext>(surfaceData);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
void loadHybridMethods() override {
|
|
55
|
-
registerHybridGetter("Make", &GPUCanvasContextFactory::Make, this);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
} // namespace rnwgpu
|