react-native-webgpu 0.23.0 → 0.25.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 (127) hide show
  1. package/Package.swift +18 -129
  2. package/android/CMakeLists.txt +1 -0
  3. package/android/cpp/AndroidPlatformContext.h +10 -9
  4. package/android/cpp/cpp-adapter.cpp +19 -96
  5. package/android/src/main/java/com/webgpu/BackingViewKind.java +5 -22
  6. package/android/src/main/java/com/webgpu/WebGPUAPI.java +0 -2
  7. package/android/src/main/java/com/webgpu/WebGPUModule.java +34 -3
  8. package/android/src/main/java/com/webgpu/WebGPUVideoPlayer.java +1 -1
  9. package/android/src/main/java/com/webgpu/WebGPUView.java +17 -34
  10. package/apple/ApplePlatformContext.h +2 -1
  11. package/apple/ApplePlatformContext.mm +2 -2
  12. package/apple/WebGPUModule.mm +22 -0
  13. package/binaries.json +53 -105
  14. package/cpp/dawn/common/ExternalTextureParams.h +3 -3
  15. package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
  16. package/cpp/dawn/include/dawn/dawn_proc_table.h +329 -0
  17. package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
  18. package/cpp/dawn/include/dawn/dawn_version.h +51 -0
  19. package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
  20. package/cpp/dawn/include/dawn/native/D3D12Backend.h +104 -0
  21. package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
  22. package/cpp/dawn/include/dawn/native/DawnNative.h +375 -0
  23. package/cpp/dawn/include/dawn/native/MetalBackend.h +67 -0
  24. package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
  25. package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
  26. package/cpp/dawn/include/dawn/native/VulkanBackend.h +199 -0
  27. package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
  28. package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
  29. package/cpp/dawn/include/dawn/platform/DawnPlatform.h +210 -0
  30. package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
  31. package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
  32. package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
  33. package/cpp/dawn/include/dawn/webgpu.h +5119 -0
  34. package/cpp/dawn/include/dawn/webgpu_cpp.h +10506 -0
  35. package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2897 -0
  36. package/cpp/dawn/include/webgpu/webgpu.h +33 -0
  37. package/cpp/dawn/include/webgpu/webgpu_cpp.h +33 -0
  38. package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
  39. package/cpp/dawn/include/webgpu/webgpu_cpp_print.h +33 -0
  40. package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +163 -0
  41. package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
  42. package/cpp/rnwgpu/GpuPurge.cpp +86 -0
  43. package/cpp/rnwgpu/GpuPurge.h +66 -0
  44. package/cpp/rnwgpu/PlatformContext.h +1 -1
  45. package/cpp/rnwgpu/SurfaceRegistry.h +2 -612
  46. package/cpp/rnwgpu/api/GPUAdapter.cpp +1 -1
  47. package/cpp/rnwgpu/api/GPUDevice.cpp +59 -32
  48. package/cpp/rnwgpu/api/GPUDevice.h +49 -4
  49. package/cpp/rnwgpu/api/RNWebGPU.h +11 -4
  50. package/lib/commonjs/Canvas.js +8 -26
  51. package/lib/commonjs/Canvas.js.map +1 -1
  52. package/lib/commonjs/main/index.js +12 -0
  53. package/lib/commonjs/main/index.js.map +1 -1
  54. package/lib/commonjs/main/index.web.js +11 -0
  55. package/lib/commonjs/main/index.web.js.map +1 -1
  56. package/lib/commonjs/mock.js +4 -1
  57. package/lib/commonjs/mock.js.map +1 -1
  58. package/lib/commonjs/purgeGpuResources.js +29 -0
  59. package/lib/commonjs/purgeGpuResources.js.map +1 -0
  60. package/lib/commonjs/video.js +8 -4
  61. package/lib/commonjs/video.js.map +1 -1
  62. package/lib/module/Canvas.js +8 -26
  63. package/lib/module/Canvas.js.map +1 -1
  64. package/lib/module/main/index.js +1 -0
  65. package/lib/module/main/index.js.map +1 -1
  66. package/lib/module/main/index.web.js +1 -0
  67. package/lib/module/main/index.web.js.map +1 -1
  68. package/lib/module/mock.js +1 -0
  69. package/lib/module/mock.js.map +1 -1
  70. package/lib/module/purgeGpuResources.js +22 -0
  71. package/lib/module/purgeGpuResources.js.map +1 -0
  72. package/lib/module/video.js +6 -2
  73. package/lib/module/video.js.map +1 -1
  74. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
  75. package/lib/typescript/lib/commonjs/mock.d.ts +1 -0
  76. package/lib/typescript/lib/commonjs/mock.d.ts.map +1 -1
  77. package/lib/typescript/lib/commonjs/purgeGpuResources.d.ts +18 -0
  78. package/lib/typescript/lib/commonjs/purgeGpuResources.d.ts.map +1 -0
  79. package/lib/typescript/lib/commonjs/video.d.ts +6 -2
  80. package/lib/typescript/lib/commonjs/video.d.ts.map +1 -1
  81. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  82. package/lib/typescript/lib/module/main/index.d.ts +1 -0
  83. package/lib/typescript/lib/module/main/index.web.d.ts +1 -0
  84. package/lib/typescript/lib/module/mock.d.ts +1 -0
  85. package/lib/typescript/lib/module/mock.d.ts.map +1 -1
  86. package/lib/typescript/lib/module/purgeGpuResources.d.ts +2 -0
  87. package/lib/typescript/lib/module/purgeGpuResources.d.ts.map +1 -0
  88. package/lib/typescript/lib/module/video.d.ts +1 -1
  89. package/lib/typescript/lib/module/video.d.ts.map +1 -1
  90. package/lib/typescript/react-native.config.d.ts +1 -0
  91. package/lib/typescript/src/Canvas.d.ts +2 -12
  92. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  93. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +1 -1
  94. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  95. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +1 -1
  96. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  97. package/lib/typescript/src/index.d.ts +3 -2
  98. package/lib/typescript/src/index.d.ts.map +1 -1
  99. package/lib/typescript/src/main/index.d.ts +1 -0
  100. package/lib/typescript/src/main/index.d.ts.map +1 -1
  101. package/lib/typescript/src/main/index.web.d.ts +1 -0
  102. package/lib/typescript/src/main/index.web.d.ts.map +1 -1
  103. package/lib/typescript/src/mock.d.ts +2 -1
  104. package/lib/typescript/src/mock.d.ts.map +1 -1
  105. package/lib/typescript/src/purgeGpuResources.d.ts +17 -0
  106. package/lib/typescript/src/purgeGpuResources.d.ts.map +1 -0
  107. package/lib/typescript/src/types.d.ts +1 -1
  108. package/lib/typescript/src/types.d.ts.map +1 -1
  109. package/lib/typescript/src/video.d.ts +7 -3
  110. package/lib/typescript/src/video.d.ts.map +1 -1
  111. package/package.json +10 -5
  112. package/react-native-webgpu.podspec +46 -78
  113. package/react-native.config.js +9 -6
  114. package/scripts/apple-binaries-utils.sh +280 -0
  115. package/scripts/prepare-apple-binaries.sh +309 -0
  116. package/scripts/spm-plugin.js +130 -0
  117. package/src/Canvas.tsx +12 -50
  118. package/src/WebGPUViewNativeComponent.ts +1 -1
  119. package/src/WebGPUViewNativeComponent.web.ts +1 -1
  120. package/src/index.tsx +5 -4
  121. package/src/main/index.tsx +1 -0
  122. package/src/main/index.web.tsx +1 -0
  123. package/src/mock.ts +2 -1
  124. package/src/purgeGpuResources.ts +21 -0
  125. package/src/types.ts +1 -1
  126. package/src/video.ts +12 -5
  127. package/android/src/main/java/com/webgpu/WebGPUHardwareBufferView.java +0 -278
@@ -0,0 +1,47 @@
1
+ // Copyright 2020 The Dawn & Tint Authors
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without
4
+ // modification, are permitted provided that the following conditions are met:
5
+ //
6
+ // 1. Redistributions of source code must retain the above copyright notice, this
7
+ // list of conditions and the following disclaimer.
8
+ //
9
+ // 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ // this list of conditions and the following disclaimer in the documentation
11
+ // and/or other materials provided with the distribution.
12
+ //
13
+ // 3. Neither the name of the copyright holder nor the names of its
14
+ // contributors may be used to endorse or promote products derived from
15
+ // this software without specific prior written permission.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_
29
+ #define INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_
30
+
31
+ #include "dawn/dawn_proc.h"
32
+
33
+ #ifdef __cplusplus
34
+ extern "C" {
35
+ #endif
36
+
37
+ // Call dawnProcSetProcs(&dawnThreadDispatchProcTable) and then use dawnProcSetPerThreadProcs
38
+ // to set per-thread procs.
39
+ WGPU_EXPORT extern DawnProcTable dawnThreadDispatchProcTable;
40
+ WGPU_EXPORT void dawnProcSetDefaultThreadProcs(const DawnProcTable* procs);
41
+ WGPU_EXPORT void dawnProcSetPerThreadProcs(const DawnProcTable* procs);
42
+
43
+ #ifdef __cplusplus
44
+ } // extern "C"
45
+ #endif
46
+
47
+ #endif // INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_
@@ -0,0 +1,51 @@
1
+ // Copyright 2026 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_DAWN_VERSION_H_
29
+ #define INCLUDE_DAWN_DAWN_VERSION_H_
30
+
31
+ #include <stdint.h>
32
+
33
+ // The full 64-bit Dawn version reserves the top 24 bits for the major version and the bottom 40
34
+ // bits for the minor version.
35
+ #define DAWN_MAKE_VERSION(major, minor) ((UINT64_C(major) << UINT64_C(40)) | UINT64_C(minor))
36
+ #define DAWN_MAJOR_VERSION 1
37
+ #define DAWN_MINOR_VERSION 2026101200
38
+ #define DAWN_VERSION DAWN_MAKE_VERSION(DAWN_MAJOR_VERSION, DAWN_MINOR_VERSION)
39
+
40
+ #ifdef __cplusplus
41
+ #include <array>
42
+
43
+ namespace dawn {
44
+
45
+ // The version is a 20-byte SHA1 hash. If the hash is not available, it is all zeros.
46
+ static constexpr std::array<uint8_t, 20> kDawnVersion = { 0x17, 0x16, 0xe8, 0x8c, 0xc9, 0xe5, 0x83, 0x98, 0xfa, 0xb5, 0xd4, 0x47, 0x3f, 0x7f, 0x2e, 0x85, 0x86, 0x67, 0xb6, 0x77 };
47
+
48
+ } // namespace dawn
49
+ #endif // __cplusplus
50
+
51
+ #endif // INCLUDE_DAWN_DAWN_VERSION_H_
@@ -0,0 +1,65 @@
1
+ // Copyright 2023 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_D3D11BACKEND_H_
29
+ #define INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_
30
+
31
+ #include <d3d11_1.h>
32
+ #include <wrl/client.h>
33
+
34
+ #include <memory>
35
+ #include <optional>
36
+
37
+ #include "dawn/native/D3DBackend.h"
38
+
39
+ namespace dawn::native::d3d11 {
40
+
41
+ DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D11Device> GetD3D11Device(WGPUDevice device);
42
+
43
+ // May be chained on RequestAdapterOptions
44
+ struct DAWN_NATIVE_EXPORT RequestAdapterOptionsD3D11Device : wgpu::ChainedStruct {
45
+ RequestAdapterOptionsD3D11Device() {
46
+ sType = static_cast<wgpu::SType>(WGPUSType_RequestAdapterOptionsD3D11Device);
47
+ }
48
+
49
+ Microsoft::WRL::ComPtr<ID3D11Device> device;
50
+ };
51
+
52
+ // May be chained on SharedTextureMemoryDescriptor
53
+ struct DAWN_NATIVE_EXPORT SharedTextureMemoryD3D11Texture2DDescriptor : wgpu::ChainedStruct {
54
+ SharedTextureMemoryD3D11Texture2DDescriptor() {
55
+ sType = static_cast<wgpu::SType>(WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor);
56
+ }
57
+
58
+ // This ID3D11Texture2D object must be created from the same ID3D11Device used in the
59
+ // WGPUDevice.
60
+ Microsoft::WRL::ComPtr<ID3D11Texture2D> texture;
61
+ };
62
+
63
+ } // namespace dawn::native::d3d11
64
+
65
+ #endif // INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_
@@ -0,0 +1,104 @@
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_D3D12BACKEND_H_
29
+ #define INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
30
+
31
+ // d3d12.h must be included first, before other d3d headers that may include it, to ensure
32
+ // we pick up the one from the Agility SDK when enabled.
33
+ #if defined(DAWN_USE_AGILITY_SDK)
34
+ // clang-format off
35
+ #if defined(__clang__)
36
+ #pragma clang diagnostic push
37
+ #pragma clang diagnostic ignored "-Wmicrosoft-enum-value"
38
+ #pragma clang diagnostic ignored "-Wnested-anon-types"
39
+ #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
40
+ #endif
41
+ #include "third_party/agility-sdk/src/build/native/include/d3d12.h"
42
+ #if defined(__clang__)
43
+ #pragma clang diagnostic pop
44
+ #endif
45
+ #else // defined(DAWN_USE_AGILITY_SDK)
46
+ #include <d3d12.h>
47
+ #endif // defined(DAWN_USE_AGILITY_SDK)
48
+ // clang-format on
49
+
50
+ #include <d3d11on12.h>
51
+ #include <dxgi1_4.h>
52
+ #include <wrl/client.h>
53
+
54
+ #include "dawn/native/D3DBackend.h"
55
+
56
+ struct ID3D12Device;
57
+ struct ID3D12Resource;
58
+
59
+ namespace dawn::native::d3d12 {
60
+
61
+ class Device;
62
+
63
+ enum MemorySegment {
64
+ Local,
65
+ NonLocal,
66
+ };
67
+
68
+ DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
69
+
70
+ DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D11On12Device> GetOrCreateD3D11On12Device(
71
+ WGPUDevice device);
72
+
73
+ DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12CommandQueue> GetD3D12CommandQueue(
74
+ WGPUDevice device);
75
+
76
+ DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
77
+ uint64_t requestedReservationSize,
78
+ MemorySegment memorySegment);
79
+
80
+ // May be chained on SharedBufferMemoryDescriptor
81
+ struct DAWN_NATIVE_EXPORT SharedBufferMemoryD3D12ResourceDescriptor : wgpu::ChainedStruct {
82
+ SharedBufferMemoryD3D12ResourceDescriptor() {
83
+ sType = static_cast<wgpu::SType>(WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor);
84
+ }
85
+
86
+ // This ID3D12Resource object must be created from the same ID3D12Device used in the
87
+ // WGPUDevice.
88
+ Microsoft::WRL::ComPtr<ID3D12Resource> resource;
89
+ };
90
+
91
+ // May be chained on SharedTextureMemoryDescriptor.
92
+ struct DAWN_NATIVE_EXPORT SharedTextureMemoryD3D12ResourceDescriptor : wgpu::ChainedStruct {
93
+ SharedTextureMemoryD3D12ResourceDescriptor() {
94
+ sType = static_cast<wgpu::SType>(WGPUSType_SharedTextureMemoryD3D12ResourceDescriptor);
95
+ }
96
+
97
+ // This ID3D12Resource object must be created from the same ID3D12Device used in the
98
+ // WGPUDevice.
99
+ Microsoft::WRL::ComPtr<ID3D12Resource> resource;
100
+ };
101
+
102
+ } // namespace dawn::native::d3d12
103
+
104
+ #endif // INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
@@ -0,0 +1,56 @@
1
+ // Copyright 2023 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_D3DBACKEND_H_
29
+ #define INCLUDE_DAWN_NATIVE_D3DBACKEND_H_
30
+
31
+ #include <dxgi1_4.h>
32
+ #include <webgpu/webgpu_cpp_chained_struct.h>
33
+ #include <wrl/client.h>
34
+
35
+ #include <memory>
36
+ #include <vector>
37
+
38
+ #include "dawn/native/DawnNative.h"
39
+
40
+ namespace dawn::native::d3d {
41
+
42
+ DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<IDXGIAdapter> GetDXGIAdapter(WGPUAdapter adapter);
43
+
44
+ // Can be chained in WGPURequestAdapterOptions
45
+ struct DAWN_NATIVE_EXPORT RequestAdapterOptionsLUID : wgpu::ChainedStruct {
46
+ RequestAdapterOptionsLUID();
47
+
48
+ ::LUID adapterLUID{};
49
+ };
50
+
51
+ // Chrome uses 0 as acquire key.
52
+ static constexpr uint64_t kDXGIKeyedMutexAcquireKey = 0;
53
+
54
+ } // namespace dawn::native::d3d
55
+
56
+ #endif // INCLUDE_DAWN_NATIVE_D3DBACKEND_H_