react-native-webgpu 0.12.1 → 0.13.0

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 (85) hide show
  1. package/Package.swift +86 -56
  2. package/android/CMakeLists.txt +10 -4
  3. package/android/build.gradle +23 -0
  4. package/cpp/rnwgpu/SurfaceRegistry.h +2 -2
  5. package/package.json +5 -7
  6. package/react-native-webgpu.podspec +38 -2
  7. package/cpp/webgpu/webgpu.h +0 -5063
  8. package/cpp/webgpu/webgpu_cpp.h +0 -10401
  9. package/cpp/webgpu/webgpu_cpp_chained_struct.h +0 -57
  10. package/cpp/webgpu/webgpu_cpp_print.h +0 -2868
  11. package/cpp/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  12. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  13. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  14. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  15. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  16. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +0 -65
  17. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/dawn_proc_table.h +0 -329
  18. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/DawnNative.h +0 -367
  19. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/NullBackend.h +0 -39
  20. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/OpenGLBackend.h +0 -89
  21. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/VulkanBackend.h +0 -183
  22. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/native/dawn_native_export.h +0 -49
  23. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu.h +0 -5063
  24. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu.ixx +0 -358
  25. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu_cpp.h +0 -10401
  26. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/webgpu_cpp_print.h +0 -2868
  27. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/wire/client/webgpu.h +0 -369
  28. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/wire/client/webgpu_cpp.h +0 -10584
  29. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/dawn/wire/client/webgpu_cpp_print.h +0 -2868
  30. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu.h +0 -33
  31. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_cpp.h +0 -33
  32. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_cpp_chained_struct.h +0 -57
  33. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_cpp_print.h +0 -33
  34. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  35. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_cpp.h +0 -5932
  36. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_cpp_chained_struct.h +0 -54
  37. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_cpp_print.h +0 -2059
  38. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/Headers/webgpu_upstream/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  39. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  40. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/dawn_proc_table.h +0 -329
  41. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/DawnNative.h +0 -367
  42. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/NullBackend.h +0 -39
  43. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/OpenGLBackend.h +0 -89
  44. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/VulkanBackend.h +0 -183
  45. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/native/dawn_native_export.h +0 -49
  46. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu.h +0 -5063
  47. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu.ixx +0 -358
  48. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu_cpp.h +0 -10401
  49. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/webgpu_cpp_print.h +0 -2868
  50. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/wire/client/webgpu.h +0 -369
  51. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/wire/client/webgpu_cpp.h +0 -10584
  52. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/dawn/wire/client/webgpu_cpp_print.h +0 -2868
  53. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu.h +0 -33
  54. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_cpp.h +0 -33
  55. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_cpp_chained_struct.h +0 -57
  56. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_cpp_print.h +0 -33
  57. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  58. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_cpp.h +0 -5932
  59. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_cpp_chained_struct.h +0 -54
  60. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_cpp_print.h +0 -2059
  61. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/Headers/webgpu_upstream/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  62. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -4
  63. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/dawn_proc_table.h +0 -329
  64. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/DawnNative.h +0 -367
  65. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/NullBackend.h +0 -39
  66. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/OpenGLBackend.h +0 -89
  67. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/VulkanBackend.h +0 -183
  68. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/native/dawn_native_export.h +0 -49
  69. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu.h +0 -5063
  70. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu.ixx +0 -358
  71. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu_cpp.h +0 -10401
  72. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/webgpu_cpp_print.h +0 -2868
  73. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/wire/client/webgpu.h +0 -369
  74. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/wire/client/webgpu_cpp.h +0 -10584
  75. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/dawn/wire/client/webgpu_cpp_print.h +0 -2868
  76. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu.h +0 -33
  77. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_cpp.h +0 -33
  78. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_cpp_chained_struct.h +0 -57
  79. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_cpp_print.h +0 -33
  80. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  81. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_cpp.h +0 -5932
  82. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_cpp_chained_struct.h +0 -54
  83. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_cpp_print.h +0 -2059
  84. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/Headers/webgpu_upstream/webgpu/webgpu_enum_class_bitmasks.h +0 -163
  85. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -4
@@ -1,367 +0,0 @@
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_DAWNNATIVE_H_
29
- #define INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
30
-
31
- #include <webgpu/webgpu_cpp.h>
32
-
33
- #include <string>
34
- #include <string_view>
35
- #include <vector>
36
-
37
- #include "dawn/dawn_proc_table.h"
38
- #include "dawn/native/dawn_native_export.h"
39
-
40
- namespace dawn::platform {
41
- class Platform;
42
- } // namespace dawn::platform
43
-
44
- namespace dawn::native {
45
-
46
- class InstanceBase;
47
- class AdapterBase;
48
-
49
- // Each toggle is assigned with a TogglesStage, indicating the validation and earliest usage
50
- // time of the toggle.
51
- enum class ToggleStage { Instance, Adapter, Device };
52
-
53
- // A struct to record the information of a toggle. A toggle is a code path in Dawn device that
54
- // can be manually configured to run or not outside Dawn, including workarounds, special
55
- // features and optimizations.
56
- struct ToggleInfo {
57
- const char* name;
58
- const char* description;
59
- const char* url;
60
- ToggleStage stage;
61
- };
62
-
63
- // A struct to record the information of a feature. A feature is a GPU feature that is not
64
- // required to be supported by all Dawn backends and can only be used when it is enabled on the
65
- // creation of device.
66
- struct FeatureInfo {
67
- const char* name;
68
- const char* description;
69
- const char* url;
70
- // The enum of feature state, could be stable or experimental. Using an experimental feature
71
- // requires the AllowUnsafeAPIs toggle to be enabled.
72
- enum class FeatureState { Stable = 0, Experimental };
73
- FeatureState featureState;
74
- };
75
-
76
- // An adapter is an object that represent on possibility of creating devices in the system.
77
- // Most of the time it will represent a combination of a physical GPU and an API. Not that the
78
- // same GPU can be represented by multiple adapters but on different APIs.
79
- //
80
- // The underlying Dawn adapter is owned by the Dawn instance so this class is not RAII but just
81
- // a reference to an underlying adapter.
82
- class DAWN_NATIVE_EXPORT Adapter {
83
- public:
84
- Adapter();
85
- explicit(false) Adapter(AdapterBase* impl);
86
- ~Adapter();
87
-
88
- Adapter(const Adapter& other);
89
- Adapter& operator=(const Adapter& other);
90
-
91
- void SetUseTieredLimits(bool useTieredLimits);
92
-
93
- // Check that the Adapter is able to support importing external images. This is necessary
94
- // to implement the swapchain and interop APIs in Chromium.
95
- bool SupportsExternalImages() const;
96
-
97
- explicit operator bool() const;
98
-
99
- // Create a device on this adapter. On an error, nullptr is returned.
100
- WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
101
- WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
102
-
103
- // Returns the underlying WGPUAdapter object.
104
- WGPUAdapter Get() const;
105
-
106
- // Reset the backend device object for testing purposes.
107
- void ResetInternalDeviceForTesting();
108
-
109
- private:
110
- AdapterBase* mImpl = nullptr;
111
- };
112
-
113
- enum BackendValidationLevel { Full, Partial, Disabled };
114
-
115
- // Can be chained in InstanceDescriptor
116
- struct DAWN_NATIVE_EXPORT DawnInstanceDescriptor : wgpu::ChainedStruct {
117
- DawnInstanceDescriptor();
118
- std::span<std::string_view> additionalRuntimeSearchPaths;
119
- dawn::platform::Platform* platform = nullptr;
120
-
121
- BackendValidationLevel backendValidationLevel = BackendValidationLevel::Disabled;
122
- bool beginCaptureOnStartup = false;
123
-
124
- WGPULoggingCallbackInfo loggingCallbackInfo = WGPU_LOGGING_CALLBACK_INFO_INIT;
125
-
126
- template <typename F,
127
- typename T,
128
- typename Cb = wgpu::LoggingCallback<T>,
129
- typename = std::enable_if_t<std::is_convertible_v<F, Cb*>>>
130
- void SetLoggingCallback(F callback, T userdata) {
131
- assert(loggingCallbackInfo.callback == nullptr);
132
-
133
- loggingCallbackInfo.callback = [](WGPULoggingType type, struct WGPUStringView message,
134
- void* callback_param, void* userdata_param) {
135
- auto cb = reinterpret_cast<Cb*>(callback_param);
136
- (*cb)(static_cast<wgpu::LoggingType>(type), message, static_cast<T>(userdata_param));
137
- };
138
- loggingCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
139
- loggingCallbackInfo.userdata2 = reinterpret_cast<void*>(userdata);
140
- }
141
-
142
- template <typename L,
143
- typename Cb = wgpu::LoggingCallback<>,
144
- typename = std::enable_if_t<std::is_convertible_v<L, Cb>>>
145
- void SetLoggingCallback(L callback) {
146
- assert(loggingCallbackInfo.callback == nullptr);
147
- using F = wgpu::LoggingCallback<void>;
148
- static_assert(std::is_convertible_v<L, F*>, "Logging callback cannot be a binding lambda");
149
-
150
- loggingCallbackInfo.callback = [](WGPULoggingType type, struct WGPUStringView message,
151
- void* callback_param, void*) {
152
- auto cb = reinterpret_cast<F*>(callback_param);
153
- (*cb)(static_cast<wgpu::LoggingType>(type), message);
154
- };
155
- loggingCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
156
- loggingCallbackInfo.userdata2 = nullptr;
157
- }
158
-
159
- // Equality operators, mostly for testing. Note that this tests
160
- // strict pointer-pointer equality if the struct contains member pointers.
161
- bool operator==(const DawnInstanceDescriptor& rhs) const;
162
- };
163
-
164
- // Represents a connection to dawn_native and is used for dependency injection, discovering
165
- // system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter).
166
- //
167
- // This is an RAII class for Dawn instances and also controls the lifetime of all adapters
168
- // for this instance.
169
- class DAWN_NATIVE_EXPORT Instance {
170
- public:
171
- explicit Instance(const WGPUInstanceDescriptor* desc = nullptr);
172
- explicit Instance(const wgpu::InstanceDescriptor* desc);
173
- explicit Instance(InstanceBase* impl);
174
- ~Instance();
175
-
176
- Instance(const Instance& other) = delete;
177
- Instance& operator=(const Instance& other) = delete;
178
-
179
- // Discovers and returns a vector of adapters.
180
- // All systems adapters that can be found are returned if no options are passed.
181
- // Otherwise, returns adapters based on the `options`. Adapter toggles descriptor can chained
182
- // after options.
183
- std::vector<Adapter> EnumerateAdapters(const WGPURequestAdapterOptions* options) const;
184
- std::vector<Adapter> EnumerateAdapters(
185
- const wgpu::RequestAdapterOptions* options = nullptr) const;
186
-
187
- const ToggleInfo* GetToggleInfo(const char* toggleName);
188
-
189
- // Enables backend validation layers
190
- void SetBackendValidationLevel(BackendValidationLevel validationLevel);
191
-
192
- uint64_t GetDeviceCountForTesting() const;
193
- // Backdoor to get the number of deprecation warnings for testing
194
- uint64_t GetDeprecationWarningCountForTesting() const;
195
-
196
- // Returns the underlying WGPUInstance object.
197
- WGPUInstance Get() const;
198
-
199
- // Make mImpl->mPlatform point to an object inside Dawn in case it becomes a dangling pointer
200
- void DisconnectDawnPlatform();
201
-
202
- // Used by DawnTest, NOT thread-safe.
203
- void SetPlatformForTesting(dawn::platform::Platform* platform);
204
-
205
- private:
206
- InstanceBase* mImpl = nullptr;
207
- };
208
-
209
- // Backend-agnostic API for dawn_native
210
- DAWN_NATIVE_EXPORT const DawnProcTable& GetProcs();
211
-
212
- // Query the names of all the toggles that are enabled in adapter
213
- DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(const wgpu::Adapter& adapter);
214
-
215
- // Query the names of all the toggles that are enabled in device
216
- DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(WGPUDevice device);
217
-
218
- // Backdoor to get the number of lazy clears for testing
219
- DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
220
-
221
- // Query if texture has been initialized
222
- DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(
223
- WGPUTexture texture,
224
- uint32_t baseMipLevel,
225
- uint32_t levelCount,
226
- uint32_t baseArrayLayer,
227
- uint32_t layerCount,
228
- WGPUTextureAspect aspect = WGPUTextureAspect_All);
229
-
230
- // Backdoor to get the order of the ProcMap for testing
231
- DAWN_NATIVE_EXPORT std::vector<std::string_view> GetProcMapNamesForTesting();
232
-
233
- DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device);
234
-
235
- DAWN_NATIVE_EXPORT bool InstanceProcessEvents(WGPUInstance instance);
236
-
237
- // ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp
238
- DAWN_NATIVE_EXPORT void EnableErrorInjector();
239
- DAWN_NATIVE_EXPORT void DisableErrorInjector();
240
- DAWN_NATIVE_EXPORT void ClearErrorInjector();
241
- DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount();
242
- DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index);
243
-
244
- // The different types of external images
245
- enum ExternalImageType : uint16_t {
246
- OpaqueFD,
247
- DmaBuf,
248
- IOSurface,
249
- EGLImage,
250
- GLTexture,
251
- AHardwareBuffer,
252
- Last = AHardwareBuffer,
253
- };
254
-
255
- // Common properties of external images
256
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
257
- public:
258
- const WGPUTextureDescriptor* cTextureDescriptor = nullptr; // Must match image creation params
259
- bool isInitialized = false; // Whether the texture is initialized on import
260
- ExternalImageType GetType() const;
261
-
262
- protected:
263
- explicit ExternalImageDescriptor(ExternalImageType type);
264
-
265
- private:
266
- ExternalImageType mType;
267
- };
268
-
269
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
270
- public:
271
- bool isInitialized = false; // Whether the texture is initialized after export
272
- ExternalImageType GetType() const;
273
-
274
- protected:
275
- explicit ExternalImageExportInfo(ExternalImageType type);
276
-
277
- private:
278
- ExternalImageType mType;
279
- };
280
-
281
- DAWN_NATIVE_EXPORT bool CheckIsErrorForTesting(void* objectHandle);
282
-
283
- DAWN_NATIVE_EXPORT std::string GetObjectLabelForTesting(void* objectHandle);
284
-
285
- DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer);
286
-
287
- DAWN_NATIVE_EXPORT std::vector<const ToggleInfo*> AllToggleInfos();
288
-
289
- // Used to query the details of an feature. Return nullptr if featureName is not a valid
290
- // name of an feature supported in Dawn.
291
- DAWN_NATIVE_EXPORT const FeatureInfo* GetFeatureInfo(wgpu::FeatureName feature);
292
-
293
- class DAWN_NATIVE_EXPORT MemoryDump {
294
- public:
295
- // Standard attribute |name|s for the AddScalar() and AddString() methods.
296
- // These match the expected names in Chromium memory-infra instrumentation.
297
- static const char kNameSize[]; // To represent allocated space.
298
- static const char kNameObjectCount[]; // To represent number of objects.
299
-
300
- // Standard attribute |unit|s for the AddScalar() and AddString() methods.
301
- // These match the expected names in Chromium memory-infra instrumentation.
302
- static const char kUnitsBytes[]; // Unit name to represent bytes.
303
- static const char kUnitsObjects[]; // Unit name to represent #objects.
304
-
305
- MemoryDump() = default;
306
-
307
- virtual void AddScalar(const char* name,
308
- const char* key,
309
- const char* units,
310
- uint64_t value) = 0;
311
-
312
- virtual void AddString(const char* name, const char* key, const std::string& value) = 0;
313
-
314
- virtual void AddOwnerGUID(const char* name, uint64_t ownerGUID);
315
-
316
- MemoryDump(const MemoryDump&) = delete;
317
- MemoryDump& operator=(const MemoryDump&) = delete;
318
-
319
- protected:
320
- virtual ~MemoryDump() = default;
321
- };
322
- DAWN_NATIVE_EXPORT void DumpMemoryStatistics(WGPUDevice device, MemoryDump* dump);
323
-
324
- // Intended for background tracing for UMA that returns the estimated memory usage.
325
- struct DAWN_NATIVE_EXPORT MemoryUsageInfo {
326
- // Total memory usage.
327
- uint64_t totalUsage;
328
- // Total depth stencil textures' memory.
329
- uint64_t depthStencilTexturesUsage;
330
- // Total MSAA textures' memory.
331
- uint64_t msaaTexturesUsage;
332
- // Number of MSAA textures.
333
- uint64_t msaaTexturesCount;
334
- // Largest MSAA texture's memory.
335
- uint64_t largestMsaaTextureUsage;
336
- // Total textures' memory.
337
- uint64_t texturesUsage;
338
- // Total buffers' memory.
339
- uint64_t buffersUsage;
340
- };
341
- DAWN_NATIVE_EXPORT MemoryUsageInfo ComputeEstimatedMemoryUsageInfo(WGPUDevice device);
342
-
343
- // Memory information gathered from backend specific allocators.
344
- // - memory allocated by clients for objects such as buffers, textures.
345
- // - heap memory used by the allocator for allocations.
346
- struct DAWN_NATIVE_EXPORT AllocatorMemoryInfo {
347
- uint64_t totalUsedMemory = 0;
348
- uint64_t totalAllocatedMemory = 0;
349
- uint64_t totalLazyAllocatedMemory = 0;
350
- uint64_t totalLazyUsedMemory = 0;
351
- };
352
- DAWN_NATIVE_EXPORT AllocatorMemoryInfo GetAllocatorMemoryInfo(WGPUDevice device);
353
-
354
- // Free any unused GPU memory like staging buffers, cached resources, etc. Returns true if there are
355
- // still objects to delete and ReduceMemoryUsage() should be run again after a short delay to allow
356
- // submitted work to complete.
357
- DAWN_NATIVE_EXPORT bool ReduceMemoryUsage(WGPUDevice device);
358
-
359
- // Perform tasks that are appropriate to do when idle like serializing pipeline
360
- // caches, etc.
361
- DAWN_NATIVE_EXPORT void PerformIdleTasks(const wgpu::Device& device);
362
-
363
- DAWN_NATIVE_EXPORT bool IsDeviceLost(WGPUDevice device);
364
-
365
- } // namespace dawn::native
366
-
367
- #endif // INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
@@ -1,39 +0,0 @@
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_NULLBACKEND_H_
29
- #define INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
30
-
31
- #include "dawn/native/DawnNative.h"
32
-
33
- namespace dawn::native::null {
34
-
35
- // Nothing for now \o/
36
-
37
- } // namespace dawn::native::null
38
-
39
- #endif // INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
@@ -1,89 +0,0 @@
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_OPENGLBACKEND_H_
29
- #define INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
30
-
31
- #include "dawn/native/DawnNative.h"
32
- #include "webgpu/webgpu_cpp_chained_struct.h"
33
-
34
- namespace dawn::native::opengl {
35
-
36
- using EGLDisplay = void*;
37
- using EGLImage = void*;
38
- using GLuint = unsigned int;
39
- using EGLint = int32_t;
40
-
41
- // Define a GetProc function pointer that mirrors the one in egl.h
42
- #if defined(_WIN32)
43
- #define DAWN_STDCALL __stdcall
44
- #else // defined(_WIN32)
45
- #define DAWN_STDCALL
46
- #endif // defined(_WIN32)
47
-
48
- using EGLFunctionPointerType = void (*)();
49
- // NOLINTNEXTLINE(readability/casting): cpplint thinks this is a C-style cast but it isn't.
50
- using EGLGetProcProc = EGLFunctionPointerType(DAWN_STDCALL*)(const char*);
51
- #undef DAWN_STDCALL
52
-
53
- // Can be chained in WGPURequestAdapterOptions
54
- struct DAWN_NATIVE_EXPORT RequestAdapterOptionsGetGLProc : wgpu::ChainedStruct {
55
- RequestAdapterOptionsGetGLProc();
56
-
57
- EGLGetProcProc getProc = nullptr;
58
- EGLDisplay display = nullptr;
59
- };
60
-
61
- // Can be chained in WGPURequestAdapterOptions
62
- struct DAWN_NATIVE_EXPORT RequestAdapterOptionsAngleVirtualizationGroup : wgpu::ChainedStruct {
63
- RequestAdapterOptionsAngleVirtualizationGroup();
64
- EGLint angleVirtualizationGroup = -1; // EGL_DONT_CARE
65
- };
66
-
67
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorEGLImage : ExternalImageDescriptor {
68
- public:
69
- ExternalImageDescriptorEGLImage();
70
-
71
- EGLImage image = nullptr;
72
- };
73
-
74
- DAWN_NATIVE_EXPORT WGPUTexture
75
- WrapExternalEGLImage(WGPUDevice device, const ExternalImageDescriptorEGLImage* descriptor);
76
-
77
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorGLTexture : ExternalImageDescriptor {
78
- public:
79
- ExternalImageDescriptorGLTexture();
80
-
81
- GLuint texture = 0;
82
- };
83
-
84
- DAWN_NATIVE_EXPORT WGPUTexture
85
- WrapExternalGLTexture(WGPUDevice device, const ExternalImageDescriptorGLTexture* descriptor);
86
-
87
- } // namespace dawn::native::opengl
88
-
89
- #endif // INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
@@ -1,183 +0,0 @@
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_VULKANBACKEND_H_
29
- #define INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_
30
-
31
- #include <vulkan/vulkan.h>
32
-
33
- #include <array>
34
- #include <vector>
35
-
36
- #include "dawn/native/DawnNative.h"
37
-
38
- namespace dawn::native::vulkan {
39
-
40
- DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device);
41
-
42
- DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
43
-
44
- enum class NeedsDedicatedAllocation {
45
- Yes,
46
- No,
47
- // Use Vulkan reflection to detect whether a dedicated allocation is needed.
48
- Detect,
49
- };
50
-
51
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorVk : ExternalImageDescriptor {
52
- public:
53
- // The following members may be ignored if |ExternalImageDescriptor::isInitialized| is false
54
- // since the import does not need to preserve texture contents.
55
-
56
- // See https://www.khronos.org/registry/vulkan/specs/1.1/html/chap7.html. The acquire
57
- // operation old/new layouts must match exactly the layouts in the release operation. So
58
- // we may need to issue two barriers releasedOldLayout -> releasedNewLayout ->
59
- // cTextureDescriptor.usage if the new layout is not compatible with the desired usage.
60
- // The first barrier is the queue transfer, the second is the layout transition to our
61
- // desired usage.
62
- VkImageLayout releasedOldLayout = VK_IMAGE_LAYOUT_GENERAL;
63
- VkImageLayout releasedNewLayout = VK_IMAGE_LAYOUT_GENERAL;
64
-
65
- // Try to detect the need to use a dedicated allocation for imported images by default but let
66
- // the application override this as drivers have bugs and forget to require a dedicated
67
- // allocation.
68
- NeedsDedicatedAllocation dedicatedAllocation = NeedsDedicatedAllocation::Detect;
69
-
70
- protected:
71
- using ExternalImageDescriptor::ExternalImageDescriptor;
72
- };
73
-
74
- struct ExternalImageExportInfoVk : ExternalImageExportInfo {
75
- public:
76
- // See comments in |ExternalImageDescriptorVk|
77
- // Contains the old/new layouts used in the queue release operation.
78
- VkImageLayout releasedOldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
79
- VkImageLayout releasedNewLayout = VK_IMAGE_LAYOUT_UNDEFINED;
80
-
81
- protected:
82
- using ExternalImageExportInfo::ExternalImageExportInfo;
83
- };
84
-
85
- // Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome
86
- #if defined(__linux__) || defined(__Fuchsia__)
87
-
88
- // Common properties of external images represented by FDs. On successful import the file
89
- // descriptor's ownership is transferred to the Dawn implementation and they shouldn't be
90
- // used outside of Dawn again. TODO(enga): Also transfer ownership in the error case so the
91
- // caller can assume the FD is always consumed.
92
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorFD : ExternalImageDescriptorVk {
93
- public:
94
- int memoryFD = -1; // A file descriptor from an export of the memory of the image
95
- std::vector<int> waitFDs; // File descriptors of semaphores which will be waited on
96
-
97
- protected:
98
- using ExternalImageDescriptorVk::ExternalImageDescriptorVk;
99
- };
100
-
101
- // Descriptor for opaque file descriptor image import
102
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorOpaqueFD : ExternalImageDescriptorFD {
103
- ExternalImageDescriptorOpaqueFD();
104
-
105
- VkDeviceSize allocationSize = 0; // Must match VkMemoryAllocateInfo from image creation
106
- uint32_t memoryTypeIndex = 0; // Must match VkMemoryAllocateInfo from image creation
107
- };
108
-
109
- // The plane-wise offset and stride.
110
- struct DAWN_NATIVE_EXPORT PlaneLayout {
111
- uint64_t offset = 0;
112
- uint32_t stride = 0;
113
- };
114
-
115
- // Descriptor for dma-buf file descriptor image import
116
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD {
117
- ExternalImageDescriptorDmaBuf();
118
-
119
- static constexpr uint32_t kMaxPlanes = 3;
120
- std::array<PlaneLayout, kMaxPlanes> planeLayouts = {};
121
- uint64_t drmModifier = 0; // DRM modifier of the buffer
122
- };
123
-
124
- // Info struct that is written to in |ExportVulkanImage|.
125
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfoFD : ExternalImageExportInfoVk {
126
- public:
127
- // Contains the exported semaphore handles.
128
- std::vector<int> semaphoreHandles;
129
-
130
- protected:
131
- using ExternalImageExportInfoVk::ExternalImageExportInfoVk;
132
- };
133
-
134
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfoOpaqueFD : ExternalImageExportInfoFD {
135
- ExternalImageExportInfoOpaqueFD();
136
- };
137
-
138
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfoDmaBuf : ExternalImageExportInfoFD {
139
- ExternalImageExportInfoDmaBuf();
140
- };
141
-
142
- #ifdef __ANDROID__
143
-
144
- // Descriptor for AHardwareBuffer image import
145
- struct DAWN_NATIVE_EXPORT ExternalImageDescriptorAHardwareBuffer : ExternalImageDescriptorVk {
146
- public:
147
- ExternalImageDescriptorAHardwareBuffer();
148
-
149
- struct AHardwareBuffer* handle; // The AHardwareBuffer which contains the memory of the image
150
- std::vector<int> waitFDs; // File descriptors of semaphores which will be waited on
151
-
152
- protected:
153
- using ExternalImageDescriptorVk::ExternalImageDescriptorVk;
154
- };
155
-
156
- struct DAWN_NATIVE_EXPORT ExternalImageExportInfoAHardwareBuffer : ExternalImageExportInfoFD {
157
- ExternalImageExportInfoAHardwareBuffer();
158
- };
159
-
160
- #endif // __ANDROID__
161
-
162
- #endif // defined(__linux__) || defined(__Fuchsia__)
163
-
164
- // Imports external memory into a Vulkan image. Internally, this uses external memory /
165
- // semaphore extensions to import the image and wait on the provided synchronizaton
166
- // primitives before the texture can be used.
167
- // On failure, returns a nullptr.
168
- DAWN_NATIVE_EXPORT WGPUTexture WrapVulkanImage(WGPUDevice device,
169
- const ExternalImageDescriptorVk* descriptor);
170
-
171
- // Exports external memory from a Vulkan image. This must be called on wrapped textures
172
- // before they are destroyed. It writes the semaphore to wait on and the old/new image
173
- // layouts to |info|. Pass VK_IMAGE_LAYOUT_UNDEFINED as |desiredLayout| if you don't want to
174
- // perform a layout transition.
175
- DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture,
176
- VkImageLayout desiredLayout,
177
- ExternalImageExportInfoVk* info);
178
- // |ExportVulkanImage| with default desiredLayout of VK_IMAGE_LAYOUT_UNDEFINED.
179
- DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture, ExternalImageExportInfoVk* info);
180
-
181
- } // namespace dawn::native::vulkan
182
-
183
- #endif // INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_