react-native-wgpu 0.1.19 → 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/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/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/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_
|
|
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 = [
|
|
@@ -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
|