@shopify/react-native-skia 2.6.1 → 2.6.3-next.1

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 (29) hide show
  1. package/cpp/dawn/include/dawn/dawn_proc.h +50 -0
  2. package/cpp/dawn/include/dawn/dawn_proc_table.h +326 -0
  3. package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
  4. package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
  5. package/cpp/dawn/include/dawn/native/D3D12Backend.h +102 -0
  6. package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
  7. package/cpp/dawn/include/dawn/native/DawnNative.h +369 -0
  8. package/cpp/dawn/include/dawn/native/MetalBackend.h +56 -0
  9. package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
  10. package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
  11. package/cpp/dawn/include/dawn/native/VulkanBackend.h +183 -0
  12. package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
  13. package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
  14. package/cpp/dawn/include/dawn/platform/DawnPlatform.h +203 -0
  15. package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
  16. package/cpp/dawn/include/dawn/replay/Replay.h +75 -0
  17. package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
  18. package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2752 -0
  19. package/cpp/dawn/include/tint/tint.h +90 -0
  20. package/cpp/dawn/include/webgpu/webgpu.h +4902 -0
  21. package/cpp/dawn/include/webgpu/webgpu_cpp.h +10261 -0
  22. package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
  23. package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +161 -0
  24. package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
  25. package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
  26. package/cpp/skia/src/gpu/graphite/ResourceTypes.h +360 -0
  27. package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
  28. package/package.json +7 -6
  29. package/scripts/install-libs.js +44 -4
@@ -0,0 +1,369 @@
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
+ // NOLINTNEXTLINE(runtime/explicit)
86
+ Adapter(AdapterBase* impl);
87
+ ~Adapter();
88
+
89
+ Adapter(const Adapter& other);
90
+ Adapter& operator=(const Adapter& other);
91
+
92
+ void SetUseTieredLimits(bool useTieredLimits);
93
+
94
+ // Check that the Adapter is able to support importing external images. This is necessary
95
+ // to implement the swapchain and interop APIs in Chromium.
96
+ bool SupportsExternalImages() const;
97
+
98
+ explicit operator bool() const;
99
+
100
+ // Create a device on this adapter. On an error, nullptr is returned.
101
+ WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
102
+ WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
103
+
104
+ // Returns the underlying WGPUAdapter object.
105
+ WGPUAdapter Get() const;
106
+
107
+ // Reset the backend device object for testing purposes.
108
+ void ResetInternalDeviceForTesting();
109
+
110
+ private:
111
+ AdapterBase* mImpl = nullptr;
112
+ };
113
+
114
+ enum BackendValidationLevel { Full, Partial, Disabled };
115
+
116
+ // Can be chained in InstanceDescriptor
117
+ struct DAWN_NATIVE_EXPORT DawnInstanceDescriptor : wgpu::ChainedStruct {
118
+ DawnInstanceDescriptor();
119
+ uint32_t additionalRuntimeSearchPathsCount = 0;
120
+ const char* const* additionalRuntimeSearchPaths;
121
+ dawn::platform::Platform* platform = nullptr;
122
+
123
+ BackendValidationLevel backendValidationLevel = BackendValidationLevel::Disabled;
124
+ bool beginCaptureOnStartup = false;
125
+
126
+ WGPULoggingCallbackInfo loggingCallbackInfo = WGPU_LOGGING_CALLBACK_INFO_INIT;
127
+
128
+ template <typename F,
129
+ typename T,
130
+ typename Cb = wgpu::LoggingCallback<T>,
131
+ typename = std::enable_if_t<std::is_convertible_v<F, Cb*>>>
132
+ void SetLoggingCallback(F callback, T userdata) {
133
+ assert(loggingCallbackInfo.callback == nullptr);
134
+
135
+ loggingCallbackInfo.callback = [](WGPULoggingType type, struct WGPUStringView message,
136
+ void* callback_param, void* userdata_param) {
137
+ auto cb = reinterpret_cast<Cb*>(callback_param);
138
+ (*cb)(static_cast<wgpu::LoggingType>(type), message, static_cast<T>(userdata_param));
139
+ };
140
+ loggingCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
141
+ loggingCallbackInfo.userdata2 = reinterpret_cast<void*>(userdata);
142
+ }
143
+
144
+ template <typename L,
145
+ typename Cb = wgpu::LoggingCallback<>,
146
+ typename = std::enable_if_t<std::is_convertible_v<L, Cb>>>
147
+ void SetLoggingCallback(L callback) {
148
+ assert(loggingCallbackInfo.callback == nullptr);
149
+ using F = wgpu::LoggingCallback<void>;
150
+ static_assert(std::is_convertible_v<L, F*>, "Logging callback cannot be a binding lambda");
151
+
152
+ loggingCallbackInfo.callback = [](WGPULoggingType type, struct WGPUStringView message,
153
+ void* callback_param, void*) {
154
+ auto cb = reinterpret_cast<F*>(callback_param);
155
+ (*cb)(static_cast<wgpu::LoggingType>(type), message);
156
+ };
157
+ loggingCallbackInfo.userdata1 = reinterpret_cast<void*>(+callback);
158
+ loggingCallbackInfo.userdata2 = nullptr;
159
+ }
160
+
161
+ // Equality operators, mostly for testing. Note that this tests
162
+ // strict pointer-pointer equality if the struct contains member pointers.
163
+ bool operator==(const DawnInstanceDescriptor& rhs) const;
164
+ };
165
+
166
+ // Represents a connection to dawn_native and is used for dependency injection, discovering
167
+ // system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter).
168
+ //
169
+ // This is an RAII class for Dawn instances and also controls the lifetime of all adapters
170
+ // for this instance.
171
+ class DAWN_NATIVE_EXPORT Instance {
172
+ public:
173
+ explicit Instance(const WGPUInstanceDescriptor* desc = nullptr);
174
+ explicit Instance(const wgpu::InstanceDescriptor* desc);
175
+ explicit Instance(InstanceBase* impl);
176
+ ~Instance();
177
+
178
+ Instance(const Instance& other) = delete;
179
+ Instance& operator=(const Instance& other) = delete;
180
+
181
+ // Discovers and returns a vector of adapters.
182
+ // All systems adapters that can be found are returned if no options are passed.
183
+ // Otherwise, returns adapters based on the `options`. Adapter toggles descriptor can chained
184
+ // after options.
185
+ std::vector<Adapter> EnumerateAdapters(const WGPURequestAdapterOptions* options) const;
186
+ std::vector<Adapter> EnumerateAdapters(
187
+ const wgpu::RequestAdapterOptions* options = nullptr) const;
188
+
189
+ const ToggleInfo* GetToggleInfo(const char* toggleName);
190
+
191
+ // Enables backend validation layers
192
+ void SetBackendValidationLevel(BackendValidationLevel validationLevel);
193
+
194
+ uint64_t GetDeviceCountForTesting() const;
195
+ // Backdoor to get the number of deprecation warnings for testing
196
+ uint64_t GetDeprecationWarningCountForTesting() const;
197
+
198
+ // Returns the underlying WGPUInstance object.
199
+ WGPUInstance Get() const;
200
+
201
+ // Make mImpl->mPlatform point to an object inside Dawn in case it becomes a dangling pointer
202
+ void DisconnectDawnPlatform();
203
+
204
+ // Used by DawnTest, NOT thread-safe.
205
+ void SetPlatformForTesting(dawn::platform::Platform* platform);
206
+
207
+ private:
208
+ InstanceBase* mImpl = nullptr;
209
+ };
210
+
211
+ // Backend-agnostic API for dawn_native
212
+ DAWN_NATIVE_EXPORT const DawnProcTable& GetProcs();
213
+
214
+ // Query the names of all the toggles that are enabled in adapter
215
+ DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(const wgpu::Adapter& adapter);
216
+
217
+ // Query the names of all the toggles that are enabled in device
218
+ DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(WGPUDevice device);
219
+
220
+ // Backdoor to get the number of lazy clears for testing
221
+ DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
222
+
223
+ // Query if texture has been initialized
224
+ DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(
225
+ WGPUTexture texture,
226
+ uint32_t baseMipLevel,
227
+ uint32_t levelCount,
228
+ uint32_t baseArrayLayer,
229
+ uint32_t layerCount,
230
+ WGPUTextureAspect aspect = WGPUTextureAspect_All);
231
+
232
+ // Backdoor to get the order of the ProcMap for testing
233
+ DAWN_NATIVE_EXPORT std::vector<std::string_view> GetProcMapNamesForTesting();
234
+
235
+ DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device);
236
+
237
+ DAWN_NATIVE_EXPORT bool InstanceProcessEvents(WGPUInstance instance);
238
+
239
+ // ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp
240
+ DAWN_NATIVE_EXPORT void EnableErrorInjector();
241
+ DAWN_NATIVE_EXPORT void DisableErrorInjector();
242
+ DAWN_NATIVE_EXPORT void ClearErrorInjector();
243
+ DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount();
244
+ DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index);
245
+
246
+ // The different types of external images
247
+ enum ExternalImageType {
248
+ OpaqueFD,
249
+ DmaBuf,
250
+ IOSurface,
251
+ EGLImage,
252
+ GLTexture,
253
+ AHardwareBuffer,
254
+ Last = AHardwareBuffer,
255
+ };
256
+
257
+ // Common properties of external images
258
+ struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
259
+ public:
260
+ const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params
261
+ bool isInitialized; // Whether the texture is initialized on import
262
+ ExternalImageType GetType() const;
263
+
264
+ protected:
265
+ explicit ExternalImageDescriptor(ExternalImageType type);
266
+
267
+ private:
268
+ ExternalImageType mType;
269
+ };
270
+
271
+ struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
272
+ public:
273
+ bool isInitialized = false; // Whether the texture is initialized after export
274
+ ExternalImageType GetType() const;
275
+
276
+ protected:
277
+ explicit ExternalImageExportInfo(ExternalImageType type);
278
+
279
+ private:
280
+ ExternalImageType mType;
281
+ };
282
+
283
+ DAWN_NATIVE_EXPORT bool CheckIsErrorForTesting(void* objectHandle);
284
+
285
+ DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle);
286
+
287
+ DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer);
288
+
289
+ DAWN_NATIVE_EXPORT std::vector<const ToggleInfo*> AllToggleInfos();
290
+
291
+ // Used to query the details of an feature. Return nullptr if featureName is not a valid
292
+ // name of an feature supported in Dawn.
293
+ DAWN_NATIVE_EXPORT const FeatureInfo* GetFeatureInfo(wgpu::FeatureName feature);
294
+
295
+ class DAWN_NATIVE_EXPORT MemoryDump {
296
+ public:
297
+ // Standard attribute |name|s for the AddScalar() and AddString() methods.
298
+ // These match the expected names in Chromium memory-infra instrumentation.
299
+ static const char kNameSize[]; // To represent allocated space.
300
+ static const char kNameObjectCount[]; // To represent number of objects.
301
+
302
+ // Standard attribute |unit|s for the AddScalar() and AddString() methods.
303
+ // These match the expected names in Chromium memory-infra instrumentation.
304
+ static const char kUnitsBytes[]; // Unit name to represent bytes.
305
+ static const char kUnitsObjects[]; // Unit name to represent #objects.
306
+
307
+ MemoryDump() = default;
308
+
309
+ virtual void AddScalar(const char* name,
310
+ const char* key,
311
+ const char* units,
312
+ uint64_t value) = 0;
313
+
314
+ virtual void AddString(const char* name, const char* key, const std::string& value) = 0;
315
+
316
+ virtual void AddOwnerGUID(const char* name, uint64_t ownerGUID);
317
+
318
+ MemoryDump(const MemoryDump&) = delete;
319
+ MemoryDump& operator=(const MemoryDump&) = delete;
320
+
321
+ protected:
322
+ virtual ~MemoryDump() = default;
323
+ };
324
+ DAWN_NATIVE_EXPORT void DumpMemoryStatistics(WGPUDevice device, MemoryDump* dump);
325
+
326
+ // Intended for background tracing for UMA that returns the estimated memory usage.
327
+ struct DAWN_NATIVE_EXPORT MemoryUsageInfo {
328
+ // Total memory usage.
329
+ uint64_t totalUsage;
330
+ // Total depth stencil textures' memory.
331
+ uint64_t depthStencilTexturesUsage;
332
+ // Total MSAA textures' memory.
333
+ uint64_t msaaTexturesUsage;
334
+ // Number of MSAA textures.
335
+ uint64_t msaaTexturesCount;
336
+ // Largest MSAA texture's memory.
337
+ uint64_t largestMsaaTextureUsage;
338
+ // Total textures' memory.
339
+ uint64_t texturesUsage;
340
+ // Total buffers' memory.
341
+ uint64_t buffersUsage;
342
+ };
343
+ DAWN_NATIVE_EXPORT MemoryUsageInfo ComputeEstimatedMemoryUsageInfo(WGPUDevice device);
344
+
345
+ // Memory information gathered from backend specific allocators.
346
+ // - memory allocated by clients for objects such as buffers, textures.
347
+ // - heap memory used by the allocator for allocations.
348
+ struct DAWN_NATIVE_EXPORT AllocatorMemoryInfo {
349
+ uint64_t totalUsedMemory = 0;
350
+ uint64_t totalAllocatedMemory = 0;
351
+ uint64_t totalLazyAllocatedMemory = 0;
352
+ uint64_t totalLazyUsedMemory = 0;
353
+ };
354
+ DAWN_NATIVE_EXPORT AllocatorMemoryInfo GetAllocatorMemoryInfo(WGPUDevice device);
355
+
356
+ // Free any unused GPU memory like staging buffers, cached resources, etc. Returns true if there are
357
+ // still objects to delete and ReduceMemoryUsage() should be run again after a short delay to allow
358
+ // submitted work to complete.
359
+ DAWN_NATIVE_EXPORT bool ReduceMemoryUsage(WGPUDevice device);
360
+
361
+ // Perform tasks that are appropriate to do when idle like serializing pipeline
362
+ // caches, etc.
363
+ DAWN_NATIVE_EXPORT void PerformIdleTasks(const wgpu::Device& device);
364
+
365
+ DAWN_NATIVE_EXPORT bool IsDeviceLost(WGPUDevice device);
366
+
367
+ } // namespace dawn::native
368
+
369
+ #endif // INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
@@ -0,0 +1,56 @@
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_METALBACKEND_H_
29
+ #define INCLUDE_DAWN_NATIVE_METALBACKEND_H_
30
+
31
+ #include <webgpu/webgpu.h>
32
+
33
+ #include "dawn/native/dawn_native_export.h"
34
+
35
+ #if defined(__OBJC__)
36
+ #import <Metal/Metal.h>
37
+ #endif
38
+
39
+ namespace dawn::native::metal {
40
+
41
+ // When making Metal interop with other APIs, we need to be careful that QueueSubmit doesn't
42
+ // mean that the operations will be visible to other APIs/Metal devices right away. macOS
43
+ // does have a global queue of graphics operations, but the command buffers are inserted there
44
+ // when they are "scheduled". Submitting other operations before the command buffer is
45
+ // scheduled could lead to races in who gets scheduled first and incorrect rendering.
46
+ // TODO(crbug.com/444702048): Remove after migrating Chromium to commands scheduled futures.
47
+ DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
48
+
49
+ #if defined(__OBJC__)
50
+ // Return the MTLDevice corresponding to the WGPUDevice.
51
+ DAWN_NATIVE_EXPORT id<MTLDevice> GetMTLDevice(WGPUDevice device);
52
+ #endif
53
+
54
+ } // namespace dawn::native::metal
55
+
56
+ #endif // INCLUDE_DAWN_NATIVE_METALBACKEND_H_
@@ -0,0 +1,39 @@
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_
@@ -0,0 +1,89 @@
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;
58
+ EGLDisplay display;
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;
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;
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_