@shopify/react-native-skia 2.6.5 → 2.6.7

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 (279) hide show
  1. package/android/CMakeLists.txt +2 -2
  2. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerDelegate.java +35 -0
  3. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerInterface.java +17 -0
  4. package/apple/RNSkiaModule.mm +8 -2
  5. package/apple/SkiaManager.mm +10 -5
  6. package/cpp/api/JsiSkApi.h +6 -6
  7. package/cpp/api/JsiSkCanvas.h +33 -0
  8. package/cpp/api/JsiSkImage.h +12 -4
  9. package/cpp/api/JsiSkMaskFilter.h +1 -0
  10. package/cpp/api/JsiSkSurface.h +5 -1
  11. package/cpp/jsi2/NativeObject.h +39 -0
  12. package/cpp/rnskia/RNSkManager.cpp +27 -11
  13. package/cpp/rnwgpu/SurfaceRegistry.h +33 -1
  14. package/cpp/rnwgpu/api/GPU.cpp +15 -15
  15. package/cpp/rnwgpu/api/GPU.h +6 -3
  16. package/cpp/rnwgpu/api/GPUAdapter.cpp +11 -7
  17. package/cpp/rnwgpu/api/GPUAdapter.h +3 -3
  18. package/cpp/rnwgpu/api/GPUBuffer.h +3 -3
  19. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +13 -16
  20. package/cpp/rnwgpu/api/GPUCanvasContext.h +3 -0
  21. package/cpp/rnwgpu/api/GPUDevice.cpp +103 -17
  22. package/cpp/rnwgpu/api/GPUDevice.h +18 -3
  23. package/cpp/rnwgpu/api/GPUQueue.h +3 -3
  24. package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
  25. package/cpp/rnwgpu/api/GPUShaderModule.h +3 -3
  26. package/cpp/rnwgpu/api/GPUSharedFence.cpp +80 -0
  27. package/cpp/rnwgpu/api/GPUSharedFence.h +53 -0
  28. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +64 -11
  29. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +13 -8
  30. package/cpp/rnwgpu/api/WebGPUConstants.h +36 -0
  31. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +58 -0
  32. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +51 -0
  33. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +55 -22
  34. package/cpp/rnwgpu/async/AsyncTaskHandle.h +8 -5
  35. package/cpp/rnwgpu/async/RuntimeContext.cpp +194 -0
  36. package/cpp/rnwgpu/async/RuntimeContext.h +121 -0
  37. package/cpp/skia/include/android/GrAHardwareBufferUtils.h +1 -1
  38. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +1 -1
  39. package/cpp/skia/include/android/SkAnimatedImage.h +1 -1
  40. package/cpp/skia/include/codec/SkCodec.h +0 -8
  41. package/cpp/skia/include/codec/SkEncodedOrigin.h +1 -1
  42. package/cpp/skia/include/codec/SkPngRustDecoder.h +1 -1
  43. package/cpp/skia/include/core/SkBitmap.h +2 -8
  44. package/cpp/skia/include/core/SkCPURecorder.h +3 -1
  45. package/cpp/skia/include/core/SkCanvasVirtualEnforcer.h +1 -1
  46. package/cpp/skia/include/core/SkColorType.h +5 -3
  47. package/cpp/skia/include/core/SkContourMeasure.h +1 -1
  48. package/cpp/skia/include/core/SkCoverageMode.h +1 -1
  49. package/cpp/skia/include/core/SkCubicMap.h +1 -1
  50. package/cpp/skia/include/core/SkExecutor.h +1 -1
  51. package/cpp/skia/include/core/SkFont.h +15 -0
  52. package/cpp/skia/include/core/SkFontArguments.h +6 -1
  53. package/cpp/skia/include/core/SkFontMetrics.h +1 -1
  54. package/cpp/skia/include/core/SkFontMgr.h +36 -1
  55. package/cpp/skia/include/core/SkFontParameters.h +1 -1
  56. package/cpp/skia/include/core/SkFontScanner.h +1 -1
  57. package/cpp/skia/include/core/SkFontTypes.h +1 -1
  58. package/cpp/skia/include/core/SkM44.h +1 -1
  59. package/cpp/skia/include/core/SkMilestone.h +1 -1
  60. package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +1 -1
  61. package/cpp/skia/include/core/SkPathBuilder.h +10 -4
  62. package/cpp/skia/include/core/SkPathIter.h +1 -1
  63. package/cpp/skia/include/core/SkPathTypes.h +1 -1
  64. package/cpp/skia/include/core/SkPixelRef.h +4 -1
  65. package/cpp/skia/include/core/SkRecorder.h +2 -1
  66. package/cpp/skia/include/core/SkRegion.h +7 -1
  67. package/cpp/skia/include/core/SkSamplingOptions.h +1 -1
  68. package/cpp/skia/include/core/SkSerialProcs.h +8 -1
  69. package/cpp/skia/include/core/SkShader.h +3 -5
  70. package/cpp/skia/include/core/SkSpan.h +1 -1
  71. package/cpp/skia/include/core/SkStream.h +1 -1
  72. package/cpp/skia/include/core/SkStrikeRef.h +80 -0
  73. package/cpp/skia/include/core/SkTileMode.h +1 -1
  74. package/cpp/skia/include/core/SkVertices.h +1 -1
  75. package/cpp/skia/include/core/SkYUVAPixmaps.h +3 -5
  76. package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
  77. package/cpp/skia/include/docs/SkXPSDocument.h +1 -1
  78. package/cpp/skia/include/effects/SkGradient.h +1 -1
  79. package/cpp/skia/include/effects/SkHighContrastFilter.h +1 -1
  80. package/cpp/skia/include/effects/SkShaderMaskFilter.h +1 -1
  81. package/cpp/skia/include/effects/SkTrimPathEffect.h +1 -1
  82. package/cpp/skia/include/encode/SkEncoder.h +1 -1
  83. package/cpp/skia/include/encode/SkJpegEncoder.h +1 -1
  84. package/cpp/skia/include/encode/SkPngEncoder.h +1 -1
  85. package/cpp/skia/include/encode/SkPngRustEncoder.h +1 -1
  86. package/cpp/skia/include/encode/SkWebpEncoder.h +1 -1
  87. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  88. package/cpp/skia/include/gpu/MutableTextureState.h +1 -1
  89. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +1 -1
  90. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +6 -62
  91. package/cpp/skia/include/gpu/ganesh/GrContextThreadSafeProxy.h +1 -1
  92. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +1 -1
  93. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +1 -1
  94. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +2 -1
  95. package/cpp/skia/include/gpu/ganesh/mock/GrMockBackendSurface.h +59 -0
  96. package/cpp/skia/include/gpu/ganesh/mock/GrMockTypes.h +1 -1
  97. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlBackendContext.h +1 -1
  98. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlTypes.h +1 -1
  99. package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +1 -1
  100. package/cpp/skia/include/gpu/graphite/Context.h +11 -4
  101. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +6 -0
  102. package/cpp/skia/include/gpu/graphite/Image.h +82 -9
  103. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +7 -2
  104. package/cpp/skia/include/gpu/graphite/Recorder.h +6 -4
  105. package/cpp/skia/include/gpu/graphite/precompile/PrecompileColorFilter.h +11 -1
  106. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +1 -0
  107. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +1 -1
  108. package/cpp/skia/include/gpu/mtl/MtlMemoryAllocator.h +1 -1
  109. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
  110. package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +1 -1
  111. package/cpp/skia/include/gpu/vk/VulkanTypes.h +1 -1
  112. package/cpp/skia/include/ports/SkCFObject.h +1 -1
  113. package/cpp/skia/include/ports/SkFontMgr_Fontations.h +1 -1
  114. package/cpp/skia/include/ports/SkFontMgr_android_ndk.h +1 -1
  115. package/cpp/skia/include/ports/SkFontMgr_data.h +1 -1
  116. package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +1 -1
  117. package/cpp/skia/include/ports/SkFontMgr_mac_ct.h +1 -1
  118. package/cpp/skia/include/ports/SkFontScanner_Fontations.h +1 -1
  119. package/cpp/skia/include/ports/SkFontScanner_FreeType.h +1 -1
  120. package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
  121. package/cpp/skia/include/private/SkExif.h +1 -1
  122. package/cpp/skia/include/private/SkGainmapInfo.h +1 -1
  123. package/cpp/skia/include/private/SkGainmapShader.h +1 -1
  124. package/cpp/skia/include/private/SkHdrMetadata.h +21 -0
  125. package/cpp/skia/include/private/SkJpegGainmapEncoder.h +1 -1
  126. package/cpp/skia/include/private/SkPixelStorage.h +37 -0
  127. package/cpp/skia/include/private/SkXmp.h +1 -1
  128. package/cpp/skia/include/private/base/SkAssert.h +6 -5
  129. package/cpp/skia/include/private/base/SkContainers.h +1 -1
  130. package/cpp/skia/include/private/base/SkFeatures.h +30 -30
  131. package/cpp/skia/include/private/base/SkLog.h +1 -7
  132. package/cpp/skia/include/private/base/SkLogPriority.h +4 -5
  133. package/cpp/skia/include/private/base/SkMacros.h +1 -1
  134. package/cpp/skia/include/private/base/SkMalloc.h +1 -1
  135. package/cpp/skia/include/private/base/SkSafe32.h +1 -1
  136. package/cpp/skia/include/private/base/SkSpan_impl.h +1 -1
  137. package/cpp/skia/include/private/base/SkTDArray.h +13 -1
  138. package/cpp/skia/include/private/base/SkTPin.h +1 -1
  139. package/cpp/skia/include/private/base/SkTo.h +1 -1
  140. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +1 -1
  141. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +1 -1
  142. package/cpp/skia/include/private/chromium/SkCodecsICCProfileChromium.h +52 -0
  143. package/cpp/skia/include/private/chromium/SkExifChromium.h +26 -0
  144. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
  145. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
  146. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +2 -1
  147. package/cpp/skia/include/private/gpu/vk/SkiaVulkan.h +1 -1
  148. package/cpp/skia/include/sksl/SkSLDebugTrace.h +1 -1
  149. package/cpp/skia/include/third_party/vulkan/vulkan/vk_icd.h +41 -51
  150. package/cpp/skia/include/third_party/vulkan/vulkan/vk_layer.h +42 -53
  151. package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -1
  152. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +158 -154
  153. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +68 -65
  154. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +90 -87
  155. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +9 -9
  156. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +2 -2
  157. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +82 -79
  158. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +24 -24
  159. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +2 -2
  160. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +95 -96
  161. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std.h +151 -0
  162. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std_decode.h +68 -0
  163. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +1 -1
  164. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +5 -1
  165. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +7 -1
  166. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +291 -158
  167. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +13174 -10113
  168. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +23 -19
  169. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +159 -165
  170. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +22 -19
  171. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +3 -1
  172. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +3 -1
  173. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +94 -88
  174. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ohos.h +120 -0
  175. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +55 -51
  176. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +18 -15
  177. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +23 -19
  178. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +31 -1
  179. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +5 -1
  180. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +27 -27
  181. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +20 -16
  182. package/cpp/skia/include/utils/SkEventTracer.h +6 -1
  183. package/cpp/skia/include/utils/SkOrderedFontMgr.h +1 -1
  184. package/cpp/skia/include/utils/SkShadowUtils.h +1 -1
  185. package/cpp/skia/include/utils/SkTextUtils.h +1 -1
  186. package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +20 -4
  187. package/cpp/skia/modules/skcms/src/Transform_inl.h +11 -15
  188. package/cpp/skia/modules/skcms/src/skcms_public.h +2 -0
  189. package/cpp/skia/modules/skottie/include/ExternalLayer.h +1 -1
  190. package/cpp/skia/modules/skottie/include/Skottie.h +1 -1
  191. package/cpp/skia/modules/skottie/include/SkottieProperty.h +1 -1
  192. package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
  193. package/cpp/skia/modules/skottie/include/TextShaper.h +1 -1
  194. package/cpp/skia/modules/skottie/src/SkottieValue.h +1 -1
  195. package/cpp/skia/modules/skottie/src/animator/Animator.h +1 -1
  196. package/cpp/skia/modules/skottie/src/text/Font.h +1 -1
  197. package/cpp/skia/modules/skottie/src/text/TextAdapter.h +1 -1
  198. package/cpp/skia/modules/skottie/src/text/TextAnimator.h +3 -2
  199. package/cpp/skia/modules/skottie/src/text/TextValue.h +1 -1
  200. package/cpp/skia/modules/skparagraph/include/DartTypes.h +1 -1
  201. package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
  202. package/cpp/skia/modules/skparagraph/include/FontCollection.h +5 -1
  203. package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
  204. package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
  205. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +1 -1
  206. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +1 -1
  207. package/cpp/skia/modules/skparagraph/include/ParagraphPainter.h +1 -1
  208. package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +12 -5
  209. package/cpp/skia/modules/skparagraph/include/TextShadow.h +1 -1
  210. package/cpp/skia/modules/skparagraph/include/TextStyle.h +1 -1
  211. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -1
  212. package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +1 -1
  213. package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +1 -1
  214. package/cpp/skia/modules/sksg/include/SkSGDraw.h +1 -1
  215. package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +1 -1
  216. package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +1 -1
  217. package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +1 -1
  218. package/cpp/skia/modules/sksg/include/SkSGGradient.h +1 -1
  219. package/cpp/skia/modules/sksg/include/SkSGGroup.h +1 -1
  220. package/cpp/skia/modules/sksg/include/SkSGImage.h +1 -1
  221. package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +1 -1
  222. package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +1 -1
  223. package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
  224. package/cpp/skia/modules/sksg/include/SkSGNode.h +1 -1
  225. package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +1 -1
  226. package/cpp/skia/modules/sksg/include/SkSGPaint.h +1 -1
  227. package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
  228. package/cpp/skia/modules/sksg/include/SkSGPlane.h +1 -1
  229. package/cpp/skia/modules/sksg/include/SkSGRect.h +1 -1
  230. package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +1 -1
  231. package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +1 -1
  232. package/cpp/skia/modules/sksg/include/SkSGScene.h +1 -1
  233. package/cpp/skia/modules/sksg/include/SkSGText.h +1 -1
  234. package/cpp/skia/modules/sksg/include/SkSGTransform.h +1 -1
  235. package/cpp/skia/modules/skshaper/include/SkShaper_coretext.h +8 -1
  236. package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
  237. package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
  238. package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
  239. package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
  240. package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
  241. package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
  242. package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
  243. package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
  244. package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
  245. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  246. package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
  247. package/cpp/skia/modules/svg/include/SkSVGFeMerge.h +1 -1
  248. package/cpp/skia/modules/svg/include/SkSVGFeMorphology.h +1 -1
  249. package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
  250. package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
  251. package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
  252. package/cpp/skia/modules/svg/include/SkSVGFilterContext.h +1 -1
  253. package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
  254. package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
  255. package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
  256. package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +1 -1
  257. package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
  258. package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
  259. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  260. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  261. package/cpp/skia/src/base/SkAutoLocaleSetter.h +94 -0
  262. package/cpp/skia/src/base/SkUTF.h +1 -1
  263. package/lib/commonjs/skia/types/WebGPU.d.ts +101 -5
  264. package/lib/commonjs/skia/types/WebGPU.js +99 -0
  265. package/lib/commonjs/skia/types/WebGPU.js.map +1 -1
  266. package/lib/module/skia/types/WebGPU.d.ts +101 -5
  267. package/lib/module/skia/types/WebGPU.js +98 -1
  268. package/lib/module/skia/types/WebGPU.js.map +1 -1
  269. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +1 -0
  270. package/lib/typescript/lib/module/mock/index.d.ts +1 -0
  271. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +31 -1
  272. package/lib/typescript/src/skia/types/WebGPU.d.ts +101 -5
  273. package/package.json +5 -5
  274. package/src/skia/types/WebGPU.ts +123 -5
  275. package/cpp/rnwgpu/async/AsyncDispatcher.h +0 -28
  276. package/cpp/rnwgpu/async/AsyncRunner.cpp +0 -182
  277. package/cpp/rnwgpu/async/AsyncRunner.h +0 -57
  278. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +0 -23
  279. package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +0 -22
@@ -120,9 +120,8 @@ if(SK_GRAPHITE)
120
120
  "${PROJECT_SOURCE_DIR}/../cpp/jsi2/Promise.cpp"
121
121
 
122
122
  # WebGPU async system
123
- "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/async/AsyncRunner.cpp"
124
123
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/async/AsyncTaskHandle.cpp"
125
- "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp"
124
+ "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/async/RuntimeContext.cpp"
126
125
 
127
126
  # WebGPU API
128
127
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPU.cpp"
@@ -142,6 +141,7 @@ if(SK_GRAPHITE)
142
141
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPURenderPassEncoder.cpp"
143
142
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPURenderPipeline.cpp"
144
143
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUShaderModule.cpp"
144
+ "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUSharedFence.cpp"
145
145
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUSharedTextureMemory.cpp"
146
146
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUSupportedLimits.cpp"
147
147
  "${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUTexture.cpp"
@@ -0,0 +1,35 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GeneratePropsJavaDelegate.js
8
+ */
9
+
10
+ package com.facebook.react.viewmanagers;
11
+
12
+ import android.view.View;
13
+ import androidx.annotation.Nullable;
14
+ import com.facebook.react.uimanager.BaseViewManagerDelegate;
15
+ import com.facebook.react.uimanager.BaseViewManager;
16
+ import com.facebook.react.uimanager.LayoutShadowNode;
17
+
18
+ public class SkiaWebGPUViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & SkiaWebGPUViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
19
+ public SkiaWebGPUViewManagerDelegate(U viewManager) {
20
+ super(viewManager);
21
+ }
22
+ @Override
23
+ public void setProperty(T view, String propName, @Nullable Object value) {
24
+ switch (propName) {
25
+ case "contextId":
26
+ mViewManager.setContextId(view, value == null ? 0 : ((Double) value).intValue());
27
+ break;
28
+ case "transparent":
29
+ mViewManager.setTransparent(view, value != null && (boolean) value);
30
+ break;
31
+ default:
32
+ super.setProperty(view, propName, value);
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GeneratePropsJavaInterface.js
8
+ */
9
+
10
+ package com.facebook.react.viewmanagers;
11
+
12
+ import android.view.View;
13
+
14
+ public interface SkiaWebGPUViewManagerInterface<T extends View> {
15
+ void setContextId(T view, int value);
16
+ void setTransparent(T view, boolean value);
17
+ }
@@ -35,11 +35,17 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
35
35
  // Already initialized, ignore call.
36
36
  return @true;
37
37
  }
38
- RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
38
+ #ifndef RCT_DISABLE_LEGACY_ARCH
39
39
  if (!jsInvoker) {
40
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
40
41
  jsInvoker = cxxBridge.jsCallInvoker;
41
42
  }
42
- skiaManager = [[SkiaManager alloc] initWithBridge:cxxBridge
43
+ #endif
44
+ if (!jsInvoker) {
45
+ NSLog(@"[RNSkiaModule] Failed to install SkiaManager: jsInvoker is not initialized.");
46
+ return @false;
47
+ }
48
+ skiaManager = [[SkiaManager alloc] initWithBridge:self.bridge
43
49
  jsInvoker:jsInvoker];
44
50
  return @true;
45
51
  }
@@ -2,12 +2,19 @@
2
2
 
3
3
  #import <Foundation/Foundation.h>
4
4
 
5
- #import <React/RCTBridge+Private.h>
6
5
  #import <React/RCTBridge.h>
7
6
  #import <React/RCTUIManager.h>
8
7
 
9
8
  #import "RNSkApplePlatformContext.h"
10
9
 
10
+ // Forward-declared runtime accessor that is satisfied by RCTCxxBridge
11
+ // (legacy/transitional) and RCTBridgeProxy (bridgeless). Avoids referencing
12
+ // RCTCxxBridge directly, which is compiled out when RCT_DISABLE_LEGACY_ARCH
13
+ // is set (React Native 0.82+).
14
+ @interface RCTBridge (RNSkiaRuntime)
15
+ - (void *)runtime;
16
+ @end
17
+
11
18
  static __weak SkiaManager *sharedInstance = nil;
12
19
 
13
20
  @implementation SkiaManager {
@@ -29,11 +36,9 @@ static __weak SkiaManager *sharedInstance = nil;
29
36
  self = [super init];
30
37
  if (self) {
31
38
  sharedInstance = self;
32
- RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
33
- if (cxxBridge.runtime) {
34
-
39
+ if (bridge.runtime) {
35
40
  facebook::jsi::Runtime *jsRuntime =
36
- (facebook::jsi::Runtime *)cxxBridge.runtime;
41
+ (facebook::jsi::Runtime *)bridge.runtime;
37
42
 
38
43
  // Create the RNSkiaManager (cross platform)
39
44
  _skManager = std::make_shared<RNSkia::RNSkManager>(
@@ -9,7 +9,7 @@
9
9
  #ifdef SK_GRAPHITE
10
10
  #include "rnskia/RNDawnContext.h"
11
11
  #include "rnwgpu/api/GPUDevice.h"
12
- #include "rnwgpu/async/AsyncRunner.h"
12
+ #include "rnwgpu/async/RuntimeContext.h"
13
13
  #endif
14
14
 
15
15
  #include "JsiNativeBuffer.h"
@@ -164,12 +164,12 @@ public:
164
164
  "getDevice", JSI_HOST_FUNCTION_LAMBDA {
165
165
  #ifdef SK_GRAPHITE
166
166
  auto &dawnContext = DawnContext::getInstance();
167
- auto asyncRunner = rnwgpu::async::AsyncRunner::get(runtime);
168
- if (!asyncRunner) {
169
- throw jsi::JSError(runtime, "AsyncRunner not initialized");
170
- }
167
+ // Per-runtime context: async ops on this device resolve on the calling
168
+ // runtime's own thread (via its ProcessEvents pump).
169
+ auto context = rnwgpu::async::RuntimeContext::getOrCreate(
170
+ runtime, dawnContext.getWGPUInstance());
171
171
  auto device = std::make_shared<rnwgpu::GPUDevice>(
172
- dawnContext.getWGPUDevice(), asyncRunner, "Skia Device");
172
+ dawnContext.getWGPUDevice(), context, "Skia Device");
173
173
  return rnwgpu::GPUDevice::create(runtime, device);
174
174
  #else
175
175
  throw jsi::JSError(runtime,
@@ -21,6 +21,10 @@
21
21
 
22
22
  #include "utils/RNSkTypedArray.h"
23
23
 
24
+ #if defined(SK_GRAPHITE)
25
+ #include "rnskia/RNDawnContext.h"
26
+ #endif
27
+
24
28
  #include <jsi/jsi.h>
25
29
 
26
30
  #pragma clang diagnostic push
@@ -644,6 +648,29 @@ public:
644
648
  .getArrayBuffer(runtime);
645
649
  auto bfrPtr = reinterpret_cast<void *>(buffer.data(runtime));
646
650
 
651
+ #if defined(SK_GRAPHITE)
652
+ // Graphite records draws lazily and offers no synchronous GPU readback. If
653
+ // this canvas belongs to a surface, snap & submit its recording, snapshot
654
+ // it to a CPU raster image and read from that (mirroring makeImageSnapshot).
655
+ // A canvas without an owning surface (e.g. a picture-recording canvas) has
656
+ // no texture to read back, so fall through to the raster canvas read below.
657
+ if (_surface) {
658
+ // Snapshot first: makeImageSnapshot records a copy task into the recorder
659
+ // that must be submitted before the texture can be read back (this is the
660
+ // same ordering used by JsiSkSurface::makeImageSnapshot and RNSkView).
661
+ auto snapshot = _surface->makeImageSnapshot();
662
+ if (auto *recorder = _surface->recorder()) {
663
+ DawnContext::getInstance().submitRecording(recorder->snap().get());
664
+ }
665
+ auto raster = DawnContext::getInstance().MakeRasterImage(snapshot);
666
+ if (!raster ||
667
+ !raster->readPixels(nullptr, *info, bfrPtr, bytesPerRow, srcX, srcY)) {
668
+ return jsi::Value::null();
669
+ }
670
+ return dest;
671
+ }
672
+ #endif
673
+
647
674
  if (!_canvas->readPixels(*info, bfrPtr, bytesPerRow, srcX, srcY)) {
648
675
  return jsi::Value::null();
649
676
  }
@@ -708,7 +735,13 @@ public:
708
735
  void setCanvas(SkCanvas *canvas) { _canvas = canvas; }
709
736
  SkCanvas *getCanvas() { return _canvas; }
710
737
 
738
+ // Optionally associate the canvas with its owning surface. This lets
739
+ // readPixels fall back to a surface snapshot on Graphite, which has no
740
+ // synchronous canvas readback.
741
+ void setSurface(sk_sp<SkSurface> surface) { _surface = std::move(surface); }
742
+
711
743
  private:
712
744
  SkCanvas *_canvas;
745
+ sk_sp<SkSurface> _surface;
713
746
  };
714
747
  } // namespace RNSkia
@@ -277,9 +277,6 @@ public:
277
277
  }
278
278
 
279
279
  JSI_HOST_FUNCTION(readPixels) {
280
- #if defined(SK_GRAPHITE)
281
- throw std::runtime_error("Not implemented yet");
282
- #else
283
280
  int srcX = 0;
284
281
  int srcY = 0;
285
282
  if (count > 0 && !arguments[0].isUndefined()) {
@@ -313,13 +310,24 @@ public:
313
310
  .getArrayBuffer(runtime);
314
311
  auto bfrPtr = reinterpret_cast<void *>(buffer.data(runtime));
315
312
 
313
+ #if defined(SK_GRAPHITE)
314
+ // Graphite offers no synchronous GPU readback, so fall back to a CPU raster
315
+ // copy of the image (a no-op when the image is already raster) and read the
316
+ // pixels from that. This matches the Ganesh behaviour for non-texture and
317
+ // texture-backed images alike.
318
+ auto image = DawnContext::getInstance().MakeRasterImage(getObject());
319
+ if (!image ||
320
+ !image->readPixels(nullptr, info, bfrPtr, bytesPerRow, srcX, srcY)) {
321
+ return jsi::Value::null();
322
+ }
323
+ #else
316
324
  auto grContext = getContext()->getDirectContext();
317
325
  if (!getObject()->readPixels(grContext, info, bfrPtr, bytesPerRow, srcX,
318
326
  srcY)) {
319
327
  return jsi::Value::null();
320
328
  }
321
- return dest;
322
329
  #endif
330
+ return dest;
323
331
  }
324
332
 
325
333
  JSI_HOST_FUNCTION(makeNonTextureImage) {
@@ -30,6 +30,7 @@ public:
30
30
  std::string getObjectType() const override { return "JsiSkMaskFilter"; }
31
31
 
32
32
  EXPORT_JSI_API_TYPENAME(JsiSkMaskFilter, MaskFilter)
33
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMaskFilter, dispose))
33
34
  };
34
35
 
35
36
  } // namespace RNSkia
@@ -72,8 +72,12 @@ public:
72
72
  }
73
73
 
74
74
  JSI_HOST_FUNCTION(getCanvas) {
75
+ auto surface = getObject();
75
76
  auto canvas =
76
- std::make_shared<JsiSkCanvas>(getContext(), getObject()->getCanvas());
77
+ std::make_shared<JsiSkCanvas>(getContext(), surface->getCanvas());
78
+ // Keep a reference to the owning surface so the canvas can read pixels back
79
+ // through a snapshot on Graphite (which lacks synchronous canvas readback).
80
+ canvas->setSurface(surface);
77
81
  return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, canvas,
78
82
  getContext());
79
83
  }
@@ -432,6 +432,29 @@ protected:
432
432
  prototype.setProperty(runtime, name, func);
433
433
  }
434
434
 
435
+ /**
436
+ * Install a method whose native implementation needs the calling jsi::Runtime
437
+ * as its first parameter. Used by entry points that must act per-runtime
438
+ * (e.g. GPU::requestAdapter, which creates a per-runtime RuntimeContext).
439
+ */
440
+ template <typename ReturnType, typename... Args>
441
+ static void
442
+ installMethodWithRuntime(jsi::Runtime &runtime, jsi::Object &prototype,
443
+ const char *name,
444
+ ReturnType (Derived::*method)(jsi::Runtime &,
445
+ Args...)) {
446
+ auto func = jsi::Function::createFromHostFunction(
447
+ runtime, jsi::PropNameID::forUtf8(runtime, name), sizeof...(Args),
448
+ [method](jsi::Runtime &rt, const jsi::Value &thisVal,
449
+ const jsi::Value *args, size_t count) -> jsi::Value {
450
+ auto native = Derived::fromValue(rt, thisVal);
451
+ return callMethodWithRuntime(native.get(), method, rt, args,
452
+ std::index_sequence_for<Args...>{},
453
+ count);
454
+ });
455
+ prototype.setProperty(runtime, name, func);
456
+ }
457
+
435
458
  /**
436
459
  * Install a getter on the prototype.
437
460
  */
@@ -567,6 +590,22 @@ protected:
567
590
  }
568
591
 
569
592
  private:
593
+ // Helper to call a method that takes the calling jsi::Runtime as its first
594
+ // parameter, with JSI argument conversion for the rest and JSI conversion of
595
+ // the result.
596
+ template <typename ReturnType, typename... Args, size_t... Is>
597
+ static jsi::Value
598
+ callMethodWithRuntime(Derived *obj,
599
+ ReturnType (Derived::*method)(jsi::Runtime &, Args...),
600
+ jsi::Runtime &runtime, const jsi::Value *args,
601
+ std::index_sequence<Is...>, size_t count) {
602
+ ReturnType result = (obj->*method)(
603
+ runtime, rnwgpu::JSIConverter<std::decay_t<Args>>::fromJSI(
604
+ runtime, args[Is], Is >= count)...);
605
+ return rnwgpu::JSIConverter<std::decay_t<ReturnType>>::toJSI(
606
+ runtime, std::move(result));
607
+ }
608
+
570
609
  // Helper to call a method with JSI argument conversion
571
610
  template <typename ReturnType, typename... Args, size_t... Is>
572
611
  static jsi::Value callMethod(Derived *obj,
@@ -23,6 +23,8 @@
23
23
  #include "rnwgpu/api/descriptors/GPUMapMode.h"
24
24
  #include "rnwgpu/api/descriptors/GPUShaderStage.h"
25
25
  #include "rnwgpu/api/descriptors/GPUTextureUsage.h"
26
+ #include "rnwgpu/api/WebGPUConstants.h"
27
+ #include "rnwgpu/async/RuntimeContext.h"
26
28
  #include "jsi2/Promise.h"
27
29
 
28
30
  #include "include/core/SkData.h"
@@ -82,6 +84,12 @@ void RNSkManager::installBindings() {
82
84
  jsi::Object::createFromHostObject(*_jsRuntime, _viewApi));
83
85
 
84
86
  #ifdef SK_GRAPHITE
87
+ // Register the main runtime + its CallInvoker so spontaneous events
88
+ // (device.lost / uncapturederror) on main-runtime devices can be delivered to
89
+ // the JS thread without the ProcessEvents pump. Worklet-runtime devices have
90
+ // no invoker (best-effort; see the RuntimeContext "Threading model" doc).
91
+ rnwgpu::async::RuntimeContext::registerMainRuntime(_jsRuntime, _jsCallInvoker);
92
+
85
93
  // Install WebGPU constructors
86
94
  rnwgpu::GPU::installConstructor(*_jsRuntime);
87
95
  rnwgpu::GPUUncapturedErrorEvent::installConstructor(*_jsRuntime);
@@ -104,18 +112,26 @@ void RNSkManager::installBindings() {
104
112
  std::move(navigator));
105
113
  }
106
114
 
107
- // Install WebGPU constant objects as plain JS objects
108
- _jsRuntime->global().setProperty(*_jsRuntime, "GPUBufferUsage",
109
- rnwgpu::GPUBufferUsage::create(*_jsRuntime));
110
- _jsRuntime->global().setProperty(*_jsRuntime, "GPUColorWrite",
111
- rnwgpu::GPUColorWrite::create(*_jsRuntime));
112
- _jsRuntime->global().setProperty(*_jsRuntime, "GPUMapMode",
113
- rnwgpu::GPUMapMode::create(*_jsRuntime));
114
- _jsRuntime->global().setProperty(*_jsRuntime, "GPUShaderStage",
115
- rnwgpu::GPUShaderStage::create(*_jsRuntime));
115
+ // Install WebGPU constant objects as plain JS objects on the main runtime.
116
+ rnwgpu::installWebGPUConstants(*_jsRuntime);
117
+
118
+ // Install a global `installWebGPU()` host function so worklet runtimes can get
119
+ // the same constants. A host function captured into a worklet is serialized as
120
+ // a SerializableHostFunction and re-created on the worklet runtime, so the body
121
+ // runs there (its `rt` is the worklet runtime) and installs the constants on
122
+ // that runtime. The constants come from the native wgpu::*Usage enums, so the
123
+ // values stay a single source of truth across every runtime. Calling it on a
124
+ // runtime that already has the globals is a safe, idempotent no-op.
116
125
  _jsRuntime->global().setProperty(
117
- *_jsRuntime, "GPUTextureUsage",
118
- rnwgpu::GPUTextureUsage::create(*_jsRuntime));
126
+ *_jsRuntime, "installWebGPU",
127
+ jsi::Function::createFromHostFunction(
128
+ *_jsRuntime, jsi::PropNameID::forAscii(*_jsRuntime, "installWebGPU"),
129
+ 0,
130
+ [](jsi::Runtime &rt, const jsi::Value & /*thisVal*/,
131
+ const jsi::Value * /*args*/, size_t /*count*/) -> jsi::Value {
132
+ rnwgpu::installWebGPUConstants(rt);
133
+ return jsi::Value::undefined();
134
+ }));
119
135
 
120
136
  // Install RNWebGPU global object for WebGPU Canvas support
121
137
  auto rnWebGPU = std::make_shared<rnwgpu::RNWebGPU>(gpu, nullptr);
@@ -7,6 +7,12 @@
7
7
 
8
8
  #include "webgpu/webgpu_cpp.h"
9
9
 
10
+ #ifdef __APPLE__
11
+ namespace dawn::native::metal {
12
+ void WaitForCommandsToBeScheduled(WGPUDevice device);
13
+ } // namespace dawn::native::metal
14
+ #endif
15
+
10
16
  namespace rnwgpu {
11
17
 
12
18
  struct NativeInfo {
@@ -112,13 +118,39 @@ public:
112
118
  height = newHeight;
113
119
  }
114
120
 
115
- void present() {
121
+ // Present the current surface texture. Called synchronously from the thread
122
+ // that did getCurrentTexture / submit (via GPUCanvasContext::present), so it
123
+ // preserves Dawn surface thread-affinity. No-op when offscreen / unconfigured
124
+ // (no surface).
125
+ void presentFrame() {
126
+ #ifdef __APPLE__
127
+ // Ensure command buffers are scheduled before presenting. Read the device
128
+ // under a shared lock, then wait without holding it (the wait can block).
129
+ // The device may be reconfigured between the two locks; that is safe because
130
+ // present() is called on the rendering thread right after submit(), the wait
131
+ // just flushes that thread's already-submitted work, and the Present() below
132
+ // re-checks `surface` under the unique lock before touching it.
133
+ wgpu::Device device;
134
+ {
135
+ std::shared_lock<std::shared_mutex> lock(_mutex);
136
+ device = config.device;
137
+ }
138
+ if (device) {
139
+ dawn::native::metal::WaitForCommandsToBeScheduled(device.Get());
140
+ }
141
+ #endif
116
142
  std::unique_lock<std::shared_mutex> lock(_mutex);
117
143
  if (surface) {
118
144
  surface.Present();
119
145
  }
120
146
  }
121
147
 
148
+ // True when an on-screen wgpu::Surface is attached (vs offscreen texture).
149
+ bool hasSurface() {
150
+ std::shared_lock<std::shared_mutex> lock(_mutex);
151
+ return surface != nullptr;
152
+ }
153
+
122
154
  wgpu::Texture getCurrentTexture() {
123
155
  std::shared_lock<std::shared_mutex> lock(_mutex);
124
156
  if (surface) {
@@ -9,17 +9,15 @@
9
9
 
10
10
  #include "Convertors.h"
11
11
  #include "jsi2/JSIConverter.h"
12
- #include "rnwgpu/async/JSIMicrotaskDispatcher.h"
12
+ #include "rnwgpu/async/RuntimeContext.h"
13
13
 
14
14
  namespace rnwgpu {
15
15
 
16
- GPU::GPU(jsi::Runtime &runtime, wgpu::Instance instance)
17
- : NativeObject(CLASS_NAME), _instance(instance) {
18
- auto dispatcher = std::make_shared<async::JSIMicrotaskDispatcher>(runtime);
19
- _async = async::AsyncRunner::getOrCreate(runtime, _instance, dispatcher);
20
- }
16
+ GPU::GPU(jsi::Runtime & /*runtime*/, wgpu::Instance instance)
17
+ : NativeObject(CLASS_NAME), _instance(instance) {}
21
18
 
22
19
  async::AsyncTaskHandle GPU::requestAdapter(
20
+ jsi::Runtime &runtime,
23
21
  std::optional<std::shared_ptr<GPURequestAdapterOptions>> options) {
24
22
  wgpu::RequestAdapterOptions aOptions;
25
23
  Convertor conv;
@@ -32,12 +30,17 @@ async::AsyncTaskHandle GPU::requestAdapter(
32
30
  constexpr auto kDefaultBackendType = wgpu::BackendType::Vulkan;
33
31
  #endif
34
32
  aOptions.backendType = kDefaultBackendType;
35
- return _async->postTask(
36
- [this, aOptions](const async::AsyncTaskHandle::ResolveFunction &resolve,
37
- const async::AsyncTaskHandle::RejectFunction &reject) {
33
+
34
+ // Per-runtime context: async ops requested on this runtime resolve on this
35
+ // runtime's own thread (via its ProcessEvents pump).
36
+ auto context = async::RuntimeContext::getOrCreate(runtime, _instance);
37
+ return context->postTask(
38
+ [this, aOptions,
39
+ context](const async::AsyncTaskHandle::ResolveFunction &resolve,
40
+ const async::AsyncTaskHandle::RejectFunction &reject) {
38
41
  _instance.RequestAdapter(
39
42
  &aOptions, wgpu::CallbackMode::AllowProcessEvents,
40
- [asyncRunner = _async, resolve,
43
+ [context, resolve,
41
44
  reject](wgpu::RequestAdapterStatus status, wgpu::Adapter adapter,
42
45
  wgpu::StringView message) {
43
46
  if (message.length) {
@@ -45,8 +48,8 @@ async::AsyncTaskHandle GPU::requestAdapter(
45
48
  }
46
49
 
47
50
  if (status == wgpu::RequestAdapterStatus::Success && adapter) {
48
- auto adapterHost = std::make_shared<GPUAdapter>(
49
- std::move(adapter), asyncRunner);
51
+ auto adapterHost =
52
+ std::make_shared<GPUAdapter>(std::move(adapter), context);
50
53
  auto result =
51
54
  std::variant<std::nullptr_t, std::shared_ptr<GPUAdapter>>(
52
55
  adapterHost);
@@ -136,9 +139,6 @@ std::unordered_set<std::string> GPU::getWgslLanguageFeatures() {
136
139
  case wgpu::WGSLLanguageFeatureName::BufferView:
137
140
  name = "buffer_view";
138
141
  break;
139
- case wgpu::WGSLLanguageFeatureName::FilteringParameters:
140
- name = "filtering_parameters";
141
- break;
142
142
  case wgpu::WGSLLanguageFeatureName::SwizzleAssignment:
143
143
  name = "swizzle_assignment";
144
144
  break;
@@ -9,8 +9,8 @@
9
9
 
10
10
  #include "jsi2/NativeObject.h"
11
11
 
12
- #include "rnwgpu/async/AsyncRunner.h"
13
12
  #include "rnwgpu/async/AsyncTaskHandle.h"
13
+ #include "rnwgpu/async/RuntimeContext.h"
14
14
 
15
15
  #include "webgpu/webgpu_cpp.h"
16
16
 
@@ -32,7 +32,10 @@ public:
32
32
  public:
33
33
  std::string getBrand() { return CLASS_NAME; }
34
34
 
35
+ // requestAdapter needs the calling runtime so each runtime gets its own
36
+ // RuntimeContext (and ProcessEvents pump on its own thread).
35
37
  async::AsyncTaskHandle requestAdapter(
38
+ jsi::Runtime &runtime,
36
39
  std::optional<std::shared_ptr<GPURequestAdapterOptions>> options);
37
40
  wgpu::TextureFormat getPreferredCanvasFormat();
38
41
 
@@ -40,7 +43,8 @@ public:
40
43
 
41
44
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
42
45
  installGetter(runtime, prototype, "__brand", &GPU::getBrand);
43
- installMethod(runtime, prototype, "requestAdapter", &GPU::requestAdapter);
46
+ installMethodWithRuntime(runtime, prototype, "requestAdapter",
47
+ &GPU::requestAdapter);
44
48
  installMethod(runtime, prototype, "getPreferredCanvasFormat",
45
49
  &GPU::getPreferredCanvasFormat);
46
50
  installGetter(runtime, prototype, "wgslLanguageFeatures",
@@ -51,7 +55,6 @@ public:
51
55
 
52
56
  private:
53
57
  wgpu::Instance _instance;
54
- std::shared_ptr<async::AsyncRunner> _async;
55
58
  };
56
59
 
57
60
  } // namespace rnwgpu
@@ -138,10 +138,10 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
138
138
  }
139
139
  _instance.RequestDevice(
140
140
  &deviceDesc, wgpu::CallbackMode::AllowProcessEvents,
141
- [asyncRunner = _async, resolve, reject, label, creationRuntime,
141
+ [context = _async, resolve, reject, label, creationRuntime,
142
142
  deviceLostBinding](wgpu::RequestDeviceStatus status,
143
143
  wgpu::Device device,
144
- wgpu::StringView message) mutable {
144
+ wgpu::StringView message) {
145
145
  if (message.length) {
146
146
  fprintf(stderr, "%s", message.data);
147
147
  }
@@ -154,10 +154,13 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
154
154
  return;
155
155
  }
156
156
 
157
+ // SetLoggingCallback is a repeatable callback (no callback mode),
158
+ // which rejects capturing lambdas. Pass the runtime pointer
159
+ // through Dawn's userdata argument instead of capturing it.
157
160
  device.SetLoggingCallback(
158
- [creationRuntime](wgpu::LoggingType type,
159
- wgpu::StringView msg) {
160
- if (creationRuntime == nullptr) {
161
+ [](wgpu::LoggingType type, wgpu::StringView msg,
162
+ jsi::Runtime *runtime) {
163
+ if (runtime == nullptr) {
161
164
  return;
162
165
  }
163
166
  const char *logLevel = "";
@@ -183,10 +186,11 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
183
186
  fprintf(stderr, "%s: %.*s\n", logLevel,
184
187
  static_cast<int>(msg.length), msg.data);
185
188
  }
186
- });
189
+ },
190
+ creationRuntime);
187
191
 
188
192
  auto deviceHost = std::make_shared<GPUDevice>(std::move(device),
189
- asyncRunner, label);
193
+ context, label);
190
194
  *deviceLostBinding = deviceHost;
191
195
  resolve([deviceHost = std::move(deviceHost)](
192
196
  jsi::Runtime &runtime) mutable {
@@ -8,8 +8,8 @@
8
8
 
9
9
  #include "jsi2/NativeObject.h"
10
10
 
11
- #include "rnwgpu/async/AsyncRunner.h"
12
11
  #include "rnwgpu/async/AsyncTaskHandle.h"
12
+ #include "rnwgpu/async/RuntimeContext.h"
13
13
 
14
14
  #include "webgpu/webgpu_cpp.h"
15
15
 
@@ -27,7 +27,7 @@ public:
27
27
  static constexpr const char *CLASS_NAME = "GPUAdapter";
28
28
 
29
29
  explicit GPUAdapter(wgpu::Adapter instance,
30
- std::shared_ptr<async::AsyncRunner> async)
30
+ std::shared_ptr<async::RuntimeContext> async)
31
31
  : NativeObject(CLASS_NAME), _instance(instance), _async(async) {}
32
32
 
33
33
  public:
@@ -53,7 +53,7 @@ public:
53
53
 
54
54
  private:
55
55
  wgpu::Adapter _instance;
56
- std::shared_ptr<async::AsyncRunner> _async;
56
+ std::shared_ptr<async::RuntimeContext> _async;
57
57
  };
58
58
 
59
59
  } // namespace rnwgpu
@@ -9,8 +9,8 @@
9
9
 
10
10
  #include "jsi2/NativeObject.h"
11
11
 
12
- #include "rnwgpu/async/AsyncRunner.h"
13
12
  #include "rnwgpu/async/AsyncTaskHandle.h"
13
+ #include "rnwgpu/async/RuntimeContext.h"
14
14
 
15
15
  #include "webgpu/webgpu_cpp.h"
16
16
 
@@ -25,7 +25,7 @@ public:
25
25
  static constexpr const char *CLASS_NAME = "GPUBuffer";
26
26
 
27
27
  explicit GPUBuffer(wgpu::Buffer instance,
28
- std::shared_ptr<async::AsyncRunner> async,
28
+ std::shared_ptr<async::RuntimeContext> async,
29
29
  std::string label)
30
30
  : NativeObject(CLASS_NAME), _instance(instance), _async(async),
31
31
  _label(label) {}
@@ -71,7 +71,7 @@ public:
71
71
 
72
72
  private:
73
73
  wgpu::Buffer _instance;
74
- std::shared_ptr<async::AsyncRunner> _async;
74
+ std::shared_ptr<async::RuntimeContext> _async;
75
75
  std::string _label;
76
76
  struct Mapping {
77
77
  uint64_t start;