react-native-wgpu 0.2.7 → 0.2.9

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 (50) hide show
  1. package/cpp/dawn/native/MetalBackend.h +1 -0
  2. package/cpp/dawn/native/WebGPUBackend.h +15 -1
  3. package/cpp/dawn/webgpu_cpp_print.h +9 -0
  4. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -6
  5. package/cpp/rnwgpu/api/GPUAdapter.h +0 -3
  6. package/cpp/rnwgpu/api/GPUAdapterInfo.h +6 -1
  7. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +1 -1
  8. package/cpp/rnwgpu/api/GPUDevice.cpp +1 -1
  9. package/cpp/rnwgpu/api/descriptors/Unions.h +4 -4
  10. package/cpp/webgpu/webgpu.h +47 -50
  11. package/cpp/webgpu/webgpu_cpp.h +151 -100
  12. package/lib/commonjs/Canvas.js.map +1 -1
  13. package/lib/commonjs/hooks.js +4 -4
  14. package/lib/commonjs/hooks.js.map +1 -1
  15. package/lib/module/Canvas.js.map +1 -1
  16. package/lib/module/hooks.js +4 -4
  17. package/lib/module/hooks.js.map +1 -1
  18. package/lib/typescript/eslint.config.d.mts +3 -0
  19. package/lib/typescript/eslint.config.d.mts.map +1 -0
  20. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  21. package/lib/typescript/src/__tests__/globalSetup.d.ts +0 -7
  22. package/lib/typescript/src/__tests__/globalSetup.d.ts.map +1 -1
  23. package/lib/typescript/src/__tests__/setup.d.ts +1 -0
  24. package/lib/typescript/src/__tests__/setup.d.ts.map +1 -1
  25. package/lib/typescript/src/hooks.d.ts.map +1 -1
  26. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  27. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  28. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  29. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  30. package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  31. package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  32. package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
  33. package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
  34. package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
  35. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +9 -9
  36. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  37. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  38. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
  39. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
  40. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
  41. package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
  42. package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  43. package/libs/dawn.json +39 -62
  44. package/package.json +14 -16
  45. package/src/Canvas.tsx +0 -1
  46. package/src/__tests__/GPU.spec.ts +3 -1
  47. package/src/__tests__/demos/Wireframe.spec.ts +2 -4
  48. package/src/__tests__/globalSetup.ts +0 -9
  49. package/src/__tests__/setup.ts +2 -2
  50. package/src/hooks.tsx +3 -2
@@ -43,6 +43,7 @@ namespace dawn::native::metal {
43
43
  // does have a global queue of graphics operations, but the command buffers are inserted there
44
44
  // when they are "scheduled". Submitting other operations before the command buffer is
45
45
  // scheduled could lead to races in who gets scheduled first and incorrect rendering.
46
+ // TODO(crbug.com/444702048): Remove after migrating Chromium to commands scheduled futures.
46
47
  DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
47
48
 
48
49
  #if defined(__OBJC__)
@@ -28,8 +28,22 @@
28
28
  #ifndef INCLUDE_DAWN_NATIVE_WEBGPUBACKEND_H_
29
29
  #define INCLUDE_DAWN_NATIVE_WEBGPUBACKEND_H_
30
30
 
31
+ #include <ostream>
32
+
31
33
  #include "dawn/native/DawnNative.h"
32
34
 
33
- namespace dawn::native::webgpu {} // namespace dawn::native::webgpu
35
+ namespace dawn::native::webgpu {
36
+
37
+ using CaptureStream = std::ostream;
38
+
39
+ // Starts a capture on the given device.
40
+ DAWN_NATIVE_EXPORT void StartCapture(WGPUDevice device,
41
+ CaptureStream& commandStream,
42
+ CaptureStream& contentStream);
43
+
44
+ // Ends a capture on the given device.
45
+ DAWN_NATIVE_EXPORT void EndCapture(WGPUDevice device);
46
+
47
+ } // namespace dawn::native::webgpu
34
48
 
35
49
  #endif // INCLUDE_DAWN_NATIVE_WEBGPUBACKEND_H_
@@ -785,6 +785,9 @@ namespace wgpu {
785
785
  break;
786
786
  case FeatureName::ChromiumExperimentalBindless:
787
787
  o << "FeatureName::ChromiumExperimentalBindless";
788
+ break;
789
+ case FeatureName::AdapterPropertiesWGPU:
790
+ o << "FeatureName::AdapterPropertiesWGPU";
788
791
  break;
789
792
  default:
790
793
  o << "FeatureName::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<FeatureName>::type>(value);
@@ -1514,6 +1517,12 @@ namespace wgpu {
1514
1517
  break;
1515
1518
  case SType::TexelBufferBindingLayout:
1516
1519
  o << "SType::TexelBufferBindingLayout";
1520
+ break;
1521
+ case SType::SharedTextureMemoryMetalEndAccessState:
1522
+ o << "SType::SharedTextureMemoryMetalEndAccessState";
1523
+ break;
1524
+ case SType::AdapterPropertiesWGPU:
1525
+ o << "SType::AdapterPropertiesWGPU";
1517
1526
  break;
1518
1527
  default:
1519
1528
  o << "SType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<SType>::type>(value);
@@ -151,10 +151,4 @@ std::shared_ptr<GPUAdapterInfo> GPUAdapter::getInfo() {
151
151
  return std::make_shared<GPUAdapterInfo>(info);
152
152
  }
153
153
 
154
- bool GPUAdapter::getIsFallbackAdapter() {
155
- wgpu::AdapterInfo adapterInfo = {};
156
- _instance.GetInfo(&adapterInfo);
157
- return adapterInfo.adapterType == wgpu::AdapterType::CPU;
158
- }
159
-
160
154
  } // namespace rnwgpu
@@ -37,7 +37,6 @@ public:
37
37
  std::unordered_set<std::string> getFeatures();
38
38
  std::shared_ptr<GPUSupportedLimits> getLimits();
39
39
  std::shared_ptr<GPUAdapterInfo> getInfo();
40
- bool getIsFallbackAdapter();
41
40
 
42
41
  void loadHybridMethods() override {
43
42
  registerHybridGetter("__brand", &GPUAdapter::getBrand, this);
@@ -45,8 +44,6 @@ public:
45
44
  registerHybridGetter("features", &GPUAdapter::getFeatures, this);
46
45
  registerHybridGetter("limits", &GPUAdapter::getLimits, this);
47
46
  registerHybridGetter("info", &GPUAdapter::getInfo, this);
48
- registerHybridGetter("isFallbackAdapter", &GPUAdapter::getIsFallbackAdapter,
49
- this);
50
47
  }
51
48
 
52
49
  inline const wgpu::Adapter get() { return _instance; }
@@ -21,7 +21,8 @@ public:
21
21
  explicit GPUAdapterInfo(wgpu::AdapterInfo &info)
22
22
  : HybridObject("GPUAdapterInfo"), _vendor(info.vendor),
23
23
  _architecture(info.architecture), _device(info.device),
24
- _description(info.description) {}
24
+ _description(info.description),
25
+ _isFallbackAdapter(info.adapterType == wgpu::AdapterType::CPU) {}
25
26
 
26
27
  public:
27
28
  std::string getBrand() { return _name; }
@@ -30,6 +31,7 @@ public:
30
31
  std::string getArchitecture() { return _architecture; }
31
32
  std::string getDevice() { return _device; }
32
33
  std::string getDescription() { return _description; }
34
+ bool getIsFallbackAdapter() { return _isFallbackAdapter; }
33
35
 
34
36
  void loadHybridMethods() override {
35
37
  registerHybridGetter("__brand", &GPUAdapterInfo::getBrand, this);
@@ -39,6 +41,8 @@ public:
39
41
  this);
40
42
  registerHybridGetter("device", &GPUAdapterInfo::getDevice, this);
41
43
  registerHybridGetter("description", &GPUAdapterInfo::getDescription, this);
44
+ registerHybridGetter("isFallbackAdapter",
45
+ &GPUAdapterInfo::getIsFallbackAdapter, this);
42
46
  }
43
47
 
44
48
  private:
@@ -46,6 +50,7 @@ private:
46
50
  std::string _architecture;
47
51
  std::string _device;
48
52
  std::string _description;
53
+ bool _isFallbackAdapter;
49
54
  };
50
55
 
51
56
  } // namespace rnwgpu
@@ -41,7 +41,7 @@ std::shared_ptr<GPURenderPassEncoder> GPUCommandEncoder::beginRenderPass(
41
41
  std::shared_ptr<GPURenderPassDescriptor> descriptor) {
42
42
 
43
43
  wgpu::RenderPassDescriptor desc{};
44
- wgpu::RenderPassDescriptorMaxDrawCount maxDrawCountDesc{};
44
+ wgpu::RenderPassMaxDrawCount maxDrawCountDesc{};
45
45
  desc.nextInChain = &maxDrawCountDesc;
46
46
  Convertor conv;
47
47
 
@@ -70,7 +70,7 @@ GPUDevice::createTexture(std::shared_ptr<GPUTextureDescriptor> descriptor) {
70
70
 
71
71
  std::shared_ptr<GPUShaderModule> GPUDevice::createShaderModule(
72
72
  std::shared_ptr<GPUShaderModuleDescriptor> descriptor) {
73
- wgpu::ShaderModuleWGSLDescriptor wgsl_desc{};
73
+ wgpu::ShaderSourceWGSL wgsl_desc{};
74
74
  wgpu::ShaderModuleDescriptor sm_desc{};
75
75
  Convertor conv;
76
76
  if (!conv(wgsl_desc.code, descriptor->code) ||
@@ -487,7 +487,7 @@ inline void convertJSUnionToEnum(const std::string &inUnion,
487
487
  *outEnum = wgpu::FeatureName::AdapterPropertiesVk;
488
488
  } else if (inUnion == "r8unorm-storage") {
489
489
  *outEnum = wgpu::FeatureName::R8UnormStorage;
490
- } else if (inUnion == "dawn-format-capabilities") {
490
+ } else if (inUnion == "format-capabilities") {
491
491
  *outEnum = wgpu::FeatureName::DawnFormatCapabilities;
492
492
  } else if (inUnion == "norm16-texture-formats") {
493
493
  *outEnum = wgpu::FeatureName::Norm16TextureFormats;
@@ -590,6 +590,9 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum,
590
590
  case wgpu::FeatureName::DawnNative:
591
591
  *outUnion = "dawn-native";
592
592
  break;
593
+ case wgpu::FeatureName::DawnFormatCapabilities:
594
+ *outUnion = "format-capabilities";
595
+ break;
593
596
  case wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses:
594
597
  *outUnion = "chromium-experimental-timestamp-query-inside-passes";
595
598
  break;
@@ -662,9 +665,6 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum,
662
665
  case wgpu::FeatureName::R8UnormStorage:
663
666
  *outUnion = "r8unorm-storage";
664
667
  break;
665
- case wgpu::FeatureName::DawnFormatCapabilities:
666
- *outUnion = "dawn-format-capabilities";
667
- break;
668
668
  case wgpu::FeatureName::Norm16TextureFormats:
669
669
  *outUnion = "norm16-texture-formats";
670
670
  break;
@@ -149,6 +149,7 @@ typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE;
149
149
  // Structure forward declarations
150
150
  struct WGPUAdapterPropertiesD3D;
151
151
  struct WGPUAdapterPropertiesVk;
152
+ struct WGPUAdapterPropertiesWGPU;
152
153
  struct WGPUBindGroupDynamicBindingArray;
153
154
  struct WGPUBlendComponent;
154
155
  struct WGPUBufferBindingLayout;
@@ -296,7 +297,7 @@ struct WGPUSharedFenceExportInfo;
296
297
  struct WGPUSharedTextureMemoryAHardwareBufferProperties;
297
298
  struct WGPUSharedTextureMemoryBeginAccessDescriptor;
298
299
  struct WGPUSharedTextureMemoryDmaBufDescriptor;
299
- struct WGPUSharedTextureMemoryEndAccessState;
300
+ struct WGPUSharedTextureMemoryMetalEndAccessState;
300
301
  struct WGPUSurfaceDescriptor;
301
302
  struct WGPUTexelCopyBufferInfo;
302
303
  struct WGPUTexelCopyTextureInfo;
@@ -314,6 +315,7 @@ struct WGPUDeviceDescriptor;
314
315
  struct WGPUPipelineLayoutDescriptor;
315
316
  struct WGPURenderPassPixelLocalStorage;
316
317
  struct WGPUSharedTextureMemoryDescriptor;
318
+ struct WGPUSharedTextureMemoryEndAccessState;
317
319
  struct WGPUSharedTextureMemoryProperties;
318
320
  struct WGPUTextureViewDescriptor;
319
321
  struct WGPUVertexState;
@@ -613,6 +615,7 @@ typedef enum WGPUFeatureName {
613
615
  WGPUFeatureName_DawnDeviceAllocatorControl = 0x00050039,
614
616
  WGPUFeatureName_TextureComponentSwizzle = 0x0005003A,
615
617
  WGPUFeatureName_ChromiumExperimentalBindless = 0x0005003C,
618
+ WGPUFeatureName_AdapterPropertiesWGPU = 0x0005003D,
616
619
  WGPUFeatureName_Force32 = 0x7FFFFFFF
617
620
  } WGPUFeatureName WGPU_ENUM_ATTRIBUTE;
618
621
 
@@ -896,6 +899,8 @@ typedef enum WGPUSType {
896
899
  WGPUSType_BindGroupDynamicBindingArray = 0x0005004C,
897
900
  WGPUSType_TexelBufferBindingEntry = 0x0005004D,
898
901
  WGPUSType_TexelBufferBindingLayout = 0x0005004E,
902
+ WGPUSType_SharedTextureMemoryMetalEndAccessState = 0x0005004F,
903
+ WGPUSType_AdapterPropertiesWGPU = 0x00050050,
899
904
  WGPUSType_Force32 = 0x7FFFFFFF
900
905
  } WGPUSType WGPU_ENUM_ATTRIBUTE;
901
906
 
@@ -1446,6 +1451,20 @@ typedef struct WGPUAdapterPropertiesVk {
1446
1451
  /*.driverVersion=*/0 _wgpu_COMMA \
1447
1452
  })
1448
1453
 
1454
+ // Can be chained in WGPUAdapterInfo
1455
+ typedef struct WGPUAdapterPropertiesWGPU {
1456
+ WGPUChainedStruct chain;
1457
+ WGPUBackendType backendType;
1458
+ } WGPUAdapterPropertiesWGPU WGPU_STRUCTURE_ATTRIBUTE;
1459
+
1460
+ #define WGPU_ADAPTER_PROPERTIES_WGPU_INIT _wgpu_MAKE_INIT_STRUCT(WGPUAdapterPropertiesWGPU, { \
1461
+ /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \
1462
+ /*.next=*/NULL _wgpu_COMMA \
1463
+ /*.sType=*/WGPUSType_AdapterPropertiesWGPU _wgpu_COMMA \
1464
+ }) _wgpu_COMMA \
1465
+ /*.backendType=*/WGPUBackendType_Undefined _wgpu_COMMA \
1466
+ })
1467
+
1449
1468
  // Can be chained in WGPUBindGroupDescriptor
1450
1469
  typedef struct WGPUBindGroupDynamicBindingArray {
1451
1470
  WGPUChainedStruct chain;
@@ -3724,20 +3743,18 @@ typedef struct WGPUSharedTextureMemoryDmaBufDescriptor {
3724
3743
  /*.planes=*/NULL _wgpu_COMMA \
3725
3744
  })
3726
3745
 
3727
- typedef struct WGPUSharedTextureMemoryEndAccessState {
3728
- WGPUChainedStruct * nextInChain;
3729
- WGPUBool initialized;
3730
- size_t fenceCount;
3731
- WGPUSharedFence const * fences;
3732
- uint64_t const * signaledValues;
3733
- } WGPUSharedTextureMemoryEndAccessState WGPU_STRUCTURE_ATTRIBUTE;
3746
+ // Can be chained in WGPUSharedTextureMemoryEndAccessState
3747
+ typedef struct WGPUSharedTextureMemoryMetalEndAccessState {
3748
+ WGPUChainedStruct chain;
3749
+ WGPUFuture commandsScheduledFuture;
3750
+ } WGPUSharedTextureMemoryMetalEndAccessState WGPU_STRUCTURE_ATTRIBUTE;
3734
3751
 
3735
- #define WGPU_SHARED_TEXTURE_MEMORY_END_ACCESS_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSharedTextureMemoryEndAccessState, { \
3736
- /*.nextInChain=*/NULL _wgpu_COMMA \
3737
- /*.initialized=*/WGPU_FALSE _wgpu_COMMA \
3738
- /*.fenceCount=*/0 _wgpu_COMMA \
3739
- /*.fences=*/NULL _wgpu_COMMA \
3740
- /*.signaledValues=*/NULL _wgpu_COMMA \
3752
+ #define WGPU_SHARED_TEXTURE_MEMORY_METAL_END_ACCESS_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSharedTextureMemoryMetalEndAccessState, { \
3753
+ /*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \
3754
+ /*.next=*/NULL _wgpu_COMMA \
3755
+ /*.sType=*/WGPUSType_SharedTextureMemoryMetalEndAccessState _wgpu_COMMA \
3756
+ }) _wgpu_COMMA \
3757
+ /*.commandsScheduledFuture=*/WGPU_FUTURE_INIT _wgpu_COMMA \
3741
3758
  })
3742
3759
 
3743
3760
  typedef struct WGPUSurfaceDescriptor {
@@ -4002,6 +4019,22 @@ typedef struct WGPUSharedTextureMemoryDescriptor {
4002
4019
  /*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \
4003
4020
  })
4004
4021
 
4022
+ typedef struct WGPUSharedTextureMemoryEndAccessState {
4023
+ WGPUChainedStruct * nextInChain;
4024
+ WGPUBool initialized;
4025
+ size_t fenceCount;
4026
+ WGPUSharedFence const * fences;
4027
+ uint64_t const * signaledValues;
4028
+ } WGPUSharedTextureMemoryEndAccessState WGPU_STRUCTURE_ATTRIBUTE;
4029
+
4030
+ #define WGPU_SHARED_TEXTURE_MEMORY_END_ACCESS_STATE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSharedTextureMemoryEndAccessState, { \
4031
+ /*.nextInChain=*/NULL _wgpu_COMMA \
4032
+ /*.initialized=*/WGPU_FALSE _wgpu_COMMA \
4033
+ /*.fenceCount=*/0 _wgpu_COMMA \
4034
+ /*.fences=*/NULL _wgpu_COMMA \
4035
+ /*.signaledValues=*/NULL _wgpu_COMMA \
4036
+ })
4037
+
4005
4038
  typedef struct WGPUSharedTextureMemoryProperties {
4006
4039
  WGPUChainedStruct * nextInChain;
4007
4040
  WGPUTextureUsage usage;
@@ -4124,42 +4157,6 @@ typedef struct WGPURenderPipelineDescriptor {
4124
4157
  /*.fragment=*/NULL _wgpu_COMMA \
4125
4158
  })
4126
4159
 
4127
- // WGPURenderPassDescriptorMaxDrawCount is deprecated.
4128
- // Use WGPURenderPassMaxDrawCount instead.
4129
- typedef WGPURenderPassMaxDrawCount WGPURenderPassDescriptorMaxDrawCount;
4130
-
4131
- // WGPUShaderModuleSPIRVDescriptor is deprecated.
4132
- // Use WGPUShaderSourceSPIRV instead.
4133
- typedef WGPUShaderSourceSPIRV WGPUShaderModuleSPIRVDescriptor;
4134
-
4135
- // WGPUShaderModuleWGSLDescriptor is deprecated.
4136
- // Use WGPUShaderSourceWGSL instead.
4137
- typedef WGPUShaderSourceWGSL WGPUShaderModuleWGSLDescriptor;
4138
-
4139
- // WGPUSurfaceDescriptorFromAndroidNativeWindow is deprecated.
4140
- // Use WGPUSurfaceSourceAndroidNativeWindow instead.
4141
- typedef WGPUSurfaceSourceAndroidNativeWindow WGPUSurfaceDescriptorFromAndroidNativeWindow;
4142
-
4143
- // WGPUSurfaceDescriptorFromMetalLayer is deprecated.
4144
- // Use WGPUSurfaceSourceMetalLayer instead.
4145
- typedef WGPUSurfaceSourceMetalLayer WGPUSurfaceDescriptorFromMetalLayer;
4146
-
4147
- // WGPUSurfaceDescriptorFromWaylandSurface is deprecated.
4148
- // Use WGPUSurfaceSourceWaylandSurface instead.
4149
- typedef WGPUSurfaceSourceWaylandSurface WGPUSurfaceDescriptorFromWaylandSurface;
4150
-
4151
- // WGPUSurfaceDescriptorFromWindowsHWND is deprecated.
4152
- // Use WGPUSurfaceSourceWindowsHWND instead.
4153
- typedef WGPUSurfaceSourceWindowsHWND WGPUSurfaceDescriptorFromWindowsHWND;
4154
-
4155
- // WGPUSurfaceDescriptorFromXcbWindow is deprecated.
4156
- // Use WGPUSurfaceSourceXCBWindow instead.
4157
- typedef WGPUSurfaceSourceXCBWindow WGPUSurfaceDescriptorFromXcbWindow;
4158
-
4159
- // WGPUSurfaceDescriptorFromXlibWindow is deprecated.
4160
- // Use WGPUSurfaceSourceXlibWindow instead.
4161
- typedef WGPUSurfaceSourceXlibWindow WGPUSurfaceDescriptorFromXlibWindow;
4162
-
4163
4160
  #ifdef __cplusplus
4164
4161
  extern "C" {
4165
4162
  #endif