react-native-wgpu 0.2.10 → 0.3.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 (258) hide show
  1. package/README.md +155 -69
  2. package/android/CMakeLists.txt +5 -7
  3. package/android/build.gradle +7 -18
  4. package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +34 -10
  5. package/apple/MetalView.mm +0 -19
  6. package/apple/WebGPUModule.h +1 -9
  7. package/apple/WebGPUModule.mm +0 -3
  8. package/apple/WebGPUView.h +0 -3
  9. package/apple/WebGPUView.mm +0 -2
  10. package/cpp/WGPULogger.h +10 -0
  11. package/cpp/dawn/dawn_proc_table.h +1 -1
  12. package/cpp/dawn/webgpu.h +4855 -0
  13. package/cpp/dawn/webgpu_cpp.h +10168 -0
  14. package/cpp/dawn/wire/client/webgpu.h +354 -0
  15. package/cpp/dawn/wire/client/webgpu_cpp.h +10343 -0
  16. package/cpp/dawn/wire/client/webgpu_cpp_print.h +2715 -0
  17. package/cpp/jsi/RNFHybridObject.cpp +8 -4
  18. package/cpp/jsi/RNFHybridObject.h +7 -2
  19. package/cpp/jsi/RNFJSIConverter.h +13 -102
  20. package/cpp/jsi/RNFJSIHelper.h +5 -3
  21. package/cpp/jsi/RNFRuntimeState.cpp +18 -0
  22. package/cpp/jsi/RNFRuntimeState.h +106 -0
  23. package/cpp/rnwgpu/RNWebGPUManager.cpp +1 -9
  24. package/cpp/rnwgpu/api/GPU.cpp +51 -26
  25. package/cpp/rnwgpu/api/GPU.h +5 -18
  26. package/cpp/rnwgpu/api/GPUAdapter.cpp +79 -54
  27. package/cpp/rnwgpu/api/GPUAdapter.h +6 -6
  28. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -1
  29. package/cpp/rnwgpu/api/GPUBindGroup.h +1 -3
  30. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +1 -3
  31. package/cpp/rnwgpu/api/GPUBuffer.cpp +35 -32
  32. package/cpp/rnwgpu/api/GPUBuffer.h +9 -7
  33. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +5 -1
  34. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -2
  35. package/cpp/rnwgpu/api/GPUCommandBuffer.h +1 -3
  36. package/cpp/rnwgpu/api/GPUCommandEncoder.h +1 -3
  37. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -2
  38. package/cpp/rnwgpu/api/GPUCompilationMessage.h +1 -3
  39. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +1 -3
  40. package/cpp/rnwgpu/api/GPUComputePipeline.h +1 -3
  41. package/cpp/rnwgpu/api/GPUDevice.cpp +183 -128
  42. package/cpp/rnwgpu/api/GPUDevice.h +22 -21
  43. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +1 -3
  44. package/cpp/rnwgpu/api/GPUExternalTexture.h +1 -3
  45. package/cpp/rnwgpu/api/GPUPipelineLayout.h +1 -3
  46. package/cpp/rnwgpu/api/GPUQuerySet.h +1 -3
  47. package/cpp/rnwgpu/api/GPUQueue.cpp +19 -8
  48. package/cpp/rnwgpu/api/GPUQueue.h +7 -6
  49. package/cpp/rnwgpu/api/GPURenderBundle.h +1 -3
  50. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +1 -3
  51. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +1 -3
  52. package/cpp/rnwgpu/api/GPURenderPipeline.h +1 -3
  53. package/cpp/rnwgpu/api/GPUSampler.h +1 -3
  54. package/cpp/rnwgpu/api/GPUShaderModule.cpp +42 -28
  55. package/cpp/rnwgpu/api/GPUShaderModule.h +6 -6
  56. package/cpp/rnwgpu/api/GPUSupportedLimits.h +1 -3
  57. package/cpp/rnwgpu/api/GPUTexture.h +1 -3
  58. package/cpp/rnwgpu/api/GPUTextureView.h +1 -3
  59. package/cpp/rnwgpu/api/RNWebGPU.h +1 -7
  60. package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
  61. package/cpp/rnwgpu/async/AsyncRunner.cpp +215 -0
  62. package/cpp/rnwgpu/async/AsyncRunner.h +53 -0
  63. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
  64. package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
  65. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
  66. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
  67. package/cpp/webgpu/webgpu.h +5 -4827
  68. package/cpp/webgpu/webgpu_cpp.h +5 -10140
  69. package/cpp/{dawn/native/WebGPUBackend.h → webgpu/webgpu_cpp_print.h} +4 -20
  70. package/lib/commonjs/Canvas.js +6 -66
  71. package/lib/commonjs/Canvas.js.map +1 -1
  72. package/lib/commonjs/hooks.js +6 -42
  73. package/lib/commonjs/hooks.js.map +1 -1
  74. package/lib/module/Canvas.js +7 -67
  75. package/lib/module/Canvas.js.map +1 -1
  76. package/lib/module/hooks.js +5 -40
  77. package/lib/module/hooks.js.map +1 -1
  78. package/lib/typescript/lib/commonjs/hooks.d.ts +1 -5
  79. package/lib/typescript/lib/commonjs/hooks.d.ts.map +1 -1
  80. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  81. package/lib/typescript/lib/module/hooks.d.ts +1 -5
  82. package/lib/typescript/lib/module/hooks.d.ts.map +1 -1
  83. package/lib/typescript/src/Canvas.d.ts +0 -1
  84. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  85. package/lib/typescript/src/hooks.d.ts +2 -7
  86. package/lib/typescript/src/hooks.d.ts.map +1 -1
  87. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  88. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  89. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  90. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  91. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +5 -35
  92. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  93. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  94. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
  95. package/package.json +4 -3
  96. package/react-native-wgpu.podspec +12 -16
  97. package/src/Canvas.tsx +8 -69
  98. package/src/hooks.tsx +14 -48
  99. package/android/cpp/platform/ThreadUtils.cpp +0 -41
  100. package/android/src/oldarch/com/webgpu/NativeWebGPUModuleSpec.java +0 -23
  101. package/android/src/oldarch/com/webgpu/WebGPUViewManagerSpec.java +0 -12
  102. package/apple/WebGPUViewManager.mm +0 -24
  103. package/apple/platform/ThreadUtils.cpp +0 -34
  104. package/cpp/dawn/dawn_proc.h +0 -50
  105. package/cpp/dawn/dawn_thread_dispatch_proc.h +0 -47
  106. package/cpp/dawn/native/D3D11Backend.h +0 -77
  107. package/cpp/dawn/native/D3D12Backend.h +0 -68
  108. package/cpp/dawn/native/D3DBackend.h +0 -56
  109. package/cpp/dawn/native/MetalBackend.h +0 -56
  110. package/cpp/dawn/platform/DawnPlatform.h +0 -167
  111. package/cpp/dawn/platform/dawn_platform_export.h +0 -49
  112. package/cpp/jsi/RNFRuntimeCache.cpp +0 -57
  113. package/cpp/jsi/RNFRuntimeCache.h +0 -79
  114. package/cpp/jsi/RNFWorkletRuntimeCollector.h +0 -43
  115. package/cpp/jsi/RNFWorkletRuntimeRegistry.cpp +0 -12
  116. package/cpp/jsi/RNFWorkletRuntimeRegistry.h +0 -44
  117. package/cpp/platform/ThreadUtils.h +0 -30
  118. package/cpp/rnwgpu/api/AsyncRunner.h +0 -30
  119. package/cpp/threading/CallInvokerDispatcher.h +0 -37
  120. package/cpp/threading/Dispatcher.cpp +0 -55
  121. package/cpp/threading/Dispatcher.h +0 -93
  122. package/cpp/threading/ThreadPool.cpp +0 -88
  123. package/cpp/threading/ThreadPool.h +0 -53
  124. package/cpp/webgpu/webgpu_glfw.h +0 -88
  125. package/lib/typescript/src/__tests__/Alpha.spec.d.ts +0 -2
  126. package/lib/typescript/src/__tests__/Alpha.spec.d.ts.map +0 -1
  127. package/lib/typescript/src/__tests__/ArrayBuffer.spec.d.ts +0 -2
  128. package/lib/typescript/src/__tests__/ArrayBuffer.spec.d.ts.map +0 -1
  129. package/lib/typescript/src/__tests__/Buffer.spec.d.ts +0 -2
  130. package/lib/typescript/src/__tests__/Buffer.spec.d.ts.map +0 -1
  131. package/lib/typescript/src/__tests__/ComputeShader.spec.d.ts +0 -2
  132. package/lib/typescript/src/__tests__/ComputeShader.spec.d.ts.map +0 -1
  133. package/lib/typescript/src/__tests__/Constants.spec.d.ts +0 -2
  134. package/lib/typescript/src/__tests__/Constants.spec.d.ts.map +0 -1
  135. package/lib/typescript/src/__tests__/Device.spec.d.ts +0 -2
  136. package/lib/typescript/src/__tests__/Device.spec.d.ts.map +0 -1
  137. package/lib/typescript/src/__tests__/ErrorScope.spec.d.ts +0 -2
  138. package/lib/typescript/src/__tests__/ErrorScope.spec.d.ts.map +0 -1
  139. package/lib/typescript/src/__tests__/ExternalTexture.spec.d.ts +0 -2
  140. package/lib/typescript/src/__tests__/ExternalTexture.spec.d.ts.map +0 -1
  141. package/lib/typescript/src/__tests__/GPU.spec.d.ts +0 -2
  142. package/lib/typescript/src/__tests__/GPU.spec.d.ts.map +0 -1
  143. package/lib/typescript/src/__tests__/ImageData.spec.d.ts +0 -2
  144. package/lib/typescript/src/__tests__/ImageData.spec.d.ts.map +0 -1
  145. package/lib/typescript/src/__tests__/Shaders.spec.d.ts +0 -2
  146. package/lib/typescript/src/__tests__/Shaders.spec.d.ts.map +0 -1
  147. package/lib/typescript/src/__tests__/Texture.spec.d.ts +0 -2
  148. package/lib/typescript/src/__tests__/Texture.spec.d.ts.map +0 -1
  149. package/lib/typescript/src/__tests__/components/Wireframe/Shaders.d.ts +0 -3
  150. package/lib/typescript/src/__tests__/components/Wireframe/Shaders.d.ts.map +0 -1
  151. package/lib/typescript/src/__tests__/components/Wireframe/models.d.ts +0 -29
  152. package/lib/typescript/src/__tests__/components/Wireframe/models.d.ts.map +0 -1
  153. package/lib/typescript/src/__tests__/components/Wireframe/utils.d.ts +0 -5
  154. package/lib/typescript/src/__tests__/components/Wireframe/utils.d.ts.map +0 -1
  155. package/lib/typescript/src/__tests__/components/cube.d.ts +0 -7
  156. package/lib/typescript/src/__tests__/components/cube.d.ts.map +0 -1
  157. package/lib/typescript/src/__tests__/components/meshes/mesh.d.ts +0 -22
  158. package/lib/typescript/src/__tests__/components/meshes/mesh.d.ts.map +0 -1
  159. package/lib/typescript/src/__tests__/components/meshes/sphere.d.ts +0 -12
  160. package/lib/typescript/src/__tests__/components/meshes/sphere.d.ts.map +0 -1
  161. package/lib/typescript/src/__tests__/components/meshes/stanfordDragon.d.ts +0 -7
  162. package/lib/typescript/src/__tests__/components/meshes/stanfordDragon.d.ts.map +0 -1
  163. package/lib/typescript/src/__tests__/components/meshes/stanfordDragonData.d.ts +0 -6
  164. package/lib/typescript/src/__tests__/components/meshes/stanfordDragonData.d.ts.map +0 -1
  165. package/lib/typescript/src/__tests__/components/meshes/teapot.d.ts +0 -6
  166. package/lib/typescript/src/__tests__/components/meshes/teapot.d.ts.map +0 -1
  167. package/lib/typescript/src/__tests__/components/meshes/utils.d.ts +0 -10
  168. package/lib/typescript/src/__tests__/components/meshes/utils.d.ts.map +0 -1
  169. package/lib/typescript/src/__tests__/components/triangle.d.ts +0 -3
  170. package/lib/typescript/src/__tests__/components/triangle.d.ts.map +0 -1
  171. package/lib/typescript/src/__tests__/config.d.ts +0 -3
  172. package/lib/typescript/src/__tests__/config.d.ts.map +0 -1
  173. package/lib/typescript/src/__tests__/demos/ABuffer.spec.d.ts +0 -2
  174. package/lib/typescript/src/__tests__/demos/ABuffer.spec.d.ts.map +0 -1
  175. package/lib/typescript/src/__tests__/demos/Blur.spec.d.ts +0 -2
  176. package/lib/typescript/src/__tests__/demos/Blur.spec.d.ts.map +0 -1
  177. package/lib/typescript/src/__tests__/demos/Cube.spec.d.ts +0 -2
  178. package/lib/typescript/src/__tests__/demos/Cube.spec.d.ts.map +0 -1
  179. package/lib/typescript/src/__tests__/demos/FractalCube.spec.d.ts +0 -2
  180. package/lib/typescript/src/__tests__/demos/FractalCube.spec.d.ts.map +0 -1
  181. package/lib/typescript/src/__tests__/demos/OcclusionQuery.spec.d.ts +0 -2
  182. package/lib/typescript/src/__tests__/demos/OcclusionQuery.spec.d.ts.map +0 -1
  183. package/lib/typescript/src/__tests__/demos/RenderBundles.spec.d.ts +0 -2
  184. package/lib/typescript/src/__tests__/demos/RenderBundles.spec.d.ts.map +0 -1
  185. package/lib/typescript/src/__tests__/demos/Triangle.spec.d.ts +0 -2
  186. package/lib/typescript/src/__tests__/demos/Triangle.spec.d.ts.map +0 -1
  187. package/lib/typescript/src/__tests__/demos/Wireframe.spec.d.ts +0 -2
  188. package/lib/typescript/src/__tests__/demos/Wireframe.spec.d.ts.map +0 -1
  189. package/lib/typescript/src/__tests__/globalSetup.d.ts +0 -3
  190. package/lib/typescript/src/__tests__/globalSetup.d.ts.map +0 -1
  191. package/lib/typescript/src/__tests__/globalTeardown.d.ts +0 -3
  192. package/lib/typescript/src/__tests__/globalTeardown.d.ts.map +0 -1
  193. package/lib/typescript/src/__tests__/setup.d.ts +0 -63
  194. package/lib/typescript/src/__tests__/setup.d.ts.map +0 -1
  195. package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  196. package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  197. package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
  198. package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
  199. package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
  200. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
  201. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
  202. package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
  203. package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  204. package/libs/dawn.json +0 -4670
  205. package/src/__tests__/Alpha.spec.ts +0 -28
  206. package/src/__tests__/ArrayBuffer.spec.ts +0 -76
  207. package/src/__tests__/Buffer.spec.ts +0 -357
  208. package/src/__tests__/ComputeShader.spec.ts +0 -375
  209. package/src/__tests__/Constants.spec.ts +0 -89
  210. package/src/__tests__/Device.spec.ts +0 -84
  211. package/src/__tests__/ErrorScope.spec.ts +0 -92
  212. package/src/__tests__/ExternalTexture.spec.ts +0 -284
  213. package/src/__tests__/GPU.spec.ts +0 -272
  214. package/src/__tests__/ImageData.spec.ts +0 -26
  215. package/src/__tests__/Shaders.spec.ts +0 -232
  216. package/src/__tests__/Texture.spec.ts +0 -197
  217. package/src/__tests__/assets/Di-3d.png +0 -0
  218. package/src/__tests__/components/Wireframe/Shaders.ts +0 -138
  219. package/src/__tests__/components/Wireframe/models.ts +0 -113
  220. package/src/__tests__/components/Wireframe/utils.ts +0 -22
  221. package/src/__tests__/components/cube.ts +0 -51
  222. package/src/__tests__/components/meshes/mesh.ts +0 -96
  223. package/src/__tests__/components/meshes/sphere.ts +0 -103
  224. package/src/__tests__/components/meshes/stanfordDragon.ts +0 -44
  225. package/src/__tests__/components/meshes/stanfordDragonData.ts +0 -5
  226. package/src/__tests__/components/meshes/teapot.ts +0 -13
  227. package/src/__tests__/components/meshes/utils.ts +0 -235
  228. package/src/__tests__/components/triangle.ts +0 -17
  229. package/src/__tests__/config.ts +0 -2
  230. package/src/__tests__/demos/ABuffer.spec.ts +0 -890
  231. package/src/__tests__/demos/Blur.spec.ts +0 -398
  232. package/src/__tests__/demos/Cube.spec.ts +0 -929
  233. package/src/__tests__/demos/FractalCube.spec.ts +0 -240
  234. package/src/__tests__/demos/OcclusionQuery.spec.ts +0 -376
  235. package/src/__tests__/demos/RenderBundles.spec.ts +0 -580
  236. package/src/__tests__/demos/Triangle.spec.ts +0 -266
  237. package/src/__tests__/demos/Wireframe.spec.ts +0 -188
  238. package/src/__tests__/globalSetup.ts +0 -45
  239. package/src/__tests__/globalTeardown.ts +0 -11
  240. package/src/__tests__/setup.ts +0 -423
  241. package/src/__tests__/snapshots/abuffer.png +0 -0
  242. package/src/__tests__/snapshots/asteroid.png +0 -0
  243. package/src/__tests__/snapshots/blur.png +0 -0
  244. package/src/__tests__/snapshots/buffer.png +0 -0
  245. package/src/__tests__/snapshots/constant-triangle.png +0 -0
  246. package/src/__tests__/snapshots/cube.png +0 -0
  247. package/src/__tests__/snapshots/f.png +0 -0
  248. package/src/__tests__/snapshots/f2.png +0 -0
  249. package/src/__tests__/snapshots/fractal-cubes.png +0 -0
  250. package/src/__tests__/snapshots/instanced-cubes.png +0 -0
  251. package/src/__tests__/snapshots/occlusion-query.png +0 -0
  252. package/src/__tests__/snapshots/ref.png +0 -0
  253. package/src/__tests__/snapshots/semi-opaque-cyan.png +0 -0
  254. package/src/__tests__/snapshots/texture.png +0 -0
  255. package/src/__tests__/snapshots/textured-cube.png +0 -0
  256. package/src/__tests__/snapshots/triangle-msaa.png +0 -0
  257. package/src/__tests__/snapshots/triangle.png +0 -0
  258. package/src/__tests__/snapshots/two-cube.png +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wgpu",
3
- "version": "0.2.10",
3
+ "version": "0.3.1",
4
4
  "description": "React Native WebGPU",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -10,6 +10,7 @@
10
10
  "files": [
11
11
  "src/**",
12
12
  "lib/**",
13
+ "!**/__tests__/**",
13
14
  "android/build.gradle",
14
15
  "android/CMakeLists.txt",
15
16
  "android/cpp/**",
@@ -19,6 +20,7 @@
19
20
  "libs/**",
20
21
  "*.podspec"
21
22
  ],
23
+ "dawn": "chromium/7472",
22
24
  "scripts": {
23
25
  "test": "NODE_OPTIONS='--experimental-require-module' jest -i",
24
26
  "test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i",
@@ -32,8 +34,7 @@
32
34
  "clang-format-android": "find android/cpp/ -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.cpp\" | xargs clang-format -i",
33
35
  "clang-format-common": "find cpp/rnwgpu -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.cpp\" | xargs clang-format -i",
34
36
  "cpplint": "cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=example --exclude=android/.cxx --exclude=cpp/webgpu --exclude=cpp/dawn --exclude=ios --exclude=android/build --exclude=node_modules --recursive .",
35
- "download-artifacts": "tsx scripts/build/download-artifacts.ts && yarn copy-artifacts",
36
- "copy-artifacts": "tsx scripts/build/copy-artifacts.ts",
37
+ "install-dawn": "tsx scripts/install-dawn.ts",
37
38
  "codegen": "tsx scripts/codegen/codegen.ts && yarn clang-format"
38
39
  },
39
40
  "keywords": [
@@ -31,21 +31,17 @@ Pod::Spec.new do |s|
31
31
  install_modules_dependencies(s)
32
32
  else
33
33
  s.dependency "React-Core"
34
-
35
- # Don't install the dependencies when we run `pod install` in the old architecture.
36
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
37
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
38
- s.pod_target_xcconfig = {
39
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
40
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
41
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
42
- }
43
- s.dependency "React-RCTFabric"
44
- s.dependency "React-Codegen"
45
- s.dependency "RCT-Folly"
46
- s.dependency "RCTRequired"
47
- s.dependency "RCTTypeSafety"
48
- s.dependency "ReactCommon/turbomodule/core"
49
- end
34
+ s.compiler_flags = folly_compiler_flags
35
+ s.pod_target_xcconfig = {
36
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_TARGET_SRCROOT)/cpp\"",
37
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
38
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
39
+ }
40
+ s.dependency "React-RCTFabric"
41
+ s.dependency "React-Codegen"
42
+ s.dependency "RCT-Folly"
43
+ s.dependency "RCTRequired"
44
+ s.dependency "RCTTypeSafety"
45
+ s.dependency "ReactCommon/turbomodule/core"
50
46
  end
51
47
  end
package/src/Canvas.tsx CHANGED
@@ -1,15 +1,6 @@
1
- import type { ViewProps, LayoutChangeEvent } from "react-native";
1
+ import type { ViewProps } from "react-native";
2
2
  import { View } from "react-native";
3
- import {
4
- forwardRef,
5
- useEffect,
6
- useImperativeHandle,
7
- useRef,
8
- useState,
9
- useLayoutEffect,
10
- useCallback,
11
- } from "react";
12
- import type { RefObject } from "react";
3
+ import { forwardRef, useImperativeHandle, useRef, useState } from "react";
13
4
 
14
5
  import WebGPUNativeView from "./WebGPUViewNativeComponent";
15
6
 
@@ -51,81 +42,29 @@ export interface CanvasRef {
51
42
  getContextId: () => number;
52
43
  getContext(contextName: "webgpu"): RNCanvasContext | null;
53
44
  getNativeSurface: () => NativeCanvas;
54
- whenReady: (callback: () => void) => void;
55
45
  }
56
46
 
57
- interface Size {
58
- width: number;
59
- height: number;
60
- }
61
-
62
- const useSizeFabric = (ref: RefObject<View>) => {
63
- const [size, setSize] = useState<null | Size>(null);
64
- useLayoutEffect(() => {
65
- if (!ref.current) {
66
- throw new Error("Canvas ref is null");
67
- }
68
- ref.current.measureInWindow((_x, _y, width, height) => {
69
- setSize({ width, height });
70
- });
71
- }, [ref]);
72
- return { size, onLayout: undefined };
73
- };
74
-
75
- const useSizePaper = (_ref: RefObject<View>) => {
76
- const [size, setSize] = useState<null | Size>(null);
77
- const onLayout = useCallback<(event: LayoutChangeEvent) => void>(
78
- ({
79
- nativeEvent: {
80
- layout: { width, height },
81
- },
82
- }) => {
83
- if (size === null) {
84
- setSize({ width, height });
85
- }
86
- },
87
- [size],
88
- );
89
- return { size, onLayout };
90
- };
91
-
92
47
  export const Canvas = forwardRef<
93
48
  CanvasRef,
94
49
  ViewProps & { transparent?: boolean }
95
50
  >(({ onLayout: _onLayout, transparent, ...props }, ref) => {
96
51
  const viewRef = useRef(null);
97
- const FABRIC = RNWebGPU.fabric;
98
- const useSize = FABRIC ? useSizeFabric : useSizePaper;
99
52
  const [contextId, _] = useState(() => generateContextId());
100
- const cb = useRef<() => void>();
101
- const { size, onLayout } = useSize(viewRef);
102
- useEffect(() => {
103
- if (size && cb.current) {
104
- cb.current();
105
- }
106
- }, [size]);
107
53
  useImperativeHandle(ref, () => ({
108
54
  getContextId: () => contextId,
109
55
  getNativeSurface: () => {
110
- if (size === null) {
111
- throw new Error("[WebGPU] Canvas size is not available yet");
112
- }
113
56
  return RNWebGPU.getNativeSurface(contextId);
114
57
  },
115
- whenReady(callback: () => void) {
116
- if (size === null) {
117
- cb.current = callback;
118
- } else {
119
- callback();
120
- }
121
- },
122
58
  getContext(contextName: "webgpu"): RNCanvasContext | null {
123
59
  if (contextName !== "webgpu") {
124
60
  throw new Error(`[WebGPU] Unsupported context: ${contextName}`);
125
61
  }
126
- if (size === null) {
127
- throw new Error("[WebGPU] Canvas size is not available yet");
62
+ if (!viewRef.current) {
63
+ throw new Error("[WebGPU] Cannot get context before mount");
128
64
  }
65
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
+ // @ts-expect-error
67
+ const size = viewRef.current.unstable_getBoundingClientRect();
129
68
  return RNWebGPU.MakeWebGPUCanvasContext(
130
69
  contextId,
131
70
  size.width,
@@ -134,7 +73,7 @@ export const Canvas = forwardRef<
134
73
  },
135
74
  }));
136
75
  return (
137
- <View collapsable={false} ref={viewRef} onLayout={onLayout} {...props}>
76
+ <View collapsable={false} ref={viewRef} {...props}>
138
77
  <WebGPUNativeView
139
78
  style={{ flex: 1 }}
140
79
  contextId={contextId}
package/src/hooks.tsx CHANGED
@@ -1,9 +1,14 @@
1
1
  import type { ReactNode } from "react";
2
- import { createContext, useContext, useEffect, useRef, useState } from "react";
2
+ import {
3
+ createContext,
4
+ useContext,
5
+ useEffect,
6
+ useLayoutEffect,
7
+ useRef,
8
+ useState,
9
+ } from "react";
3
10
 
4
- import type { RNCanvasContext, CanvasRef, NativeCanvas } from "./Canvas";
5
-
6
- type Unsubscribe = () => void;
11
+ import type { CanvasRef, NativeCanvas } from "./Canvas";
7
12
 
8
13
  export const warnIfNotHardwareAccelerated = (adapter: GPUAdapter) => {
9
14
  // Check if adapter is a fallback adapter using the new GPUAdapterInfo API
@@ -43,11 +48,12 @@ export const GPUDeviceProvider = ({
43
48
  };
44
49
 
45
50
  export const useSurface = () => {
51
+ const ref = useRef<CanvasRef>(null);
46
52
  const [surface, setSurface] = useState<NativeCanvas | null>(null);
47
- const ref = useCanvasEffect(() => {
53
+ useLayoutEffect(() => {
48
54
  const sur = ref.current!.getNativeSurface();
49
55
  setSurface(sur);
50
- });
56
+ }, []);
51
57
  return { ref, surface };
52
58
  };
53
59
 
@@ -59,6 +65,8 @@ export const useMainDevice = () => {
59
65
  return ctx;
60
66
  };
61
67
 
68
+ export const useCanvasRef = () => useRef<CanvasRef>(null);
69
+
62
70
  export const useDevice = (
63
71
  adapterOptions?: GPURequestAdapterOptions,
64
72
  deviceDescriptor?: GPUDeviceDescriptor,
@@ -83,45 +91,3 @@ export const useDevice = (
83
91
  }, [adapterOptions, deviceDescriptor, state]);
84
92
  return { adapter: state?.adapter ?? null, device: state?.device ?? null };
85
93
  };
86
-
87
- export const useGPUContext = () => {
88
- const [context, setContext] = useState<RNCanvasContext | null>(null);
89
- const ref = useCanvasEffect(() => {
90
- const ctx = ref.current!.getContext("webgpu")!;
91
- setContext(ctx);
92
- });
93
- return { ref, context };
94
- };
95
-
96
- export const useCanvasEffect = (
97
- effect: () =>
98
- | void
99
- | Unsubscribe
100
- | Promise<Unsubscribe | void>
101
- | Promise<void>,
102
- ) => {
103
- const unsub = useRef<Unsubscribe | null | Promise<Unsubscribe | void>>(null);
104
- const ref = useRef<CanvasRef>(null);
105
- useEffect(() => {
106
- if (!ref.current || !ref.current.whenReady) {
107
- throw new Error("The reference is not assigned to a WebGPU Canvas");
108
- }
109
- ref.current.whenReady(async () => {
110
- const sub = effect();
111
- if (sub) {
112
- unsub.current = sub;
113
- }
114
- });
115
- return () => {
116
- if (unsub.current) {
117
- if (unsub.current instanceof Promise) {
118
- unsub.current.then((sub) => sub && sub());
119
- } else {
120
- unsub.current();
121
- }
122
- }
123
- };
124
- // eslint-disable-next-line react-hooks/exhaustive-deps
125
- }, []);
126
- return ref;
127
- };
@@ -1,41 +0,0 @@
1
- //
2
- // ThreadUtils.cpp
3
- // react-native-nitro
4
- //
5
- // Created by Marc Rousavy on 14.07.24.
6
- //
7
-
8
- #include "ThreadUtils.h"
9
- #include <pthread.h>
10
- #include <sstream>
11
- #include <string>
12
- #include <sys/prctl.h>
13
- #include <thread>
14
-
15
- namespace margelo {
16
-
17
- std::string ThreadUtils::getThreadName() {
18
- #ifdef HAVE_ANDROID_PTHREAD_SETNAME_NP
19
- // Try using pthread APIs
20
- pthread_t this_thread = pthread_self();
21
- char thread_name[16]; // Thread name length limit in Android is 16 characters
22
-
23
- int result =
24
- pthread_getname_np(this_thread, thread_name, sizeof(thread_name));
25
- if (result == 0) {
26
- return std::string(thread_name);
27
- }
28
- #endif
29
-
30
- // Fall back to this_thread ID
31
- std::stringstream stream;
32
- stream << std::this_thread::get_id();
33
- std::string threadId = stream.str();
34
- return "Thread #" + threadId;
35
- }
36
-
37
- void ThreadUtils::setThreadName(const std::string &name) {
38
- prctl(PR_SET_NAME, name.c_str(), 0, 0, 0);
39
- }
40
-
41
- } // namespace margelo
@@ -1,23 +0,0 @@
1
- package com.webgpu;
2
-
3
- import androidx.annotation.NonNull;
4
- import androidx.annotation.Nullable;
5
-
6
- import com.facebook.react.bridge.ReactApplicationContext;
7
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
-
9
- class NativeWebGPUModuleSpec extends ReactContextBaseJavaModule {
10
-
11
- public static final String NAME = "WebGPUModule";
12
-
13
- public NativeWebGPUModuleSpec(@Nullable ReactApplicationContext reactContext) {
14
- super(reactContext);
15
- }
16
-
17
- @NonNull
18
- @Override
19
- public String getName() {
20
- return NAME;
21
- }
22
-
23
- }
@@ -1,12 +0,0 @@
1
- package com.webgpu;
2
-
3
- import android.view.View;
4
-
5
- import androidx.annotation.Nullable;
6
-
7
- import com.facebook.react.uimanager.SimpleViewManager;
8
-
9
- public abstract class WebGPUViewManagerSpec<T extends View> extends SimpleViewManager<T> {
10
- public abstract void setContextId(T view, int contextId);
11
- public abstract void setTransparent(T view, boolean transparency);
12
- }
@@ -1,24 +0,0 @@
1
- #import "MetalView.h"
2
- #import "RCTBridge.h"
3
- #import "RNWGUIKit.h"
4
- #import "WebGPUModule.h"
5
- #import <React/RCTUIManager.h>
6
- #import <React/RCTViewManager.h>
7
-
8
- @interface WebGPUViewManager : RCTViewManager
9
- @end
10
-
11
- @implementation WebGPUViewManager
12
-
13
- RCT_EXPORT_MODULE(WebGPUView)
14
-
15
- - (RNWGPlatformView *)view {
16
- return [MetalView new];
17
- }
18
-
19
- RCT_CUSTOM_VIEW_PROPERTY(contextId, NSNumber, RNWGPlatformView) {
20
- NSNumber *contextId = [RCTConvert NSNumber:json];
21
- [(MetalView *)view setContextId:contextId];
22
- }
23
-
24
- @end
@@ -1,34 +0,0 @@
1
- //
2
- // ThreadUtils.cpp
3
- // react-native-nitro
4
- //
5
- // Created by Marc Rousavy on 14.07.24.
6
- //
7
-
8
- #include "ThreadUtils.h"
9
- #include <pthread.h>
10
- #include <sstream>
11
- #include <string>
12
- #include <thread>
13
-
14
- namespace margelo {
15
-
16
- std::string ThreadUtils::getThreadName() {
17
- // Try using pthread APIs
18
- char name[256];
19
- if (pthread_getname_np(pthread_self(), name, sizeof(name)) == 0) {
20
- return std::string(name);
21
- }
22
-
23
- // Fall back to this_thread ID
24
- std::stringstream stream;
25
- stream << std::this_thread::get_id();
26
- std::string threadId = stream.str();
27
- return "Thread #" + threadId;
28
- }
29
-
30
- void ThreadUtils::setThreadName(const std::string &name) {
31
- pthread_setname_np(name.c_str());
32
- }
33
-
34
- } // namespace margelo
@@ -1,50 +0,0 @@
1
- // Copyright 2019 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_PROC_H_
29
- #define INCLUDE_DAWN_DAWN_PROC_H_
30
-
31
- #include <webgpu/webgpu.h>
32
-
33
- #include "dawn/dawn_proc_table.h"
34
-
35
- #ifdef __cplusplus
36
- extern "C" {
37
- #endif
38
-
39
- // Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL
40
- // for `procs` sets up the null proctable that contains only null function pointers. It is the
41
- // default value of the proctable. Setting the proctable back to null is good practice when you
42
- // are done using libdawn_proc since further usage will cause a segfault instead of calling an
43
- // unexpected function.
44
- WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
45
-
46
- #ifdef __cplusplus
47
- } // extern "C"
48
- #endif
49
-
50
- #endif // INCLUDE_DAWN_DAWN_PROC_H_
@@ -1,47 +0,0 @@
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_
@@ -1,77 +0,0 @@
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
- // If this flag is true, Dawn is required to signal a fence before EndAccess() and return it in
63
- // SharedTextureMemoryEndAccessState's fences list.
64
- // If it's false, no fence signaling is needed and EndAccess() might return empty fence list.
65
- // Notes:
66
- // - This flag is not relevant if the feature SharedFenceDXGISharedHandle is disabled/not
67
- // supported.
68
- // - This flag if present will override the requiresEndAccessFence flag in
69
- // SharedTextureMemoryD3D11BeginState
70
- // TODO(chromium:335003893): This flag is deprecated. Remove it once clients are updated to use
71
- // SharedTextureMemoryD3D11BeginState's requiresEndAccessFence.
72
- std::optional<bool> requiresEndAccessFence;
73
- };
74
-
75
- } // namespace dawn::native::d3d11
76
-
77
- #endif // INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_
@@ -1,68 +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_D3D12BACKEND_H_
29
- #define INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
30
-
31
- #include <d3d12.h>
32
- #include <dxgi1_4.h>
33
- #include <wrl/client.h>
34
-
35
- #include "dawn/native/D3DBackend.h"
36
-
37
- struct ID3D12Device;
38
- struct ID3D12Resource;
39
-
40
- namespace dawn::native::d3d12 {
41
-
42
- class Device;
43
-
44
- enum MemorySegment {
45
- Local,
46
- NonLocal,
47
- };
48
-
49
- DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
50
-
51
- DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
52
- uint64_t requestedReservationSize,
53
- MemorySegment memorySegment);
54
-
55
- // May be chained on SharedBufferMemoryDescriptor
56
- struct DAWN_NATIVE_EXPORT SharedBufferMemoryD3D12ResourceDescriptor : wgpu::ChainedStruct {
57
- SharedBufferMemoryD3D12ResourceDescriptor() {
58
- sType = static_cast<wgpu::SType>(WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor);
59
- }
60
-
61
- // This ID3D12Resource object must be created from the same ID3D12Device used in the
62
- // WGPUDevice.
63
- Microsoft::WRL::ComPtr<ID3D12Resource> resource;
64
- };
65
-
66
- } // namespace dawn::native::d3d12
67
-
68
- #endif // INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_