@shopify/react-native-skia 2.6.5 → 2.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +1 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerDelegate.java +35 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerInterface.java +17 -0
- package/cpp/api/JsiSkCanvas.h +33 -0
- package/cpp/api/JsiSkImage.h +12 -4
- package/cpp/api/JsiSkSurface.h +5 -1
- package/cpp/rnwgpu/api/GPU.cpp +0 -3
- package/cpp/rnwgpu/api/GPUAdapter.cpp +9 -5
- package/cpp/rnwgpu/api/GPUDevice.cpp +55 -4
- package/cpp/rnwgpu/api/GPUDevice.h +6 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
- package/cpp/rnwgpu/api/GPUSharedFence.cpp +80 -0
- package/cpp/rnwgpu/api/GPUSharedFence.h +53 -0
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +64 -11
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +13 -8
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +51 -0
- package/cpp/skia/include/android/GrAHardwareBufferUtils.h +1 -1
- package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +1 -1
- package/cpp/skia/include/android/SkAnimatedImage.h +1 -1
- package/cpp/skia/include/codec/SkCodec.h +0 -8
- package/cpp/skia/include/codec/SkEncodedOrigin.h +1 -1
- package/cpp/skia/include/codec/SkPngRustDecoder.h +1 -1
- package/cpp/skia/include/core/SkBitmap.h +2 -8
- package/cpp/skia/include/core/SkCPURecorder.h +3 -1
- package/cpp/skia/include/core/SkCanvasVirtualEnforcer.h +1 -1
- package/cpp/skia/include/core/SkColorType.h +5 -3
- package/cpp/skia/include/core/SkContourMeasure.h +1 -1
- package/cpp/skia/include/core/SkCoverageMode.h +1 -1
- package/cpp/skia/include/core/SkCubicMap.h +1 -1
- package/cpp/skia/include/core/SkExecutor.h +1 -1
- package/cpp/skia/include/core/SkFont.h +15 -0
- package/cpp/skia/include/core/SkFontArguments.h +6 -1
- package/cpp/skia/include/core/SkFontMetrics.h +1 -1
- package/cpp/skia/include/core/SkFontMgr.h +36 -1
- package/cpp/skia/include/core/SkFontParameters.h +1 -1
- package/cpp/skia/include/core/SkFontScanner.h +1 -1
- package/cpp/skia/include/core/SkFontTypes.h +1 -1
- package/cpp/skia/include/core/SkM44.h +1 -1
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +1 -1
- package/cpp/skia/include/core/SkPathBuilder.h +10 -4
- package/cpp/skia/include/core/SkPathIter.h +1 -1
- package/cpp/skia/include/core/SkPathTypes.h +1 -1
- package/cpp/skia/include/core/SkPixelRef.h +4 -1
- package/cpp/skia/include/core/SkRecorder.h +2 -1
- package/cpp/skia/include/core/SkRegion.h +7 -1
- package/cpp/skia/include/core/SkSamplingOptions.h +1 -1
- package/cpp/skia/include/core/SkSerialProcs.h +8 -1
- package/cpp/skia/include/core/SkShader.h +3 -5
- package/cpp/skia/include/core/SkSpan.h +1 -1
- package/cpp/skia/include/core/SkStream.h +1 -1
- package/cpp/skia/include/core/SkStrikeRef.h +80 -0
- package/cpp/skia/include/core/SkTileMode.h +1 -1
- package/cpp/skia/include/core/SkVertices.h +1 -1
- package/cpp/skia/include/core/SkYUVAPixmaps.h +3 -5
- package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
- package/cpp/skia/include/docs/SkXPSDocument.h +1 -1
- package/cpp/skia/include/effects/SkGradient.h +1 -1
- package/cpp/skia/include/effects/SkHighContrastFilter.h +1 -1
- package/cpp/skia/include/effects/SkShaderMaskFilter.h +1 -1
- package/cpp/skia/include/effects/SkTrimPathEffect.h +1 -1
- package/cpp/skia/include/encode/SkEncoder.h +1 -1
- package/cpp/skia/include/encode/SkJpegEncoder.h +1 -1
- package/cpp/skia/include/encode/SkPngEncoder.h +1 -1
- package/cpp/skia/include/encode/SkPngRustEncoder.h +1 -1
- package/cpp/skia/include/encode/SkWebpEncoder.h +1 -1
- package/cpp/skia/include/gpu/GpuTypes.h +2 -0
- package/cpp/skia/include/gpu/MutableTextureState.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +6 -62
- package/cpp/skia/include/gpu/ganesh/GrContextThreadSafeProxy.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +2 -1
- package/cpp/skia/include/gpu/ganesh/mock/GrMockBackendSurface.h +59 -0
- package/cpp/skia/include/gpu/ganesh/mock/GrMockTypes.h +1 -1
- package/cpp/skia/include/gpu/ganesh/mtl/GrMtlBackendContext.h +1 -1
- package/cpp/skia/include/gpu/ganesh/mtl/GrMtlTypes.h +1 -1
- package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +1 -1
- package/cpp/skia/include/gpu/graphite/Context.h +11 -4
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +6 -0
- package/cpp/skia/include/gpu/graphite/Image.h +82 -9
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +7 -2
- package/cpp/skia/include/gpu/graphite/Recorder.h +6 -4
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileColorFilter.h +11 -1
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +1 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +1 -1
- package/cpp/skia/include/gpu/mtl/MtlMemoryAllocator.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanTypes.h +1 -1
- package/cpp/skia/include/ports/SkCFObject.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_Fontations.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_android_ndk.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_data.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +1 -1
- package/cpp/skia/include/ports/SkFontMgr_mac_ct.h +1 -1
- package/cpp/skia/include/ports/SkFontScanner_Fontations.h +1 -1
- package/cpp/skia/include/ports/SkFontScanner_FreeType.h +1 -1
- package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
- package/cpp/skia/include/private/SkExif.h +1 -1
- package/cpp/skia/include/private/SkGainmapInfo.h +1 -1
- package/cpp/skia/include/private/SkGainmapShader.h +1 -1
- package/cpp/skia/include/private/SkHdrMetadata.h +21 -0
- package/cpp/skia/include/private/SkJpegGainmapEncoder.h +1 -1
- package/cpp/skia/include/private/SkPixelStorage.h +37 -0
- package/cpp/skia/include/private/SkXmp.h +1 -1
- package/cpp/skia/include/private/base/SkAssert.h +6 -5
- package/cpp/skia/include/private/base/SkContainers.h +1 -1
- package/cpp/skia/include/private/base/SkFeatures.h +30 -30
- package/cpp/skia/include/private/base/SkLog.h +1 -7
- package/cpp/skia/include/private/base/SkLogPriority.h +4 -5
- package/cpp/skia/include/private/base/SkMacros.h +1 -1
- package/cpp/skia/include/private/base/SkMalloc.h +1 -1
- package/cpp/skia/include/private/base/SkSafe32.h +1 -1
- package/cpp/skia/include/private/base/SkSpan_impl.h +1 -1
- package/cpp/skia/include/private/base/SkTDArray.h +13 -1
- package/cpp/skia/include/private/base/SkTPin.h +1 -1
- package/cpp/skia/include/private/base/SkTo.h +1 -1
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +1 -1
- package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +1 -1
- package/cpp/skia/include/private/chromium/SkCodecsICCProfileChromium.h +52 -0
- package/cpp/skia/include/private/chromium/SkExifChromium.h +26 -0
- package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +2 -1
- package/cpp/skia/include/private/gpu/vk/SkiaVulkan.h +1 -1
- package/cpp/skia/include/sksl/SkSLDebugTrace.h +1 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_icd.h +41 -51
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_layer.h +42 -53
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +158 -154
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +68 -65
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +90 -87
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +9 -9
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +2 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +82 -79
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +24 -24
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +2 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +95 -96
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std.h +151 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std_decode.h +68 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +1 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +5 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +7 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +291 -158
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +13174 -10113
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +23 -19
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +159 -165
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +22 -19
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +3 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +3 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +94 -88
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ohos.h +120 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +55 -51
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +18 -15
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +23 -19
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +31 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +5 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +27 -27
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +20 -16
- package/cpp/skia/include/utils/SkEventTracer.h +6 -1
- package/cpp/skia/include/utils/SkOrderedFontMgr.h +1 -1
- package/cpp/skia/include/utils/SkShadowUtils.h +1 -1
- package/cpp/skia/include/utils/SkTextUtils.h +1 -1
- package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +20 -4
- package/cpp/skia/modules/skcms/src/Transform_inl.h +11 -15
- package/cpp/skia/modules/skcms/src/skcms_public.h +2 -0
- package/cpp/skia/modules/skottie/include/ExternalLayer.h +1 -1
- package/cpp/skia/modules/skottie/include/Skottie.h +1 -1
- package/cpp/skia/modules/skottie/include/SkottieProperty.h +1 -1
- package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
- package/cpp/skia/modules/skottie/include/TextShaper.h +1 -1
- package/cpp/skia/modules/skottie/src/SkottieValue.h +1 -1
- package/cpp/skia/modules/skottie/src/animator/Animator.h +1 -1
- package/cpp/skia/modules/skottie/src/text/Font.h +1 -1
- package/cpp/skia/modules/skottie/src/text/TextAdapter.h +1 -1
- package/cpp/skia/modules/skottie/src/text/TextAnimator.h +3 -2
- package/cpp/skia/modules/skottie/src/text/TextValue.h +1 -1
- package/cpp/skia/modules/skparagraph/include/DartTypes.h +1 -1
- package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +5 -1
- package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphPainter.h +1 -1
- package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +12 -5
- package/cpp/skia/modules/skparagraph/include/TextShadow.h +1 -1
- package/cpp/skia/modules/skparagraph/include/TextStyle.h +1 -1
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGDraw.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGradient.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGGroup.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGImage.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGPaint.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGPlane.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGRect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGScene.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGText.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGTransform.h +1 -1
- package/cpp/skia/modules/skshaper/include/SkShaper_coretext.h +8 -1
- package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeMerge.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeMorphology.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFilterContext.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
- package/cpp/skia/src/base/SkAutoLocaleSetter.h +94 -0
- package/cpp/skia/src/base/SkUTF.h +1 -1
- package/lib/commonjs/skia/types/WebGPU.d.ts +70 -5
- package/lib/commonjs/skia/types/WebGPU.js.map +1 -1
- package/lib/module/skia/types/WebGPU.d.ts +70 -5
- package/lib/module/skia/types/WebGPU.js.map +1 -1
- package/lib/typescript/src/skia/types/WebGPU.d.ts +70 -5
- package/package.json +5 -5
- package/src/skia/types/WebGPU.ts +83 -5
package/android/CMakeLists.txt
CHANGED
|
@@ -142,6 +142,7 @@ if(SK_GRAPHITE)
|
|
|
142
142
|
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPURenderPassEncoder.cpp"
|
|
143
143
|
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPURenderPipeline.cpp"
|
|
144
144
|
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUShaderModule.cpp"
|
|
145
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUSharedFence.cpp"
|
|
145
146
|
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUSharedTextureMemory.cpp"
|
|
146
147
|
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUSupportedLimits.cpp"
|
|
147
148
|
"${PROJECT_SOURCE_DIR}/../cpp/rnwgpu/api/GPUTexture.cpp"
|
package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerDelegate.java
ADDED
|
@@ -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
|
+
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaWebGPUViewManagerInterface.java
ADDED
|
@@ -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
|
+
}
|
package/cpp/api/JsiSkCanvas.h
CHANGED
|
@@ -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
|
package/cpp/api/JsiSkImage.h
CHANGED
|
@@ -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) {
|
package/cpp/api/JsiSkSurface.h
CHANGED
|
@@ -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(),
|
|
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
|
}
|
package/cpp/rnwgpu/api/GPU.cpp
CHANGED
|
@@ -136,9 +136,6 @@ std::unordered_set<std::string> GPU::getWgslLanguageFeatures() {
|
|
|
136
136
|
case wgpu::WGSLLanguageFeatureName::BufferView:
|
|
137
137
|
name = "buffer_view";
|
|
138
138
|
break;
|
|
139
|
-
case wgpu::WGSLLanguageFeatureName::FilteringParameters:
|
|
140
|
-
name = "filtering_parameters";
|
|
141
|
-
break;
|
|
142
139
|
case wgpu::WGSLLanguageFeatureName::SwizzleAssignment:
|
|
143
140
|
name = "swizzle_assignment";
|
|
144
141
|
break;
|
|
@@ -141,7 +141,7 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
|
|
|
141
141
|
[asyncRunner = _async, resolve, reject, label, creationRuntime,
|
|
142
142
|
deviceLostBinding](wgpu::RequestDeviceStatus status,
|
|
143
143
|
wgpu::Device device,
|
|
144
|
-
wgpu::StringView message)
|
|
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
|
-
[
|
|
159
|
-
|
|
160
|
-
if (
|
|
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,7 +186,8 @@ 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
193
|
asyncRunner, label);
|
|
@@ -265,6 +265,55 @@ std::shared_ptr<GPUSharedTextureMemory> GPUDevice::importSharedTextureMemory(
|
|
|
265
265
|
std::move(label));
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
std::shared_ptr<GPUSharedFence> GPUDevice::importSharedFence(
|
|
269
|
+
std::shared_ptr<GPUSharedFenceDescriptor> descriptor) {
|
|
270
|
+
if (!descriptor || descriptor->handle == nullptr) {
|
|
271
|
+
throw std::runtime_error("GPUDevice::importSharedFence(): handle must be a "
|
|
272
|
+
"non-null native handle");
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
wgpu::SharedFenceDescriptor desc{};
|
|
276
|
+
std::string label = descriptor->label.value_or("");
|
|
277
|
+
if (!label.empty()) {
|
|
278
|
+
desc.label = wgpu::StringView(label.c_str(), label.size());
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// The chained platform descriptor must outlive the synchronous
|
|
282
|
+
// ImportSharedFence() below; declare them all and chain the matching one.
|
|
283
|
+
wgpu::SharedFenceMTLSharedEventDescriptor mtlDesc{};
|
|
284
|
+
wgpu::SharedFenceSyncFDDescriptor syncFdDesc{};
|
|
285
|
+
wgpu::SharedFenceVkSemaphoreOpaqueFDDescriptor vkFdDesc{};
|
|
286
|
+
|
|
287
|
+
const std::string &type = descriptor->type;
|
|
288
|
+
if (type == "mtl-shared-event") {
|
|
289
|
+
// handle is an id<MTLSharedEvent> pointer.
|
|
290
|
+
mtlDesc.sharedEvent = descriptor->handle;
|
|
291
|
+
desc.nextInChain = &mtlDesc;
|
|
292
|
+
} else if (type == "sync-fd") {
|
|
293
|
+
// handle is an OS file descriptor.
|
|
294
|
+
syncFdDesc.handle =
|
|
295
|
+
static_cast<int>(reinterpret_cast<uintptr_t>(descriptor->handle));
|
|
296
|
+
desc.nextInChain = &syncFdDesc;
|
|
297
|
+
} else if (type == "vk-semaphore-opaque-fd") {
|
|
298
|
+
vkFdDesc.handle =
|
|
299
|
+
static_cast<int>(reinterpret_cast<uintptr_t>(descriptor->handle));
|
|
300
|
+
desc.nextInChain = &vkFdDesc;
|
|
301
|
+
} else {
|
|
302
|
+
throw std::runtime_error(
|
|
303
|
+
"GPUDevice::importSharedFence(): unsupported fence type '" + type +
|
|
304
|
+
"' (expected 'mtl-shared-event', 'sync-fd' or "
|
|
305
|
+
"'vk-semaphore-opaque-fd')");
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
auto fence = _instance.ImportSharedFence(&desc);
|
|
309
|
+
if (fence == nullptr) {
|
|
310
|
+
throw std::runtime_error(
|
|
311
|
+
"GPUDevice::importSharedFence(): ImportSharedFence returned null - is "
|
|
312
|
+
"the matching 'shared-fence-*' feature enabled on the device?");
|
|
313
|
+
}
|
|
314
|
+
return std::make_shared<GPUSharedFence>(std::move(fence), std::move(label));
|
|
315
|
+
}
|
|
316
|
+
|
|
268
317
|
async::AsyncTaskHandle GPUDevice::createComputePipelineAsync(
|
|
269
318
|
std::shared_ptr<GPUComputePipelineDescriptor> descriptor) {
|
|
270
319
|
wgpu::ComputePipelineDescriptor desc{};
|
|
@@ -289,7 +338,7 @@ async::AsyncTaskHandle GPUDevice::createComputePipelineAsync(
|
|
|
289
338
|
&desc, wgpu::CallbackMode::AllowProcessEvents,
|
|
290
339
|
[pipelineHolder, resolve,
|
|
291
340
|
reject](wgpu::CreatePipelineAsyncStatus status,
|
|
292
|
-
wgpu::ComputePipeline pipeline,
|
|
341
|
+
wgpu::ComputePipeline pipeline, wgpu::StringView msg) {
|
|
293
342
|
if (status == wgpu::CreatePipelineAsyncStatus::Success && pipeline) {
|
|
294
343
|
pipelineHolder->_instance = pipeline;
|
|
295
344
|
resolve([pipelineHolder](jsi::Runtime &runtime) mutable {
|
|
@@ -298,7 +347,8 @@ async::AsyncTaskHandle GPUDevice::createComputePipelineAsync(
|
|
|
298
347
|
});
|
|
299
348
|
} else {
|
|
300
349
|
std::string error =
|
|
301
|
-
msg ? std::string(msg)
|
|
350
|
+
msg.length ? std::string(msg.data, msg.length)
|
|
351
|
+
: "Failed to create compute pipeline";
|
|
302
352
|
reject(std::move(error));
|
|
303
353
|
}
|
|
304
354
|
});
|
|
@@ -330,7 +380,7 @@ async::AsyncTaskHandle GPUDevice::createRenderPipelineAsync(
|
|
|
330
380
|
&desc, wgpu::CallbackMode::AllowProcessEvents,
|
|
331
381
|
[pipelineHolder, resolve,
|
|
332
382
|
reject](wgpu::CreatePipelineAsyncStatus status,
|
|
333
|
-
wgpu::RenderPipeline pipeline,
|
|
383
|
+
wgpu::RenderPipeline pipeline, wgpu::StringView msg) {
|
|
334
384
|
if (status == wgpu::CreatePipelineAsyncStatus::Success && pipeline) {
|
|
335
385
|
pipelineHolder->_instance = pipeline;
|
|
336
386
|
resolve([pipelineHolder](jsi::Runtime &runtime) mutable {
|
|
@@ -339,7 +389,8 @@ async::AsyncTaskHandle GPUDevice::createRenderPipelineAsync(
|
|
|
339
389
|
});
|
|
340
390
|
} else {
|
|
341
391
|
std::string error =
|
|
342
|
-
msg ? std::string(msg)
|
|
392
|
+
msg.length ? std::string(msg.data, msg.length)
|
|
393
|
+
: "Failed to create render pipeline";
|
|
343
394
|
reject(std::move(error));
|
|
344
395
|
}
|
|
345
396
|
});
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
#include "GPURenderPipeline.h"
|
|
38
38
|
#include "GPUSampler.h"
|
|
39
39
|
#include "GPUShaderModule.h"
|
|
40
|
+
#include "GPUSharedFence.h"
|
|
40
41
|
#include "GPUSharedTextureMemory.h"
|
|
41
42
|
#include "GPUSupportedLimits.h"
|
|
42
43
|
#include "GPUTexture.h"
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
#include "descriptors/GPURenderPipelineDescriptor.h"
|
|
53
54
|
#include "descriptors/GPUSamplerDescriptor.h"
|
|
54
55
|
#include "descriptors/GPUShaderModuleDescriptor.h"
|
|
56
|
+
#include "descriptors/GPUSharedFenceDescriptor.h"
|
|
55
57
|
#include "descriptors/GPUSharedTextureMemoryDescriptor.h"
|
|
56
58
|
#include "descriptors/GPUTextureDescriptor.h"
|
|
57
59
|
|
|
@@ -124,6 +126,8 @@ public:
|
|
|
124
126
|
std::shared_ptr<GPUExternalTextureDescriptor> descriptor);
|
|
125
127
|
std::shared_ptr<GPUSharedTextureMemory> importSharedTextureMemory(
|
|
126
128
|
std::shared_ptr<GPUSharedTextureMemoryDescriptor> descriptor);
|
|
129
|
+
std::shared_ptr<GPUSharedFence>
|
|
130
|
+
importSharedFence(std::shared_ptr<GPUSharedFenceDescriptor> descriptor);
|
|
127
131
|
std::shared_ptr<GPUBindGroupLayout> createBindGroupLayout(
|
|
128
132
|
std::shared_ptr<GPUBindGroupLayoutDescriptor> descriptor);
|
|
129
133
|
std::shared_ptr<GPUPipelineLayout>
|
|
@@ -179,6 +183,8 @@ public:
|
|
|
179
183
|
&GPUDevice::importExternalTexture);
|
|
180
184
|
installMethod(runtime, prototype, "importSharedTextureMemory",
|
|
181
185
|
&GPUDevice::importSharedTextureMemory);
|
|
186
|
+
installMethod(runtime, prototype, "importSharedFence",
|
|
187
|
+
&GPUDevice::importSharedFence);
|
|
182
188
|
installMethod(runtime, prototype, "createBindGroupLayout",
|
|
183
189
|
&GPUDevice::createBindGroupLayout);
|
|
184
190
|
installMethod(runtime, prototype, "createPipelineLayout",
|
|
@@ -18,7 +18,7 @@ async::AsyncTaskHandle GPUShaderModule::getCompilationInfo() {
|
|
|
18
18
|
wgpu::CallbackMode::AllowProcessEvents,
|
|
19
19
|
[result, resolve,
|
|
20
20
|
reject](wgpu::CompilationInfoRequestStatus status,
|
|
21
|
-
const wgpu::CompilationInfo *compilationInfo)
|
|
21
|
+
const wgpu::CompilationInfo *compilationInfo) {
|
|
22
22
|
if (status != wgpu::CompilationInfoRequestStatus::Success ||
|
|
23
23
|
compilationInfo == nullptr) {
|
|
24
24
|
reject("Failed to get compilation info");
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#include "GPUSharedFence.h"
|
|
2
|
+
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#if defined(__ANDROID__)
|
|
7
|
+
#include <fcntl.h>
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
namespace rnwgpu {
|
|
11
|
+
|
|
12
|
+
namespace {
|
|
13
|
+
|
|
14
|
+
// Kebab-case names matching the shared-fence-* feature strings (see Unions.h /
|
|
15
|
+
// GPUFeatures.h).
|
|
16
|
+
std::string sharedFenceTypeToString(wgpu::SharedFenceType type) {
|
|
17
|
+
switch (type) {
|
|
18
|
+
case wgpu::SharedFenceType::MTLSharedEvent:
|
|
19
|
+
return "mtl-shared-event";
|
|
20
|
+
case wgpu::SharedFenceType::SyncFD:
|
|
21
|
+
return "sync-fd";
|
|
22
|
+
case wgpu::SharedFenceType::VkSemaphoreOpaqueFD:
|
|
23
|
+
return "vk-semaphore-opaque-fd";
|
|
24
|
+
case wgpu::SharedFenceType::VkSemaphoreZirconHandle:
|
|
25
|
+
return "vk-semaphore-zircon-handle";
|
|
26
|
+
case wgpu::SharedFenceType::DXGISharedHandle:
|
|
27
|
+
return "dxgi-shared-handle";
|
|
28
|
+
case wgpu::SharedFenceType::EGLSync:
|
|
29
|
+
return "egl-sync";
|
|
30
|
+
default:
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
} // namespace
|
|
36
|
+
|
|
37
|
+
jsi::Value GPUSharedFence::exportInfo(jsi::Runtime &runtime, const jsi::Value &,
|
|
38
|
+
const jsi::Value *, size_t) {
|
|
39
|
+
wgpu::SharedFenceExportInfo info{};
|
|
40
|
+
uint64_t handle = 0;
|
|
41
|
+
|
|
42
|
+
#if defined(__APPLE__)
|
|
43
|
+
// Apple: the handle is an id<MTLSharedEvent> pointer.
|
|
44
|
+
wgpu::SharedFenceMTLSharedEventExportInfo mtlInfo{};
|
|
45
|
+
info.nextInChain = &mtlInfo;
|
|
46
|
+
_instance.ExportInfo(&info);
|
|
47
|
+
handle = reinterpret_cast<uint64_t>(mtlInfo.sharedEvent);
|
|
48
|
+
#elif defined(__ANDROID__)
|
|
49
|
+
// Android: the handle is an OS file descriptor (sync_fd). Dawn's ExportInfo
|
|
50
|
+
// returns a BORROWED fd: it is owned by the SharedFence and closed when the
|
|
51
|
+
// fence is destroyed. This exported handle is documented as caller-owned (the
|
|
52
|
+
// caller must close() it), so dup() it. Without the dup the same fd is closed
|
|
53
|
+
// twice (once by the caller and once by Dawn on fence destruction), tripping
|
|
54
|
+
// Android's fdsan (double-close abort).
|
|
55
|
+
wgpu::SharedFenceSyncFDExportInfo fdInfo{};
|
|
56
|
+
info.nextInChain = &fdInfo;
|
|
57
|
+
_instance.ExportInfo(&info);
|
|
58
|
+
int exportedFd = fdInfo.handle >= 0
|
|
59
|
+
? ::fcntl(fdInfo.handle, F_DUPFD_CLOEXEC, 0)
|
|
60
|
+
: fdInfo.handle;
|
|
61
|
+
handle = static_cast<uint64_t>(static_cast<uint32_t>(exportedFd));
|
|
62
|
+
#else
|
|
63
|
+
// react-native-skia only targets Apple (Metal) and Android (Vulkan). On any
|
|
64
|
+
// other platform there is no native handle convention to expose, so fail
|
|
65
|
+
// loudly rather than handing back a meaningless handle of 0.
|
|
66
|
+
throw jsi::JSError(runtime,
|
|
67
|
+
"GPUSharedFence::export(): unsupported platform (only "
|
|
68
|
+
"Apple/Metal and Android/Vulkan are supported)");
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
jsi::Object result(runtime);
|
|
72
|
+
result.setProperty(
|
|
73
|
+
runtime, "type",
|
|
74
|
+
jsi::String::createFromUtf8(runtime, sharedFenceTypeToString(info.type)));
|
|
75
|
+
result.setProperty(runtime, "handle",
|
|
76
|
+
jsi::BigInt::fromUint64(runtime, handle));
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "jsi2/NativeObject.h"
|
|
7
|
+
|
|
8
|
+
#include "webgpu/webgpu_cpp.h"
|
|
9
|
+
|
|
10
|
+
namespace rnwgpu {
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
// Wraps a wgpu::SharedFence: a native GPU sync primitive (id<MTLSharedEvent> on
|
|
15
|
+
// Apple, sync-fd / VkSemaphore on Android).
|
|
16
|
+
class GPUSharedFence : public NativeObject<GPUSharedFence> {
|
|
17
|
+
public:
|
|
18
|
+
static constexpr const char *CLASS_NAME = "GPUSharedFence";
|
|
19
|
+
|
|
20
|
+
explicit GPUSharedFence(wgpu::SharedFence instance, std::string label)
|
|
21
|
+
: NativeObject(CLASS_NAME), _instance(std::move(instance)),
|
|
22
|
+
_label(std::move(label)) {}
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
26
|
+
|
|
27
|
+
// export() -> { type, handle }: exposes the native handle (as a BigInt) so
|
|
28
|
+
// app code can wait on or signal the fence. The caller owns the returned
|
|
29
|
+
// handle (e.g. an exported sync-fd must be close()d).
|
|
30
|
+
jsi::Value exportInfo(jsi::Runtime &runtime, const jsi::Value &thisVal,
|
|
31
|
+
const jsi::Value *args, size_t count);
|
|
32
|
+
|
|
33
|
+
std::string getLabel() { return _label; }
|
|
34
|
+
void setLabel(const std::string &label) {
|
|
35
|
+
_label = label;
|
|
36
|
+
_instance.SetLabel(_label.c_str());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
40
|
+
installGetter(runtime, prototype, "__brand", &GPUSharedFence::getBrand);
|
|
41
|
+
installMethod(runtime, prototype, "export", &GPUSharedFence::exportInfo);
|
|
42
|
+
installGetterSetter(runtime, prototype, "label", &GPUSharedFence::getLabel,
|
|
43
|
+
&GPUSharedFence::setLabel);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
inline wgpu::SharedFence get() { return _instance; }
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
wgpu::SharedFence _instance;
|
|
50
|
+
std::string _label;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace rnwgpu
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
#include "GPUSharedTextureMemory.h"
|
|
2
2
|
|
|
3
|
+
#include <cstdint>
|
|
3
4
|
#include <memory>
|
|
5
|
+
#include <optional>
|
|
4
6
|
#include <stdexcept>
|
|
5
7
|
#include <string>
|
|
8
|
+
#include <vector>
|
|
6
9
|
|
|
7
10
|
#include "Convertors.h"
|
|
8
11
|
|
|
@@ -29,8 +32,9 @@ std::shared_ptr<GPUTexture> GPUSharedTextureMemory::createTexture(
|
|
|
29
32
|
texture, descriptor.value()->label.value_or(""), false);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
void GPUSharedTextureMemory::beginAccess(
|
|
36
|
+
std::shared_ptr<GPUTexture> texture, bool initialized,
|
|
37
|
+
std::optional<std::vector<std::shared_ptr<GPUSharedFenceState>>> fences) {
|
|
34
38
|
if (!texture) {
|
|
35
39
|
throw std::runtime_error(
|
|
36
40
|
"GPUSharedTextureMemory::beginAccess(): texture is null");
|
|
@@ -38,9 +42,28 @@ bool GPUSharedTextureMemory::beginAccess(std::shared_ptr<GPUTexture> texture,
|
|
|
38
42
|
wgpu::SharedTextureMemoryBeginAccessDescriptor desc{};
|
|
39
43
|
desc.initialized = initialized;
|
|
40
44
|
desc.concurrentRead = false;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
|
|
46
|
+
// Built in lockstep so fenceCount covers both arrays, and kept in locals so
|
|
47
|
+
// the raw pointers outlive the synchronous BeginAccess() below.
|
|
48
|
+
std::vector<wgpu::SharedFence> rawFences;
|
|
49
|
+
std::vector<uint64_t> values;
|
|
50
|
+
if (fences.has_value()) {
|
|
51
|
+
for (const auto &state : *fences) {
|
|
52
|
+
if (state && state->fence) {
|
|
53
|
+
rawFences.push_back(state->fence->get());
|
|
54
|
+
values.push_back(state->signaledValue);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!rawFences.empty()) {
|
|
59
|
+
desc.fenceCount = rawFences.size();
|
|
60
|
+
desc.fences = rawFences.data();
|
|
61
|
+
desc.signaledValues = values.data();
|
|
62
|
+
} else {
|
|
63
|
+
desc.fenceCount = 0;
|
|
64
|
+
desc.fences = nullptr;
|
|
65
|
+
desc.signaledValues = nullptr;
|
|
66
|
+
}
|
|
44
67
|
|
|
45
68
|
#if defined(__ANDROID__)
|
|
46
69
|
// Dawn's Vulkan backend (AHardwareBuffer) validates that the begin-access
|
|
@@ -57,14 +80,21 @@ bool GPUSharedTextureMemory::beginAccess(std::shared_ptr<GPUTexture> texture,
|
|
|
57
80
|
#endif
|
|
58
81
|
|
|
59
82
|
auto status = _instance.BeginAccess(texture->get(), &desc);
|
|
60
|
-
|
|
83
|
+
if (!status) {
|
|
84
|
+
throw std::runtime_error("GPUSharedTextureMemory::beginAccess() failed");
|
|
85
|
+
}
|
|
61
86
|
}
|
|
62
87
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
jsi::Value GPUSharedTextureMemory::endAccess(jsi::Runtime &runtime,
|
|
89
|
+
const jsi::Value &,
|
|
90
|
+
const jsi::Value *args,
|
|
91
|
+
size_t count) {
|
|
92
|
+
if (count < 1 || !args[0].isObject()) {
|
|
93
|
+
throw jsi::JSError(
|
|
94
|
+
runtime, "GPUSharedTextureMemory::endAccess(): expected (texture)");
|
|
67
95
|
}
|
|
96
|
+
auto texture = GPUTexture::fromValue(runtime, args[0]);
|
|
97
|
+
|
|
68
98
|
wgpu::SharedTextureMemoryEndAccessState state{};
|
|
69
99
|
|
|
70
100
|
#if defined(__ANDROID__)
|
|
@@ -76,7 +106,30 @@ bool GPUSharedTextureMemory::endAccess(std::shared_ptr<GPUTexture> texture) {
|
|
|
76
106
|
#endif
|
|
77
107
|
|
|
78
108
|
auto status = _instance.EndAccess(texture->get(), &state);
|
|
79
|
-
|
|
109
|
+
if (!status) {
|
|
110
|
+
throw jsi::JSError(runtime, "GPUSharedTextureMemory::endAccess() failed");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Copy each wgpu::SharedFence (ref-counted) into its own GPUSharedFence
|
|
114
|
+
// wrapper before `state` is destroyed.
|
|
115
|
+
jsi::Array fences(runtime, state.fenceCount);
|
|
116
|
+
for (size_t i = 0; i < state.fenceCount; i++) {
|
|
117
|
+
wgpu::SharedFence fence = state.fences[i];
|
|
118
|
+
auto wrapper = std::make_shared<GPUSharedFence>(std::move(fence), "");
|
|
119
|
+
jsi::Object entry(runtime);
|
|
120
|
+
entry.setProperty(runtime, "fence",
|
|
121
|
+
GPUSharedFence::create(runtime, std::move(wrapper)));
|
|
122
|
+
entry.setProperty(
|
|
123
|
+
runtime, "signaledValue",
|
|
124
|
+
jsi::BigInt::fromUint64(runtime, state.signaledValues[i]));
|
|
125
|
+
fences.setValueAtIndex(runtime, i, std::move(entry));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
jsi::Object result(runtime);
|
|
129
|
+
result.setProperty(runtime, "initialized",
|
|
130
|
+
jsi::Value(static_cast<bool>(state.initialized)));
|
|
131
|
+
result.setProperty(runtime, "fences", std::move(fences));
|
|
132
|
+
return result;
|
|
80
133
|
}
|
|
81
134
|
|
|
82
135
|
} // namespace rnwgpu
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <cstdint>
|
|
3
4
|
#include <memory>
|
|
4
5
|
#include <optional>
|
|
5
6
|
#include <string>
|
|
7
|
+
#include <vector>
|
|
6
8
|
|
|
7
9
|
#include "jsi2/NativeObject.h"
|
|
8
10
|
|
|
9
11
|
#include "webgpu/webgpu_cpp.h"
|
|
10
12
|
|
|
13
|
+
#include "GPUSharedFence.h"
|
|
11
14
|
#include "GPUTexture.h"
|
|
15
|
+
#include "descriptors/GPUSharedFenceState.h"
|
|
12
16
|
#include "descriptors/GPUTextureDescriptor.h"
|
|
13
17
|
|
|
14
18
|
namespace rnwgpu {
|
|
@@ -30,15 +34,16 @@ public:
|
|
|
30
34
|
std::shared_ptr<GPUTexture> createTexture(
|
|
31
35
|
std::optional<std::shared_ptr<GPUTextureDescriptor>> descriptor);
|
|
32
36
|
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
// Optional `fences` are wait fences: Dawn waits for each to reach its
|
|
38
|
+
// signaledValue before writing the surface. Throws on failure.
|
|
39
|
+
void beginAccess(
|
|
40
|
+
std::shared_ptr<GPUTexture> texture, bool initialized,
|
|
41
|
+
std::optional<std::vector<std::shared_ptr<GPUSharedFenceState>>> fences);
|
|
38
42
|
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
43
|
+
// endAccess(texture) -> { initialized, fences: { fence, signaledValue }[] }
|
|
44
|
+
// Surfaces the fences Dawn produced for the access. Throws on failure.
|
|
45
|
+
jsi::Value endAccess(jsi::Runtime &runtime, const jsi::Value &thisVal,
|
|
46
|
+
const jsi::Value *args, size_t count);
|
|
42
47
|
|
|
43
48
|
std::string getLabel() { return _label; }
|
|
44
49
|
void setLabel(const std::string &label) {
|