@shopify/react-native-skia 2.10.0 → 2.11.0-next.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 (358) hide show
  1. package/android/CMakeLists.txt +7 -41
  2. package/android/build.gradle +33 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
  4. package/cpp/api/JsiNativeBuffer.h +14 -20
  5. package/cpp/api/JsiSkAnimatedImage.h +13 -16
  6. package/cpp/api/JsiSkAnimatedImageFactory.h +9 -7
  7. package/cpp/api/JsiSkApi.h +94 -90
  8. package/cpp/api/JsiSkCanvas.h +108 -251
  9. package/cpp/api/JsiSkColorFilterFactory.h +45 -63
  10. package/cpp/api/JsiSkContourMeasure.h +19 -29
  11. package/cpp/api/JsiSkContourMeasureIter.h +6 -6
  12. package/cpp/api/JsiSkConverters.h +410 -0
  13. package/cpp/api/JsiSkDataFactory.h +9 -15
  14. package/cpp/api/JsiSkFont.h +99 -180
  15. package/cpp/api/JsiSkFontMgr.h +19 -21
  16. package/cpp/api/JsiSkFontMgrFactory.h +4 -5
  17. package/cpp/api/JsiSkImage.h +66 -66
  18. package/cpp/api/JsiSkImageFactory.h +66 -63
  19. package/cpp/api/JsiSkImageFilterFactory.h +354 -608
  20. package/cpp/api/JsiSkImageInfo.h +10 -13
  21. package/cpp/api/JsiSkMaskFilterFactory.h +8 -11
  22. package/cpp/api/JsiSkMatrix.h +36 -73
  23. package/cpp/api/JsiSkNativeObjects.h +60 -92
  24. package/cpp/api/JsiSkPaint.h +73 -131
  25. package/cpp/api/JsiSkParagraph.h +36 -53
  26. package/cpp/api/JsiSkParagraphBuilder.h +36 -64
  27. package/cpp/api/JsiSkParagraphBuilderFactory.h +11 -16
  28. package/cpp/api/JsiSkPath.h +216 -349
  29. package/cpp/api/JsiSkPathBuilder.h +133 -269
  30. package/cpp/api/JsiSkPathBuilderFactory.h +11 -11
  31. package/cpp/api/JsiSkPathEffectFactory.h +52 -72
  32. package/cpp/api/JsiSkPathFactory.h +129 -195
  33. package/cpp/api/JsiSkPicture.h +12 -18
  34. package/cpp/api/JsiSkPictureRecorder.h +14 -15
  35. package/cpp/api/JsiSkPoint.h +4 -4
  36. package/cpp/api/JsiSkRRect.h +7 -8
  37. package/cpp/api/JsiSkRSXform.h +10 -23
  38. package/cpp/api/JsiSkRect.h +23 -31
  39. package/cpp/api/JsiSkRuntimeEffect.h +67 -83
  40. package/cpp/api/JsiSkRuntimeEffectFactory.h +6 -10
  41. package/cpp/api/JsiSkRuntimeShaderBuilder.h +5 -14
  42. package/cpp/api/JsiSkSVG.h +4 -4
  43. package/cpp/api/JsiSkShaderFactory.h +153 -225
  44. package/cpp/api/JsiSkSkottie.h +104 -126
  45. package/cpp/api/JsiSkSurface.h +11 -14
  46. package/cpp/api/JsiSkSurfaceFactory.h +6 -7
  47. package/cpp/api/JsiSkTextBlobFactory.h +31 -54
  48. package/cpp/api/JsiSkTypeface.h +8 -12
  49. package/cpp/api/JsiSkTypefaceFactory.h +9 -7
  50. package/cpp/api/JsiSkTypefaceFontProvider.h +22 -23
  51. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +5 -6
  52. package/cpp/api/JsiSkVertices.h +6 -8
  53. package/cpp/api/JsiSkiaContext.h +10 -11
  54. package/cpp/api/JsiVideo.h +31 -71
  55. package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
  56. package/cpp/dawn/include/dawn/dawn_proc_table.h +330 -0
  57. package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
  58. package/cpp/dawn/include/dawn/dawn_version.h +41 -0
  59. package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
  60. package/cpp/dawn/include/dawn/native/D3D12Backend.h +86 -0
  61. package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
  62. package/cpp/dawn/include/dawn/native/DawnNative.h +369 -0
  63. package/cpp/dawn/include/dawn/native/MetalBackend.h +56 -0
  64. package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
  65. package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
  66. package/cpp/dawn/include/dawn/native/VulkanBackend.h +183 -0
  67. package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
  68. package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
  69. package/cpp/dawn/include/dawn/platform/DawnPlatform.h +210 -0
  70. package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
  71. package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
  72. package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
  73. package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2844 -0
  74. package/cpp/dawn/include/tint/tint.h +90 -0
  75. package/cpp/dawn/include/webgpu/webgpu.h +4987 -0
  76. package/cpp/dawn/include/webgpu/webgpu_cpp.h +10080 -0
  77. package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
  78. package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +161 -0
  79. package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
  80. package/cpp/jsi/JSIConverter.h +0 -31
  81. package/cpp/jsi/NativeObject.h +11 -6
  82. package/cpp/rnskia/RNDawnContext.h +18 -2
  83. package/cpp/rnskia/RNDawnInterop.cpp +19 -0
  84. package/cpp/rnskia/RNDawnUtils.h +18 -1
  85. package/cpp/rnskia/RNSkManager.cpp +5 -162
  86. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
  87. package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
  88. package/cpp/skia/src/gpu/graphite/ResourceTypes.h +360 -0
  89. package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
  90. package/lib/commonjs/mock/index.js +0 -1
  91. package/lib/commonjs/mock/index.js.map +1 -1
  92. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
  93. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  94. package/lib/commonjs/skia/types/Skia.d.ts +5 -15
  95. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  96. package/lib/commonjs/skia/types/index.d.ts +0 -1
  97. package/lib/commonjs/skia/types/index.js +0 -11
  98. package/lib/commonjs/skia/types/index.js.map +1 -1
  99. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  100. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  101. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  102. package/lib/commonjs/skia/web/JsiSkia.js +1 -4
  103. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  104. package/lib/commonjs/views/index.d.ts +0 -1
  105. package/lib/commonjs/views/index.js +0 -11
  106. package/lib/commonjs/views/index.js.map +1 -1
  107. package/lib/module/mock/index.js +0 -1
  108. package/lib/module/mock/index.js.map +1 -1
  109. package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
  110. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  111. package/lib/module/skia/types/Skia.d.ts +5 -15
  112. package/lib/module/skia/types/Skia.js.map +1 -1
  113. package/lib/module/skia/types/index.d.ts +0 -1
  114. package/lib/module/skia/types/index.js +0 -1
  115. package/lib/module/skia/types/index.js.map +1 -1
  116. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  117. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  118. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  119. package/lib/module/skia/web/JsiSkia.js +1 -4
  120. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  121. package/lib/module/views/index.d.ts +0 -1
  122. package/lib/module/views/index.js +0 -1
  123. package/lib/module/views/index.js.map +1 -1
  124. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  125. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  126. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
  127. package/lib/typescript/lib/module/mock/index.d.ts +0 -2
  128. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
  129. package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
  130. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  131. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
  132. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  133. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
  134. package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
  135. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  136. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
  137. package/lib/typescript/src/views/index.d.ts +0 -1
  138. package/libs/.graphite +1 -0
  139. package/package.json +8 -9
  140. package/react-native-skia.podspec +38 -4
  141. package/src/mock/index.ts +0 -1
  142. package/src/skia/types/Image/ImageFactory.ts +15 -6
  143. package/src/skia/types/Skia.ts +5 -15
  144. package/src/skia/types/index.ts +0 -1
  145. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  146. package/src/skia/web/JsiSkia.ts +2 -5
  147. package/src/views/index.ts +0 -1
  148. package/android/cpp/jni/JniWebGPUView.cpp +0 -112
  149. package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
  150. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
  151. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
  152. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
  153. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
  154. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
  155. package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
  156. package/apple/SkiaPlatformContext.h +0 -20
  157. package/apple/SkiaPlatformContext.mm +0 -21
  158. package/apple/SkiaWebGPUView.mm +0 -81
  159. package/apple/WebGPUMetalView.mm +0 -136
  160. package/cpp/rnwgpu/ArrayBuffer.h +0 -116
  161. package/cpp/rnwgpu/Canvas.h +0 -52
  162. package/cpp/rnwgpu/PlatformContext.h +0 -18
  163. package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
  164. package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
  165. package/cpp/rnwgpu/api/Convertors.h +0 -783
  166. package/cpp/rnwgpu/api/External.h +0 -12
  167. package/cpp/rnwgpu/api/GPU.cpp +0 -162
  168. package/cpp/rnwgpu/api/GPU.h +0 -60
  169. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -239
  170. package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
  171. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
  172. package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
  173. package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
  174. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
  175. package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
  176. package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
  177. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
  178. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
  179. package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
  180. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
  181. package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
  182. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
  183. package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
  184. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
  185. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
  186. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
  187. package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
  188. package/cpp/rnwgpu/api/GPUDevice.cpp +0 -613
  189. package/cpp/rnwgpu/api/GPUDevice.h +0 -258
  190. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
  191. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
  192. package/cpp/rnwgpu/api/GPUError.h +0 -35
  193. package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
  194. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
  195. package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
  196. package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
  197. package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
  198. package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
  199. package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
  200. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
  201. package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
  202. package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
  203. package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
  204. package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
  205. package/cpp/rnwgpu/api/GPUQueue.h +0 -84
  206. package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
  207. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
  208. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
  209. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
  210. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
  211. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
  212. package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
  213. package/cpp/rnwgpu/api/GPUSampler.h +0 -44
  214. package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
  215. package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
  216. package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
  217. package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
  218. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
  219. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
  220. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
  221. package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
  222. package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
  223. package/cpp/rnwgpu/api/GPUTexture.h +0 -162
  224. package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
  225. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
  226. package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
  227. package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
  228. package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
  229. package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
  230. package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
  231. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
  232. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
  233. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
  234. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
  235. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
  236. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
  237. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
  238. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
  239. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
  240. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
  241. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
  242. package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
  243. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
  244. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
  245. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
  246. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
  247. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
  248. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
  249. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
  250. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
  251. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
  252. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
  253. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
  254. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
  255. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
  256. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
  257. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
  258. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
  259. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
  260. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
  261. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
  262. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
  263. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
  264. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
  265. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
  266. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
  267. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
  268. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
  269. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
  270. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
  271. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
  272. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
  273. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
  274. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
  275. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
  276. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
  277. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
  278. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
  279. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
  280. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
  281. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
  282. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
  283. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
  284. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
  285. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
  286. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
  287. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
  288. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
  289. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
  290. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
  291. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
  292. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
  293. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
  294. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
  295. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -213
  296. package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
  297. package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
  298. package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
  299. package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
  300. package/lib/commonjs/skia/types/WebGPU.js +0 -105
  301. package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
  302. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
  303. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
  304. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
  305. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  306. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
  307. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  308. package/lib/commonjs/specs/utils.d.ts +0 -1
  309. package/lib/commonjs/specs/utils.js +0 -11
  310. package/lib/commonjs/specs/utils.js.map +0 -1
  311. package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
  312. package/lib/commonjs/views/WebGPUCanvas.js +0 -79
  313. package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
  314. package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
  315. package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
  316. package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
  317. package/lib/module/skia/types/WebGPU.d.ts +0 -184
  318. package/lib/module/skia/types/WebGPU.js +0 -99
  319. package/lib/module/skia/types/WebGPU.js.map +0 -1
  320. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
  321. package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
  322. package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
  323. package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  324. package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
  325. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  326. package/lib/module/specs/utils.d.ts +0 -1
  327. package/lib/module/specs/utils.js +0 -5
  328. package/lib/module/specs/utils.js.map +0 -1
  329. package/lib/module/views/WebGPUCanvas.d.ts +0 -33
  330. package/lib/module/views/WebGPUCanvas.js +0 -70
  331. package/lib/module/views/WebGPUCanvas.js.map +0 -1
  332. package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
  333. package/lib/module/views/WebGPUCanvas.web.js +0 -12
  334. package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
  335. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
  336. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
  337. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
  338. package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
  339. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
  340. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
  341. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
  342. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
  343. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
  344. package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
  345. package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
  346. package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
  347. package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
  348. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
  349. package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  350. package/lib/typescript/src/specs/utils.d.ts +0 -1
  351. package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
  352. package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
  353. package/src/skia/types/WebGPU.ts +0 -226
  354. package/src/specs/WebGPUViewNativeComponent.ts +0 -11
  355. package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
  356. package/src/specs/utils.ts +0 -4
  357. package/src/views/WebGPUCanvas.tsx +0 -125
  358. package/src/views/WebGPUCanvas.web.tsx +0 -36
@@ -11,27 +11,6 @@
11
11
 
12
12
  #include "jsi/RuntimeAwareCache.h"
13
13
 
14
- #ifdef SK_GRAPHITE
15
- #include "RNDawnContext.h"
16
- #include "jsi/Promise.h"
17
- #include "rnwgpu/ArrayBuffer.h"
18
- #include "rnwgpu/api/GPU.h"
19
- #include "rnwgpu/api/GPUUncapturedErrorEvent.h"
20
- #include "rnwgpu/api/ImageBitmap.h"
21
- #include "rnwgpu/api/RNWebGPU.h"
22
- #include "rnwgpu/api/WebGPUConstants.h"
23
- #include "rnwgpu/api/descriptors/GPUBufferUsage.h"
24
- #include "rnwgpu/api/descriptors/GPUColorWrite.h"
25
- #include "rnwgpu/api/descriptors/GPUMapMode.h"
26
- #include "rnwgpu/api/descriptors/GPUShaderStage.h"
27
- #include "rnwgpu/api/descriptors/GPUTextureUsage.h"
28
- #include "rnwgpu/async/RuntimeContext.h"
29
-
30
- #include "include/core/SkData.h"
31
- #include "include/core/SkImage.h"
32
- #include "include/core/SkImageInfo.h"
33
- #endif
34
-
35
14
  namespace RNSkia {
36
15
  namespace jsi = facebook::jsi;
37
16
 
@@ -43,7 +22,7 @@ RNSkManager::RNSkManager(
43
22
  _jsCallInvoker(jsCallInvoker),
44
23
  _viewApi(std::make_shared<RNSkJsiViewApi>(platformContext)) {
45
24
 
46
- // Register main runtime (used by both Skia and WebGPU bindings)
25
+ // Register main runtime
47
26
  RNJsi::BaseRuntimeAwareCache::setMainJsRuntime(_jsRuntime);
48
27
 
49
28
  // Install bindings
@@ -51,12 +30,6 @@ RNSkManager::RNSkManager(
51
30
  }
52
31
 
53
32
  RNSkManager::~RNSkManager() {
54
- #ifdef SK_GRAPHITE
55
- // Drop all canvas registry entries: after a reload the JS side restarts its
56
- // contextId counter, and stale entries would alias new canvases onto dead
57
- // surfaces.
58
- rnwgpu::SurfaceRegistry::getInstance().clear();
59
- #endif
60
33
  // Free up any references
61
34
  _viewApi = nullptr;
62
35
  _jsRuntime = nullptr;
@@ -87,139 +60,9 @@ void RNSkManager::installBindings() {
87
60
  _jsRuntime->global().setProperty(*_jsRuntime, "SkiaViewApi",
88
61
  makeJsiObject(*_jsRuntime, _viewApi));
89
62
 
90
- #ifdef SK_GRAPHITE
91
- // Register the main runtime + its CallInvoker so spontaneous events
92
- // (device.lost / uncapturederror) on main-runtime devices can be delivered to
93
- // the JS thread without the ProcessEvents pump. Worklet-runtime devices have
94
- // no invoker (best-effort; see the RuntimeContext "Threading model" doc).
95
- rnwgpu::async::RuntimeContext::registerMainRuntime(_jsRuntime,
96
- _jsCallInvoker);
97
-
98
- // Install WebGPU constructors
99
- rnwgpu::GPU::installConstructor(*_jsRuntime);
100
- rnwgpu::GPUUncapturedErrorEvent::installConstructor(*_jsRuntime);
101
- // Create and expose navigator.gpu using DawnContext's instance
102
- auto &dawnContext = DawnContext::getInstance();
103
- auto gpu =
104
- std::make_shared<rnwgpu::GPU>(*_jsRuntime, dawnContext.getWGPUInstance());
105
- auto navigatorValue =
106
- _jsRuntime->global().getProperty(*_jsRuntime, "navigator");
107
- if (navigatorValue.isObject()) {
108
- auto navigator = navigatorValue.asObject(*_jsRuntime);
109
- navigator.setProperty(*_jsRuntime, "gpu",
110
- rnwgpu::GPU::create(*_jsRuntime, gpu));
111
- } else {
112
- // Create navigator object if it doesn't exist
113
- jsi::Object navigator(*_jsRuntime);
114
- navigator.setProperty(*_jsRuntime, "gpu",
115
- rnwgpu::GPU::create(*_jsRuntime, gpu));
116
- _jsRuntime->global().setProperty(*_jsRuntime, "navigator",
117
- std::move(navigator));
118
- }
119
-
120
- // Install WebGPU constant objects as plain JS objects on the main runtime.
121
- rnwgpu::installWebGPUConstants(*_jsRuntime);
122
-
123
- // Install a global `installWebGPU()` host function so worklet runtimes can
124
- // get the same constants. A host function captured into a worklet is
125
- // serialized as a SerializableHostFunction and re-created on the worklet
126
- // runtime, so the body runs there (its `rt` is the worklet runtime) and
127
- // installs the constants on that runtime. The constants come from the native
128
- // wgpu::*Usage enums, so the values stay a single source of truth across
129
- // every runtime. Calling it on a runtime that already has the globals is a
130
- // safe, idempotent no-op.
131
- _jsRuntime->global().setProperty(
132
- *_jsRuntime, "installWebGPU",
133
- jsi::Function::createFromHostFunction(
134
- *_jsRuntime, jsi::PropNameID::forAscii(*_jsRuntime, "installWebGPU"),
135
- 0,
136
- [](jsi::Runtime &rt, const jsi::Value & /*thisVal*/,
137
- const jsi::Value * /*args*/, size_t /*count*/) -> jsi::Value {
138
- rnwgpu::installWebGPUConstants(rt);
139
- return jsi::Value::undefined();
140
- }));
141
-
142
- // Install RNWebGPU global object for WebGPU Canvas support
143
- auto rnWebGPU = std::make_shared<rnwgpu::RNWebGPU>(gpu, nullptr);
144
- _jsRuntime->global().setProperty(
145
- *_jsRuntime, "RNWebGPU", rnwgpu::RNWebGPU::create(*_jsRuntime, rnWebGPU));
146
-
147
- // DRAFT — compile-unverified. Install the ImageBitmap constructor (so
148
- // `instanceof ImageBitmap` works) and a global createImageBitmap() that
149
- // accepts the non-standard encoded-BufferSource overload.
150
- //
151
- // The BufferSource is run through the shared rnwgpu::ArrayBuffer converter,
152
- // which validates byteOffset/byteLength against the backing buffer and throws
153
- // synchronously on a spoofed / out-of-bounds view — so createImageBitmap()
154
- // rejects rather than reading out of bounds (see ArrayBufferBounds /
155
- // ImageBitmapBounds specs). Decoding uses Skia's own codec; no platform image
156
- // decoder is needed.
157
- rnwgpu::ImageBitmap::installConstructor(*_jsRuntime);
158
- _jsRuntime->global().setProperty(
159
- *_jsRuntime, "createImageBitmap",
160
- jsi::Function::createFromHostFunction(
161
- *_jsRuntime,
162
- jsi::PropNameID::forAscii(*_jsRuntime, "createImageBitmap"), 1,
163
- [](jsi::Runtime &rt, const jsi::Value & /*thisVal*/,
164
- const jsi::Value *args, size_t count) -> jsi::Value {
165
- if (count < 1 || !args[0].isObject()) {
166
- throw jsi::JSError(
167
- rt, "createImageBitmap requires a BufferSource argument");
168
- }
169
- // Only the encoded ArrayBuffer / ArrayBufferView overload is
170
- // supported here. Anything else (Blob, ImageData, …) is rejected.
171
- auto obj = args[0].getObject(rt);
172
- bool isBufferSource = obj.isArrayBuffer(rt);
173
- if (!isBufferSource && obj.hasProperty(rt, "buffer")) {
174
- auto bufferProp = obj.getProperty(rt, "buffer");
175
- isBufferSource = bufferProp.isObject() &&
176
- bufferProp.getObject(rt).isArrayBuffer(rt);
177
- }
178
- if (!isBufferSource) {
179
- throw jsi::JSError(rt, "createImageBitmap: unsupported source "
180
- "(expected an ArrayBuffer or TypedArray "
181
- "of encoded image bytes)");
182
- }
183
- // Validates bounds and THROWS synchronously on a spoofed view, so
184
- // the bad pointer never reaches the copy below.
185
- auto buffer = rnwgpu::JSIConverter<
186
- std::shared_ptr<rnwgpu::ArrayBuffer>>::fromJSI(rt, args[0],
187
- false);
188
- // Copy the encoded bytes off the JS-owned ArrayBuffer.
189
- const uint8_t *bytes = buffer->data();
190
- std::vector<uint8_t> encoded(bytes, bytes + buffer->size());
191
-
192
- return rnwgpu::Promise::createPromise(
193
- rt, [encoded = std::move(encoded)](
194
- jsi::Runtime &runtime,
195
- std::shared_ptr<rnwgpu::Promise> promise) mutable {
196
- auto skData =
197
- SkData::MakeWithCopy(encoded.data(), encoded.size());
198
- auto image = SkImages::DeferredFromEncodedData(skData);
199
- if (image == nullptr) {
200
- promise->reject(
201
- "createImageBitmap: failed to decode image data");
202
- return;
203
- }
204
- const int w = image->width();
205
- const int h = image->height();
206
- auto info = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType,
207
- kUnpremul_SkAlphaType);
208
- std::vector<uint8_t> pixels(info.computeMinByteSize());
209
- // nullptr context: decode/read on the CPU (raster).
210
- if (!image->readPixels(nullptr, info, pixels.data(),
211
- info.minRowBytes(), 0, 0)) {
212
- promise->reject(
213
- "createImageBitmap: failed to read decoded pixels");
214
- return;
215
- }
216
- auto bitmap = std::make_shared<rnwgpu::ImageBitmap>(
217
- std::move(pixels), static_cast<size_t>(w),
218
- static_cast<size_t>(h));
219
- promise->resolve(
220
- rnwgpu::ImageBitmap::create(runtime, bitmap));
221
- });
222
- }));
223
- #endif
63
+ // The WebGPU JS API (RNWebGPU, navigator.gpu, constants, createImageBitmap)
64
+ // is no longer installed here: react-native-webgpu is the single WebGPU API
65
+ // surface for React Native. Graphite keeps Dawn as an internal
66
+ // implementation detail only.
224
67
  }
225
68
  } // namespace RNSkia
@@ -21,6 +21,8 @@
21
21
  disallow_large_instanced_draw) \
22
22
  GPU_OP(EMULATE_ABS_INT_FUNCTION, \
23
23
  emulate_abs_int_function) \
24
+ GPU_OP(ENSURE_PREVIOUS_FRAMEBUFFER_NOT_DELETED, \
25
+ ensure_previous_framebuffer_not_deleted) \
24
26
  GPU_OP(FLUSH_ON_FRAMEBUFFER_CHANGE, \
25
27
  flush_on_framebuffer_change) \
26
28
  GPU_OP(FORCE_UPDATE_SCISSOR_STATE_WHEN_BINDING_FBO0, \
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef skgpu_graphite_ContextOptionsPriv_DEFINED
9
+ #define skgpu_graphite_ContextOptionsPriv_DEFINED
10
+
11
+ #include "include/private/base/SkMath.h"
12
+
13
+ #include <optional>
14
+
15
+ namespace skgpu::graphite {
16
+
17
+ enum class PathRendererStrategy;
18
+
19
+ /**
20
+ * Private options that are only meant for testing within Skia's tools.
21
+ */
22
+ struct ContextOptionsPriv {
23
+
24
+ int fMaxTextureSizeOverride = SK_MaxS32;
25
+
26
+ /**
27
+ * If true, will store a pointer in Recorder that points back to the Context
28
+ * that created it. Used by readPixels() and other methods that normally require a Context.
29
+ */
30
+ bool fStoreContextRefInRecorder = false;
31
+
32
+ /**
33
+ * If true, enables layer based draw ordering.
34
+ */
35
+ bool fDrawListLayer = false;
36
+
37
+ /**
38
+ * Override Caps' default strategy heuristics to prioritize this one if set *and* is supported.
39
+ */
40
+ std::optional<PathRendererStrategy> fPathRendererStrategy;
41
+ };
42
+
43
+ } // namespace skgpu::graphite
44
+
45
+ #endif // skgpu_graphite_ContextOptionsPriv_DEFINED
@@ -0,0 +1,360 @@
1
+ /*
2
+ * Copyright 2021 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef skgpu_graphite_ResourceTypes_DEFINED
9
+ #define skgpu_graphite_ResourceTypes_DEFINED
10
+
11
+ #include "include/core/SkSamplingOptions.h"
12
+ #include "include/core/SkSpan.h"
13
+ #include "include/core/SkTileMode.h"
14
+ #include "include/gpu/graphite/GraphiteTypes.h"
15
+ #include "include/private/base/SkTo.h"
16
+ #include "src/base/SkEnumBitMask.h"
17
+ #include "src/base/SkMathPriv.h"
18
+
19
+ namespace skgpu::graphite {
20
+
21
+ class Buffer;
22
+
23
+ // This declaration of the DepthStencilFlags' SkEnumBitMask ops is here bc, internally, we use
24
+ // DepthStencilFlags as bit fields but, externally (i.e., from the GraphiteTypes view), we want
25
+ // it to appear as just an enum class.
26
+ SK_MAKE_BITMASK_OPS(DepthStencilFlags)
27
+ // The same goes for SampleCount
28
+ SK_MAKE_BITMASK_OPS(SampleCount)
29
+
30
+ /**
31
+ * There are only a few possible valid sample counts (1, 2, 4, 8, 16). So we can key on those 5
32
+ * options instead of the actual sample value. The resulting key value only requires 3 bits of space
33
+ */
34
+ static constexpr uint32_t SamplesToKey(SampleCount numSamples) {
35
+ switch (numSamples) {
36
+ case SampleCount::k1:
37
+ return 0;
38
+ case SampleCount::k2:
39
+ return 1;
40
+ case SampleCount::k4:
41
+ return 2;
42
+ case SampleCount::k8:
43
+ return 3;
44
+ case SampleCount::k16:
45
+ return 4;
46
+ }
47
+ SkUNREACHABLE;
48
+ }
49
+ static constexpr SampleCount KeyToSamples(uint32_t keyBits) {
50
+ SkASSERT(keyBits <= 4);
51
+ return static_cast<SampleCount>(1 << keyBits);
52
+ }
53
+ static constexpr int kNumSampleKeyBits = 3;
54
+
55
+ /**
56
+ * The strategy that a renderpass and/or pipeline use to access the current dst pixel when blending.
57
+ */
58
+ enum class DstReadStrategy : uint8_t {
59
+ kNoneRequired,
60
+ kTextureCopy,
61
+ kTextureSample, // TODO(b/238756862): To be used once direct texture sampling is implemented
62
+ kReadFromInput,
63
+ kFramebufferFetch,
64
+
65
+ kLast = kFramebufferFetch
66
+ };
67
+ inline static constexpr int kDstReadStrategyCount = (int)(DstReadStrategy::kLast) + 1;
68
+
69
+ /**
70
+ * This enum is used to specify the load operation to be used when a RenderPass begins execution.
71
+ */
72
+ enum class LoadOp : uint8_t {
73
+ kLoad,
74
+ kClear,
75
+ kDiscard,
76
+
77
+ kLast = kDiscard
78
+ };
79
+ inline static constexpr int kLoadOpCount = (int)(LoadOp::kLast) + 1;
80
+
81
+ /**
82
+ * This enum is used to specify the store operation to be used when a RenderPass ends execution.
83
+ */
84
+ enum class StoreOp : uint8_t {
85
+ kStore,
86
+ kDiscard,
87
+
88
+ kLast = kDiscard
89
+ };
90
+ inline static constexpr int kStoreOpCount = (int)(StoreOp::kLast) + 1;
91
+
92
+ /**
93
+ * What a GPU buffer will be used for
94
+ */
95
+ enum class BufferType : int {
96
+ kVertex,
97
+ kIndex,
98
+ kXferCpuToGpu,
99
+ kXferGpuToCpu,
100
+ kUniform,
101
+ kStorage,
102
+ kQuery,
103
+
104
+ // GPU-only buffer types
105
+ kIndirect,
106
+ kVertexStorage,
107
+ kIndexStorage,
108
+
109
+ kLast = kIndexStorage,
110
+ };
111
+ static const int kBufferTypeCount = static_cast<int>(BufferType::kLast) + 1;
112
+
113
+ /**
114
+ * Data layout requirements on host-shareable buffer contents.
115
+ */
116
+ enum class Layout : uint8_t {
117
+ kInvalid = 0,
118
+ kStd140,
119
+ kStd140_F16,
120
+ kStd430,
121
+ kStd430_F16,
122
+ kMetal,
123
+ };
124
+
125
+ static constexpr const char* LayoutString(Layout layout) {
126
+ switch(layout) {
127
+ case Layout::kStd140: return "std140";
128
+ case Layout::kStd140_F16: return "std140-f16";
129
+ case Layout::kStd430: return "std430";
130
+ case Layout::kStd430_F16: return "std430-f16";
131
+ case Layout::kMetal: return "metal";
132
+ case Layout::kInvalid: return "invalid";
133
+ }
134
+ SkUNREACHABLE;
135
+ }
136
+
137
+ /**
138
+ * Indicates the intended access pattern over resource memory. This is used to select the most
139
+ * efficient memory type during resource creation based on the capabilities of the platform.
140
+ *
141
+ * This is only a hint and the actual memory type will be determined based on the resource type and
142
+ * backend capabilities.
143
+ */
144
+ enum class AccessPattern : uint8_t {
145
+ // GPU-only memory does not need to support reads/writes from the CPU. GPU-private memory will
146
+ // be preferred if the backend supports an efficient private memory type.
147
+ kGpuOnly,
148
+
149
+ // The resource needs to be CPU visible, e.g. for read-back or as a copy/upload source.
150
+ kHostVisible,
151
+
152
+ // Use to debug GPU only buffers.
153
+ kGpuOnlyCopySrc,
154
+ };
155
+
156
+ /**
157
+ * Determines whether the contents of a GPU buffer sub-allocation gets cleared to 0 before being
158
+ * used in a GPU command submission.
159
+ */
160
+ enum class ClearBuffer : bool {
161
+ kNo = false,
162
+ kYes = true,
163
+ };
164
+
165
+ /**
166
+ * Must the contents of the Resource be preserved af a render pass or can a more efficient
167
+ * representation be chosen when supported by hardware.
168
+ */
169
+ enum class Discardable : bool {
170
+ kNo = false,
171
+ kYes = true
172
+ };
173
+
174
+ enum class Ownership : uint8_t {
175
+ kOwned,
176
+ kWrapped,
177
+ };
178
+
179
+ /** Uniquely identifies the type of resource that is cached with a GraphiteResourceKey. */
180
+ using ResourceType = uint32_t;
181
+
182
+ /**
183
+ * Can the resource be held by multiple users at the same time?
184
+ * For example, stencil buffers, pipelines, etc.
185
+ */
186
+ enum class Shareable : uint8_t {
187
+ kNo, // The resource is visible in the ResourceCache once all its usage refs are dropped
188
+ kScratch, // The resource is visible to other Recorders, but acts like kNo within a Recording
189
+ kYes, // The resource is always visible in the ResourceCache
190
+ };
191
+
192
+ /*
193
+ * Struct that can be passed into bind buffer calls on the CommandBuffer. The ownership of the
194
+ * buffer and its usage in command submission must be tracked by the caller (e.g. as with
195
+ * buffers created by DrawBufferManager).
196
+ */
197
+ struct BindBufferInfo {
198
+ const Buffer* fBuffer = nullptr;
199
+ uint32_t fOffset = 0;
200
+ uint32_t fSize = 0;
201
+
202
+ explicit operator bool() const { return SkToBool(fBuffer); }
203
+
204
+ bool operator==(const BindBufferInfo& o) const {
205
+ return fBuffer == o.fBuffer && (!fBuffer || (fOffset == o.fOffset && fSize == o.fSize));
206
+ }
207
+ bool operator!=(const BindBufferInfo& o) const { return !(*this == o); }
208
+ };
209
+
210
+ // How texture memory is arranged on the GPU, which can impact what operations are supported.
211
+ enum class Tiling : uint8_t {
212
+ kOptimal,
213
+ kLinear
214
+ };
215
+
216
+ // Coarse ways in which a specific texture can be used, or the theoretic set of usages a texture
217
+ // format supports.
218
+ enum class TextureUsage : uint8_t {
219
+ kRender = 0x01, // Can be used as a rendering attachment
220
+ kMSRTSS = 0x02, // Can be rendered with MSAA-render-to-single-sampled functionality
221
+ kSample = 0x04, // Can be sampled within a shader
222
+ kCopySrc = 0x08, // Can be copied into another texture or buffer
223
+ kCopyDst = 0x10, // Can be the copy target of another texture or buffer
224
+ kStorage = 0x20, // Can be read and written to in a compute pipeline
225
+ kHostCopy = 0x40, // Can be written to directly from host memory
226
+ };
227
+ SK_MAKE_BITMASK_OPS(TextureUsage)
228
+
229
+ struct ImmutableSamplerInfo {
230
+ // If the sampler requires YCbCr conversion, backends can place that information here.
231
+ // In order to fit within SamplerDesc's uint32 desc field, backends can only utilize up to
232
+ // kMaxNumConversionInfoBits bits.
233
+ uint32_t fNonFormatYcbcrConversionInfo = 0;
234
+ // fFormat represents known OR external format numerical representation.
235
+ uint64_t fFormat = 0;
236
+ };
237
+
238
+ /**
239
+ * Struct used to describe how a Texture/TextureProxy/TextureProxyView is sampled.
240
+ */
241
+ struct SamplerDesc {
242
+ static_assert(kSkTileModeCount <= 4 && kSkFilterModeCount <= 2 && kSkMipmapModeCount <= 4);
243
+
244
+ constexpr SamplerDesc(const SkSamplingOptions& samplingOptions, SkTileMode tileMode)
245
+ : SamplerDesc(samplingOptions, {tileMode, tileMode}) {}
246
+
247
+ constexpr SamplerDesc(const SkSamplingOptions& samplingOptions,
248
+ const std::pair<SkTileMode, SkTileMode> tileModes,
249
+ const ImmutableSamplerInfo info = {})
250
+ : fDesc((static_cast<int>(tileModes.first) << kTileModeXShift ) |
251
+ (static_cast<int>(tileModes.second) << kTileModeYShift ) |
252
+ (static_cast<int>(samplingOptions.filter) << kFilterModeShift ) |
253
+ (static_cast<int>(samplingOptions.mipmap) << kMipmapModeShift ) |
254
+ (info.fNonFormatYcbcrConversionInfo << kImmutableSamplerInfoShift) )
255
+ , fFormat(info.fFormat)
256
+ , fExternalFormatMostSignificantBits(info.fFormat >> 32) {
257
+
258
+ // Cubic sampling is handled in a shader, with the actual texture sampled by with NN,
259
+ // but that is what a cubic SkSamplingOptions is set to if you ignore 'cubic', which let's
260
+ // us simplify how we construct SamplerDec's from the options passed to high-level draws.
261
+ SkASSERT(!samplingOptions.useCubic || (samplingOptions.filter == SkFilterMode::kNearest &&
262
+ samplingOptions.mipmap == SkMipmapMode::kNone));
263
+
264
+ // TODO: Add aniso value when used.
265
+
266
+ // Assert that fYcbcrConversionInfo does not exceed kMaxNumConversionInfoBits such that
267
+ // the conversion information can fit within an uint32.
268
+ SkASSERT(info.fNonFormatYcbcrConversionInfo >> kMaxNumConversionInfoBits == 0);
269
+ }
270
+ constexpr SamplerDesc() = default;
271
+ constexpr SamplerDesc(const SamplerDesc&) = default;
272
+ constexpr SamplerDesc& operator=(const SamplerDesc&) = default;
273
+
274
+ constexpr SamplerDesc(uint32_t desc, uint32_t format, uint32_t extFormatMSB)
275
+ : fDesc(desc)
276
+ , fFormat(format)
277
+ , fExternalFormatMostSignificantBits(extFormatMSB) {}
278
+
279
+ bool operator==(const SamplerDesc& o) const {
280
+ return o.fDesc == fDesc && o.fFormat == fFormat &&
281
+ o.fExternalFormatMostSignificantBits == fExternalFormatMostSignificantBits;
282
+ }
283
+
284
+ bool operator!=(const SamplerDesc& o) const { return !(*this == o); }
285
+
286
+ SkTileMode tileModeX() const {
287
+ return static_cast<SkTileMode>((fDesc >> kTileModeXShift) & 0b11);
288
+ }
289
+ SkTileMode tileModeY() const {
290
+ return static_cast<SkTileMode>((fDesc >> kTileModeYShift) & 0b11);
291
+ }
292
+ SkFilterMode filterMode() const {
293
+ return static_cast<SkFilterMode>((fDesc >> kFilterModeShift) & 0b01);
294
+ }
295
+ SkMipmapMode mipmap() const {
296
+ return static_cast<SkMipmapMode>((fDesc >> kMipmapModeShift) & 0b11);
297
+ }
298
+ uint32_t desc() const { return fDesc; }
299
+ uint32_t format() const { return fFormat; }
300
+ uint32_t externalFormatMSBs() const { return fExternalFormatMostSignificantBits; }
301
+ bool isImmutable() const { return (fDesc >> kImmutableSamplerInfoShift) != 0; }
302
+ bool usesExternalFormat() const { return (fDesc >> kImmutableSamplerInfoShift) & 0b1; }
303
+
304
+ // NOTE: returns the HW sampling options to use, so a bicubic SkSamplingOptions will become
305
+ // nearest-neighbor sampling in HW.
306
+ SkSamplingOptions samplingOptions() const {
307
+ // TODO: Add support for anisotropic filtering
308
+ SkFilterMode filter = static_cast<SkFilterMode>((fDesc >> kFilterModeShift) & 0b01);
309
+ SkMipmapMode mipmap = static_cast<SkMipmapMode>((fDesc >> kMipmapModeShift) & 0b11);
310
+ return SkSamplingOptions(filter, mipmap);
311
+ }
312
+
313
+ ImmutableSamplerInfo immutableSamplerInfo() const {
314
+ return {this->desc() >> kImmutableSamplerInfoShift,
315
+ ((uint64_t) this->externalFormatMSBs() << 32) | (uint64_t) this->format()};
316
+ }
317
+
318
+ SkSpan<const uint32_t> asSpan() const {
319
+ // Span length depends upon whether the sampler is immutable and if it uses a known format
320
+ return {&fDesc, 1u + this->isImmutable() + this->usesExternalFormat()};
321
+ }
322
+
323
+ // These are public such that backends can bitshift data in order to determine whatever
324
+ // sampler qualities they need from fDesc.
325
+ static constexpr int kNumTileModeBits = SkNextLog2(int(SkTileMode::kLastTileMode)+1);
326
+ static constexpr int kNumFilterModeBits = SkNextLog2(int(SkFilterMode::kLast)+1);
327
+ static constexpr int kNumMipmapModeBits = SkNextLog2(int(SkMipmapMode::kLast)+1);
328
+ static constexpr int kMaxNumConversionInfoBits =
329
+ 32 - kNumFilterModeBits - kNumMipmapModeBits - kNumTileModeBits;
330
+
331
+ static constexpr int kTileModeXShift = 0;
332
+ static constexpr int kTileModeYShift = kTileModeXShift + kNumTileModeBits;
333
+ static constexpr int kFilterModeShift = kTileModeYShift + kNumTileModeBits;
334
+ static constexpr int kMipmapModeShift = kFilterModeShift + kNumFilterModeBits;
335
+ static constexpr int kImmutableSamplerInfoShift = kMipmapModeShift + kNumMipmapModeBits;
336
+
337
+ // Only relevant when using immutable samplers. Otherwise, can be ignored. The number of uint32s
338
+ // required to represent all relevant sampler desc information depends upon whether we are using
339
+ // a known or external format.
340
+ static constexpr int kInt32sNeededKnownFormat = 2;
341
+ static constexpr int kInt32sNeededExternalFormat = 3;
342
+
343
+ private:
344
+ // Note: The order of these member attributes matters to keep unique object representation
345
+ // such that SkGoodHash can be used to hash SamplerDesc objects.
346
+ uint32_t fDesc = 0;
347
+
348
+ // Data fields populated by backend Caps which store texture format information (needed for
349
+ // YCbCr sampling). Only relevant when using immutable samplers. Otherwise, can be ignored.
350
+ // Known formats only require a uint32, but external formats can be up to a uint64. We store
351
+ // this as two separate uint32s such that has_unique_object_representation can be true, allowing
352
+ // this structure to be easily hashed using SkGoodHash. So, external formats can be represented
353
+ // with (fExternalFormatMostSignificantBits << 32) | fFormat.
354
+ uint32_t fFormat = 0;
355
+ uint32_t fExternalFormatMostSignificantBits = 0;
356
+ };
357
+
358
+ } // namespace skgpu::graphite
359
+
360
+ #endif // skgpu_graphite_ResourceTypes_DEFINED