react-native-wgpu 0.3.1 → 0.3.2

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.
@@ -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,82 +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
-
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_
@@ -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;
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_
@@ -1,49 +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_DAWN_NATIVE_EXPORT_H_
29
- #define INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
30
-
31
- #if defined(DAWN_NATIVE_SHARED_LIBRARY)
32
- #if defined(_WIN32)
33
- #if defined(DAWN_NATIVE_IMPLEMENTATION)
34
- #define DAWN_NATIVE_EXPORT __declspec(dllexport)
35
- #else
36
- #define DAWN_NATIVE_EXPORT __declspec(dllimport)
37
- #endif
38
- #else // defined(_WIN32)
39
- #if defined(DAWN_NATIVE_IMPLEMENTATION)
40
- #define DAWN_NATIVE_EXPORT __attribute__((visibility("default")))
41
- #else
42
- #define DAWN_NATIVE_EXPORT
43
- #endif
44
- #endif // defined(_WIN32)
45
- #else // defined(DAWN_NATIVE_SHARED_LIBRARY)
46
- #define DAWN_NATIVE_EXPORT
47
- #endif // defined(DAWN_NATIVE_SHARED_LIBRARY)
48
-
49
- #endif // INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_