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.
Files changed (63) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/cpp/AndroidPlatformContext.h +1 -1
  3. package/android/src/main/java/com/webgpu/WebGPUAHBView.java +41 -33
  4. package/android/src/main/java/com/webgpu/{SurfaceView2.java → WebGPUSurfaceViewWithSC.java} +3 -3
  5. package/android/src/main/java/com/webgpu/WebGPUView.java +15 -42
  6. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +3 -3
  7. package/android/src/oldarch/com/webgpu/WebGPUViewManagerSpec.java +1 -1
  8. package/apple/ApplePlatformContext.mm +11 -3
  9. package/apple/MetalView.h +2 -2
  10. package/apple/MetalView.mm +12 -0
  11. package/apple/RNWGUIKit.h +11 -0
  12. package/apple/WebGPUModule.mm +3 -12
  13. package/apple/WebGPUViewManager.mm +3 -2
  14. package/cpp/dawn/dawn_proc.h +50 -0
  15. package/cpp/dawn/dawn_proc_table.h +300 -0
  16. package/cpp/dawn/dawn_thread_dispatch_proc.h +47 -0
  17. package/cpp/dawn/native/D3D11Backend.h +64 -0
  18. package/cpp/dawn/native/D3D12Backend.h +68 -0
  19. package/cpp/dawn/native/D3DBackend.h +59 -0
  20. package/cpp/dawn/native/DawnNative.h +313 -0
  21. package/cpp/dawn/native/MetalBackend.h +55 -0
  22. package/cpp/dawn/native/NullBackend.h +39 -0
  23. package/cpp/dawn/native/OpenGLBackend.h +82 -0
  24. package/cpp/dawn/native/VulkanBackend.h +183 -0
  25. package/cpp/dawn/native/dawn_native_export.h +49 -0
  26. package/cpp/dawn/platform/DawnPlatform.h +165 -0
  27. package/cpp/dawn/platform/dawn_platform_export.h +49 -0
  28. package/cpp/dawn/webgpu_cpp_print.h +2484 -0
  29. package/cpp/rnwgpu/api/GPU.h +1 -1
  30. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +4 -0
  31. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -16
  32. package/cpp/webgpu/webgpu_glfw.h +71 -0
  33. package/lib/commonjs/Canvas.js +2 -5
  34. package/lib/commonjs/Canvas.js.map +1 -1
  35. package/lib/module/Canvas.js +2 -5
  36. package/lib/module/Canvas.js.map +1 -1
  37. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  38. package/lib/typescript/src/Canvas.d.ts +1 -2
  39. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  40. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -2
  41. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  42. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  43. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  44. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  45. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  46. package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  47. package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  48. package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
  49. package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
  50. package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
  51. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
  52. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  53. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  54. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
  55. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
  56. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
  57. package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
  58. package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  59. package/package.json +2 -1
  60. package/react-native-wgpu.podspec +1 -1
  61. package/src/Canvas.tsx +51 -65
  62. package/src/WebGPUViewNativeComponent.ts +2 -2
  63. package/cpp/rnwgpu/api/WebGPUCanvasContextFactory.h +0 -59
@@ -0,0 +1,49 @@
1
+ // Copyright 2018 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_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
29
+ #define INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
30
+
31
+ #if defined(DAWN_NATIVE_SHARED_LIBRARY)
32
+ #if defined(_WIN32)
33
+ #if defined(DAWN_NATIVE_IMPLEMENTATION)
34
+ #define DAWN_NATIVE_EXPORT __declspec(dllexport)
35
+ #else
36
+ #define DAWN_NATIVE_EXPORT __declspec(dllimport)
37
+ #endif
38
+ #else // defined(_WIN32)
39
+ #if defined(DAWN_NATIVE_IMPLEMENTATION)
40
+ #define DAWN_NATIVE_EXPORT __attribute__((visibility("default")))
41
+ #else
42
+ #define DAWN_NATIVE_EXPORT
43
+ #endif
44
+ #endif // defined(_WIN32)
45
+ #else // defined(DAWN_NATIVE_SHARED_LIBRARY)
46
+ #define DAWN_NATIVE_EXPORT
47
+ #endif // defined(DAWN_NATIVE_SHARED_LIBRARY)
48
+
49
+ #endif // INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
@@ -0,0 +1,165 @@
1
+ // Copyright 2019 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_DAWN_PLATFORM_DAWNPLATFORM_H_
29
+ #define INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_
30
+
31
+ #include <webgpu/webgpu.h>
32
+
33
+ #include <cstddef>
34
+ #include <cstdint>
35
+ #include <memory>
36
+
37
+ #include "dawn/platform/dawn_platform_export.h"
38
+
39
+ namespace dawn::platform {
40
+
41
+ enum class TraceCategory {
42
+ General, // General trace events
43
+ Validation, // Dawn validation
44
+ Recording, // Native command recording
45
+ GPUWork, // Actual GPU work
46
+ };
47
+
48
+ class DAWN_PLATFORM_EXPORT CachingInterface {
49
+ public:
50
+ CachingInterface();
51
+ virtual ~CachingInterface();
52
+
53
+ // LoadData has two modes. The first mode is used to get a value which
54
+ // corresponds to the |key|. The |valueOut| is a caller provided buffer
55
+ // allocated to the size |valueSize| which is loaded with data of the
56
+ // size returned. The second mode is used to query for the existence of
57
+ // the |key| where |valueOut| is nullptr and |valueSize| must be 0.
58
+ // The return size is non-zero if the |key| exists.
59
+ virtual size_t LoadData(const void* key, size_t keySize, void* valueOut, size_t valueSize) = 0;
60
+
61
+ // StoreData puts a |value| in the cache which corresponds to the |key|.
62
+ virtual void StoreData(const void* key,
63
+ size_t keySize,
64
+ const void* value,
65
+ size_t valueSize) = 0;
66
+
67
+ private:
68
+ CachingInterface(const CachingInterface&) = delete;
69
+ CachingInterface& operator=(const CachingInterface&) = delete;
70
+ };
71
+
72
+ class DAWN_PLATFORM_EXPORT WaitableEvent {
73
+ public:
74
+ WaitableEvent() = default;
75
+ virtual ~WaitableEvent() = default;
76
+
77
+ WaitableEvent(const WaitableEvent&) = delete;
78
+ WaitableEvent& operator=(const WaitableEvent&) = delete;
79
+
80
+ virtual void Wait() = 0; // Wait for completion
81
+ virtual bool IsComplete() = 0; // Non-blocking check if the event is complete
82
+ };
83
+
84
+ using PostWorkerTaskCallback = void (*)(void* userdata);
85
+
86
+ class DAWN_PLATFORM_EXPORT WorkerTaskPool {
87
+ public:
88
+ WorkerTaskPool() = default;
89
+ virtual ~WorkerTaskPool() = default;
90
+
91
+ WorkerTaskPool(const WorkerTaskPool&) = delete;
92
+ WorkerTaskPool& operator=(const WorkerTaskPool&) = delete;
93
+
94
+ virtual std::unique_ptr<WaitableEvent> PostWorkerTask(PostWorkerTaskCallback,
95
+ void* userdata) = 0;
96
+ };
97
+
98
+ // These features map to similarly named ones in src/chromium/src/gpu/config/gpu_finch_features.h
99
+ // in `namespace features`.
100
+ enum class Features {
101
+ kWebGPUUseDXC,
102
+ kWebGPUUseTintIR,
103
+ };
104
+
105
+ class DAWN_PLATFORM_EXPORT Platform {
106
+ public:
107
+ Platform();
108
+ virtual ~Platform();
109
+
110
+ virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category);
111
+
112
+ virtual double MonotonicallyIncreasingTime();
113
+
114
+ virtual uint64_t AddTraceEvent(char phase,
115
+ const unsigned char* categoryGroupEnabled,
116
+ const char* name,
117
+ uint64_t id,
118
+ double timestamp,
119
+ int numArgs,
120
+ const char** argNames,
121
+ const unsigned char* argTypes,
122
+ const uint64_t* argValues,
123
+ unsigned char flags);
124
+
125
+ // Invoked to add a UMA histogram count-based sample
126
+ virtual void HistogramCustomCounts(const char* name,
127
+ int sample,
128
+ int min,
129
+ int max,
130
+ int bucketCount);
131
+
132
+ // Invoked to add a UMA histogram count-based sample that requires high-performance
133
+ // counter (HPC) support.
134
+ virtual void HistogramCustomCountsHPC(const char* name,
135
+ int sample,
136
+ int min,
137
+ int max,
138
+ int bucketCount);
139
+
140
+ // Invoked to add a UMA histogram enumeration sample
141
+ virtual void HistogramEnumeration(const char* name, int sample, int boundaryValue);
142
+
143
+ // Invoked to add a UMA histogram sparse sample
144
+ virtual void HistogramSparse(const char* name, int sample);
145
+
146
+ // Invoked to add a UMA histogram boolean sample
147
+ virtual void HistogramBoolean(const char* name, bool sample);
148
+
149
+ // The returned CachingInterface is expected to outlive the device which uses it to persistently
150
+ // cache objects.
151
+ virtual CachingInterface* GetCachingInterface();
152
+
153
+ virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
154
+
155
+ // Hook for querying if a Finch feature is enabled.
156
+ virtual bool IsFeatureEnabled(Features feature);
157
+
158
+ private:
159
+ Platform(const Platform&) = delete;
160
+ Platform& operator=(const Platform&) = delete;
161
+ };
162
+
163
+ } // namespace dawn::platform
164
+
165
+ #endif // INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_
@@ -0,0 +1,49 @@
1
+ // Copyright 2020 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_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_
29
+ #define INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_
30
+
31
+ #if defined(DAWN_PLATFORM_SHARED_LIBRARY)
32
+ #if defined(_WIN32)
33
+ #if defined(DAWN_PLATFORM_IMPLEMENTATION)
34
+ #define DAWN_PLATFORM_EXPORT __declspec(dllexport)
35
+ #else
36
+ #define DAWN_PLATFORM_EXPORT __declspec(dllimport)
37
+ #endif
38
+ #else // defined(_WIN32)
39
+ #if defined(DAWN_PLATFORM_IMPLEMENTATION)
40
+ #define DAWN_PLATFORM_EXPORT __attribute__((visibility("default")))
41
+ #else
42
+ #define DAWN_PLATFORM_EXPORT
43
+ #endif
44
+ #endif // defined(_WIN32)
45
+ #else // defined(DAWN_PLATFORM_SHARED_LIBRARY)
46
+ #define DAWN_PLATFORM_EXPORT
47
+ #endif // defined(DAWN_PLATFORM_SHARED_LIBRARY)
48
+
49
+ #endif // INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_