react-native-wgpu 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/android/cpp/AndroidPlatformContext.h +1 -1
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +41 -33
- package/android/src/main/java/com/webgpu/{SurfaceView2.java → WebGPUSurfaceViewWithSC.java} +3 -3
- package/android/src/main/java/com/webgpu/WebGPUView.java +15 -42
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +3 -3
- package/android/src/oldarch/com/webgpu/WebGPUViewManagerSpec.java +1 -1
- package/apple/ApplePlatformContext.mm +11 -3
- package/apple/MetalView.h +2 -2
- package/apple/MetalView.mm +12 -0
- package/apple/RNWGUIKit.h +11 -0
- package/apple/WebGPUModule.mm +3 -12
- package/apple/WebGPUViewManager.mm +3 -2
- package/cpp/dawn/dawn_proc.h +50 -0
- package/cpp/dawn/dawn_proc_table.h +300 -0
- package/cpp/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/native/D3D11Backend.h +64 -0
- package/cpp/dawn/native/D3D12Backend.h +68 -0
- package/cpp/dawn/native/D3DBackend.h +59 -0
- package/cpp/dawn/native/DawnNative.h +313 -0
- package/cpp/dawn/native/MetalBackend.h +55 -0
- package/cpp/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/native/OpenGLBackend.h +82 -0
- package/cpp/dawn/native/VulkanBackend.h +183 -0
- package/cpp/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/platform/DawnPlatform.h +165 -0
- package/cpp/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/webgpu_cpp_print.h +2484 -0
- package/cpp/rnwgpu/api/GPU.h +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +4 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -16
- package/cpp/webgpu/webgpu_glfw.h +71 -0
- package/lib/commonjs/Canvas.js +2 -5
- package/lib/commonjs/Canvas.js.map +1 -1
- package/lib/module/Canvas.js +2 -5
- package/lib/module/Canvas.js.map +1 -1
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/Canvas.d.ts +1 -2
- package/lib/typescript/src/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -2
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
- package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/package.json +2 -1
- package/react-native-wgpu.podspec +1 -1
- package/src/Canvas.tsx +51 -65
- package/src/WebGPUViewNativeComponent.ts +2 -2
- package/cpp/rnwgpu/api/WebGPUCanvasContextFactory.h +0 -59
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
// TODO(crbug.com/347047627): These methods are historical duplicates of
|
|
93
|
+
// those in webgpu_cpp.h. Update uses of these methods and remove them.
|
|
94
|
+
wgpu::Status GetInfo(wgpu::AdapterInfo* info) const;
|
|
95
|
+
wgpu::Status GetInfo(WGPUAdapterInfo* info) const;
|
|
96
|
+
std::vector<const char*> GetSupportedFeatures() const;
|
|
97
|
+
wgpu::ConvertibleStatus GetLimits(WGPUSupportedLimits* limits) const;
|
|
98
|
+
|
|
99
|
+
void SetUseTieredLimits(bool useTieredLimits);
|
|
100
|
+
|
|
101
|
+
// Check that the Adapter is able to support importing external images. This is necessary
|
|
102
|
+
// to implement the swapchain and interop APIs in Chromium.
|
|
103
|
+
bool SupportsExternalImages() const;
|
|
104
|
+
|
|
105
|
+
explicit operator bool() const;
|
|
106
|
+
|
|
107
|
+
// Create a device on this adapter. On an error, nullptr is returned.
|
|
108
|
+
WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
|
|
109
|
+
WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
|
|
110
|
+
|
|
111
|
+
void RequestDevice(const wgpu::DeviceDescriptor* descriptor,
|
|
112
|
+
WGPURequestDeviceCallback callback,
|
|
113
|
+
void* userdata);
|
|
114
|
+
void RequestDevice(const WGPUDeviceDescriptor* descriptor,
|
|
115
|
+
WGPURequestDeviceCallback callback,
|
|
116
|
+
void* userdata);
|
|
117
|
+
void RequestDevice(std::nullptr_t descriptor,
|
|
118
|
+
WGPURequestDeviceCallback callback,
|
|
119
|
+
void* userdata) {
|
|
120
|
+
RequestDevice(static_cast<const wgpu::DeviceDescriptor*>(descriptor), callback, userdata);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Returns the underlying WGPUAdapter object.
|
|
124
|
+
WGPUAdapter Get() const;
|
|
125
|
+
|
|
126
|
+
// Reset the backend device object for testing purposes.
|
|
127
|
+
void ResetInternalDeviceForTesting();
|
|
128
|
+
|
|
129
|
+
private:
|
|
130
|
+
AdapterBase* mImpl = nullptr;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
enum BackendValidationLevel { Full, Partial, Disabled };
|
|
134
|
+
|
|
135
|
+
// Can be chained in InstanceDescriptor
|
|
136
|
+
struct DAWN_NATIVE_EXPORT DawnInstanceDescriptor : wgpu::ChainedStruct {
|
|
137
|
+
DawnInstanceDescriptor();
|
|
138
|
+
uint32_t additionalRuntimeSearchPathsCount = 0;
|
|
139
|
+
const char* const* additionalRuntimeSearchPaths;
|
|
140
|
+
dawn::platform::Platform* platform = nullptr;
|
|
141
|
+
|
|
142
|
+
BackendValidationLevel backendValidationLevel = BackendValidationLevel::Disabled;
|
|
143
|
+
bool beginCaptureOnStartup = false;
|
|
144
|
+
|
|
145
|
+
WGPULoggingCallback loggingCallback = nullptr;
|
|
146
|
+
void* loggingCallbackUserdata = nullptr;
|
|
147
|
+
|
|
148
|
+
// Equality operators, mostly for testing. Note that this tests
|
|
149
|
+
// strict pointer-pointer equality if the struct contains member pointers.
|
|
150
|
+
bool operator==(const DawnInstanceDescriptor& rhs) const;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Represents a connection to dawn_native and is used for dependency injection, discovering
|
|
154
|
+
// system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter).
|
|
155
|
+
//
|
|
156
|
+
// This is an RAII class for Dawn instances and also controls the lifetime of all adapters
|
|
157
|
+
// for this instance.
|
|
158
|
+
class DAWN_NATIVE_EXPORT Instance {
|
|
159
|
+
public:
|
|
160
|
+
explicit Instance(const WGPUInstanceDescriptor* desc = nullptr);
|
|
161
|
+
explicit Instance(InstanceBase* impl);
|
|
162
|
+
~Instance();
|
|
163
|
+
|
|
164
|
+
Instance(const Instance& other) = delete;
|
|
165
|
+
Instance& operator=(const Instance& other) = delete;
|
|
166
|
+
|
|
167
|
+
// Discovers and returns a vector of adapters.
|
|
168
|
+
// All systems adapters that can be found are returned if no options are passed.
|
|
169
|
+
// Otherwise, returns adapters based on the `options`. Adapter toggles descriptor can chained
|
|
170
|
+
// after options.
|
|
171
|
+
std::vector<Adapter> EnumerateAdapters(const WGPURequestAdapterOptions* options) const;
|
|
172
|
+
std::vector<Adapter> EnumerateAdapters(
|
|
173
|
+
const wgpu::RequestAdapterOptions* options = nullptr) const;
|
|
174
|
+
|
|
175
|
+
const ToggleInfo* GetToggleInfo(const char* toggleName);
|
|
176
|
+
|
|
177
|
+
// Enables backend validation layers
|
|
178
|
+
void SetBackendValidationLevel(BackendValidationLevel validationLevel);
|
|
179
|
+
|
|
180
|
+
uint64_t GetDeviceCountForTesting() const;
|
|
181
|
+
// Backdoor to get the number of deprecation warnings for testing
|
|
182
|
+
uint64_t GetDeprecationWarningCountForTesting() const;
|
|
183
|
+
|
|
184
|
+
// Returns the underlying WGPUInstance object.
|
|
185
|
+
WGPUInstance Get() const;
|
|
186
|
+
|
|
187
|
+
// Make mImpl->mPlatform point to an object inside Dawn in case it becomes a dangling pointer
|
|
188
|
+
void DisconnectDawnPlatform();
|
|
189
|
+
|
|
190
|
+
private:
|
|
191
|
+
InstanceBase* mImpl = nullptr;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// Backend-agnostic API for dawn_native
|
|
195
|
+
DAWN_NATIVE_EXPORT const DawnProcTable& GetProcs();
|
|
196
|
+
|
|
197
|
+
// Query the names of all the toggles that are enabled in device
|
|
198
|
+
DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(WGPUDevice device);
|
|
199
|
+
|
|
200
|
+
// Backdoor to get the number of lazy clears for testing
|
|
201
|
+
DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
|
|
202
|
+
|
|
203
|
+
// Query if texture has been initialized
|
|
204
|
+
DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(
|
|
205
|
+
WGPUTexture texture,
|
|
206
|
+
uint32_t baseMipLevel,
|
|
207
|
+
uint32_t levelCount,
|
|
208
|
+
uint32_t baseArrayLayer,
|
|
209
|
+
uint32_t layerCount,
|
|
210
|
+
WGPUTextureAspect aspect = WGPUTextureAspect_All);
|
|
211
|
+
|
|
212
|
+
// Backdoor to get the order of the ProcMap for testing
|
|
213
|
+
DAWN_NATIVE_EXPORT std::vector<std::string_view> GetProcMapNamesForTesting();
|
|
214
|
+
|
|
215
|
+
DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device);
|
|
216
|
+
|
|
217
|
+
DAWN_NATIVE_EXPORT bool InstanceProcessEvents(WGPUInstance instance);
|
|
218
|
+
|
|
219
|
+
// ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp
|
|
220
|
+
DAWN_NATIVE_EXPORT void EnableErrorInjector();
|
|
221
|
+
DAWN_NATIVE_EXPORT void DisableErrorInjector();
|
|
222
|
+
DAWN_NATIVE_EXPORT void ClearErrorInjector();
|
|
223
|
+
DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount();
|
|
224
|
+
DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index);
|
|
225
|
+
|
|
226
|
+
// The different types of external images
|
|
227
|
+
enum ExternalImageType {
|
|
228
|
+
OpaqueFD,
|
|
229
|
+
DmaBuf,
|
|
230
|
+
IOSurface,
|
|
231
|
+
EGLImage,
|
|
232
|
+
GLTexture,
|
|
233
|
+
AHardwareBuffer,
|
|
234
|
+
Last = AHardwareBuffer,
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// Common properties of external images
|
|
238
|
+
struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
|
|
239
|
+
public:
|
|
240
|
+
const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params
|
|
241
|
+
bool isInitialized; // Whether the texture is initialized on import
|
|
242
|
+
ExternalImageType GetType() const;
|
|
243
|
+
|
|
244
|
+
protected:
|
|
245
|
+
explicit ExternalImageDescriptor(ExternalImageType type);
|
|
246
|
+
|
|
247
|
+
private:
|
|
248
|
+
ExternalImageType mType;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
|
|
252
|
+
public:
|
|
253
|
+
bool isInitialized = false; // Whether the texture is initialized after export
|
|
254
|
+
ExternalImageType GetType() const;
|
|
255
|
+
|
|
256
|
+
protected:
|
|
257
|
+
explicit ExternalImageExportInfo(ExternalImageType type);
|
|
258
|
+
|
|
259
|
+
private:
|
|
260
|
+
ExternalImageType mType;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
DAWN_NATIVE_EXPORT bool CheckIsErrorForTesting(void* objectHandle);
|
|
264
|
+
|
|
265
|
+
DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle);
|
|
266
|
+
|
|
267
|
+
DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer);
|
|
268
|
+
|
|
269
|
+
DAWN_NATIVE_EXPORT std::vector<const ToggleInfo*> AllToggleInfos();
|
|
270
|
+
|
|
271
|
+
// Used to query the details of an feature. Return nullptr if featureName is not a valid
|
|
272
|
+
// name of an feature supported in Dawn.
|
|
273
|
+
DAWN_NATIVE_EXPORT const FeatureInfo* GetFeatureInfo(wgpu::FeatureName feature);
|
|
274
|
+
|
|
275
|
+
class DAWN_NATIVE_EXPORT MemoryDump {
|
|
276
|
+
public:
|
|
277
|
+
// Standard attribute |name|s for the AddScalar() and AddString() methods.
|
|
278
|
+
// These match the expected names in Chromium memory-infra instrumentation.
|
|
279
|
+
static const char kNameSize[]; // To represent allocated space.
|
|
280
|
+
static const char kNameObjectCount[]; // To represent number of objects.
|
|
281
|
+
|
|
282
|
+
// Standard attribute |unit|s for the AddScalar() and AddString() methods.
|
|
283
|
+
// These match the expected names in Chromium memory-infra instrumentation.
|
|
284
|
+
static const char kUnitsBytes[]; // Unit name to represent bytes.
|
|
285
|
+
static const char kUnitsObjects[]; // Unit name to represent #objects.
|
|
286
|
+
|
|
287
|
+
MemoryDump() = default;
|
|
288
|
+
|
|
289
|
+
virtual void AddScalar(const char* name,
|
|
290
|
+
const char* key,
|
|
291
|
+
const char* units,
|
|
292
|
+
uint64_t value) = 0;
|
|
293
|
+
|
|
294
|
+
virtual void AddString(const char* name, const char* key, const std::string& value) = 0;
|
|
295
|
+
|
|
296
|
+
MemoryDump(const MemoryDump&) = delete;
|
|
297
|
+
MemoryDump& operator=(const MemoryDump&) = delete;
|
|
298
|
+
|
|
299
|
+
protected:
|
|
300
|
+
virtual ~MemoryDump() = default;
|
|
301
|
+
};
|
|
302
|
+
DAWN_NATIVE_EXPORT void DumpMemoryStatistics(WGPUDevice device, MemoryDump* dump);
|
|
303
|
+
|
|
304
|
+
// Unlike memory dumps which include detailed information about allocations, this only returns the
|
|
305
|
+
// total estimated memory usage, and is intended for background tracing for UMA.
|
|
306
|
+
DAWN_NATIVE_EXPORT uint64_t ComputeEstimatedMemoryUsage(WGPUDevice device);
|
|
307
|
+
|
|
308
|
+
// Free any unused GPU memory like staging buffers, cached resources, etc.
|
|
309
|
+
DAWN_NATIVE_EXPORT void ReduceMemoryUsage(WGPUDevice device);
|
|
310
|
+
|
|
311
|
+
} // namespace dawn::native
|
|
312
|
+
|
|
313
|
+
#endif // INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
|
|
47
|
+
|
|
48
|
+
#if defined(__OBJC__)
|
|
49
|
+
// Return the MTLDevice corresponding to the WGPUDevice.
|
|
50
|
+
DAWN_NATIVE_EXPORT id<MTLDevice> GetMTLDevice(WGPUDevice device);
|
|
51
|
+
#endif
|
|
52
|
+
|
|
53
|
+
} // namespace dawn::native::metal
|
|
54
|
+
|
|
55
|
+
#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,82 @@
|
|
|
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
|
+
|
|
40
|
+
// Define a GetProc function pointer that mirrors the one in egl.h
|
|
41
|
+
#if defined(_WIN32)
|
|
42
|
+
#define DAWN_STDCALL __stdcall
|
|
43
|
+
#else // defined(_WIN32)
|
|
44
|
+
#define DAWN_STDCALL
|
|
45
|
+
#endif // defined(_WIN32)
|
|
46
|
+
|
|
47
|
+
using EGLFunctionPointerType = void (*)();
|
|
48
|
+
// NOLINTNEXTLINE(readability/casting): cpplint thinks this is a C-style cast but it isn't.
|
|
49
|
+
using EGLGetProcProc = EGLFunctionPointerType(DAWN_STDCALL*)(const char*);
|
|
50
|
+
#undef DAWN_STDCALL
|
|
51
|
+
|
|
52
|
+
// Can be chained in WGPURequestAdapterOptions
|
|
53
|
+
struct DAWN_NATIVE_EXPORT RequestAdapterOptionsGetGLProc : wgpu::ChainedStruct {
|
|
54
|
+
RequestAdapterOptionsGetGLProc();
|
|
55
|
+
|
|
56
|
+
EGLGetProcProc getProc;
|
|
57
|
+
EGLDisplay display;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorEGLImage : ExternalImageDescriptor {
|
|
61
|
+
public:
|
|
62
|
+
ExternalImageDescriptorEGLImage();
|
|
63
|
+
|
|
64
|
+
EGLImage image;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
DAWN_NATIVE_EXPORT WGPUTexture
|
|
68
|
+
WrapExternalEGLImage(WGPUDevice device, const ExternalImageDescriptorEGLImage* descriptor);
|
|
69
|
+
|
|
70
|
+
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorGLTexture : ExternalImageDescriptor {
|
|
71
|
+
public:
|
|
72
|
+
ExternalImageDescriptorGLTexture();
|
|
73
|
+
|
|
74
|
+
GLuint texture;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
DAWN_NATIVE_EXPORT WGPUTexture
|
|
78
|
+
WrapExternalGLTexture(WGPUDevice device, const ExternalImageDescriptorGLTexture* descriptor);
|
|
79
|
+
|
|
80
|
+
} // namespace dawn::native::opengl
|
|
81
|
+
|
|
82
|
+
#endif // INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
|
|
@@ -0,0 +1,183 @@
|
|
|
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;
|
|
79
|
+
VkImageLayout releasedNewLayout;
|
|
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; // 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; // Must match VkMemoryAllocateInfo from image creation
|
|
106
|
+
uint32_t memoryTypeIndex; // 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;
|
|
112
|
+
uint32_t stride;
|
|
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; // 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_
|