react-native-webgpu 0.6.2 → 0.6.4

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.
@@ -179,6 +179,9 @@ public:
179
179
  result.height = static_cast<int>(bitmapInfo.height);
180
180
  result.data.resize(bitmapInfo.height * bitmapInfo.stride);
181
181
  memcpy(result.data.data(), bitmapPixels, result.data.size());
182
+ // BitmapFactory hands back premultiplied ARGB_8888 pixels; createImageBitmap
183
+ // converts to the representation requested by premultiplyAlpha.
184
+ result.premultiplied = true;
182
185
 
183
186
  AndroidBitmap_unlockPixels(env, bitmap);
184
187
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  #import <AVFoundation/AVFoundation.h>
6
6
  #import <CoreVideo/CoreVideo.h>
7
+ #import <ImageIO/ImageIO.h>
7
8
  #import <React/RCTBlobManager.h>
8
9
  #import <React/RCTBridge+Private.h>
9
10
  #import <ReactCommon/RCTTurboModule.h>
@@ -88,36 +89,32 @@ void ApplePlatformContext::createImageBitmapAsync(
88
89
 
89
90
  ImageData
90
91
  ApplePlatformContext::createImageBitmapFromData(std::span<const uint8_t> data) {
91
- // This avoids a copy by assuming the UIImage/NSImage constructors
92
- // decode `nsData` eagerly before the memory for the wrapped `data`
93
- // is freed.
94
- //
95
- // Since we get the `CGImageRef` from `image` and then throw
96
- // it away, that's a fairly safe assumption.
92
+ // All formats are decoded through ImageIO. Apple's imaging stack always
93
+ // premultiplies alpha at decode, so the result is flagged premultiplied and
94
+ // createImageBitmap / copyExternalImageToTexture convert from there. This
95
+ // means premultiplyAlpha "none" is a lossy round trip for low-alpha pixels
96
+ // (as it is on Android); the snapshot suites compare with pixelmatch
97
+ // tolerance to absorb it.
97
98
  NSData *nsData =
98
99
  [NSData dataWithBytesNoCopy:const_cast<uint8_t *>(data.data())
99
100
  length:data.size()
100
101
  freeWhenDone:NO];
101
102
 
102
- #if !TARGET_OS_OSX
103
- UIImage *image = [UIImage imageWithData:nsData];
104
- #else
105
- NSImage *image = [[NSImage alloc] initWithData:nsData];
106
- #endif
107
- if (!image) {
103
+ CGImageSourceRef imageSource =
104
+ CGImageSourceCreateWithData((__bridge CFDataRef)nsData, NULL);
105
+ if (imageSource == NULL) {
106
+ throw std::runtime_error("Couldn't create image source");
107
+ }
108
+ NSDictionary *decodeOptions = @{(id)kCGImageSourceShouldCache : @NO};
109
+ CGImageRef cgImage = CGImageSourceCreateImageAtIndex(
110
+ imageSource, 0, (__bridge CFDictionaryRef)decodeOptions);
111
+ CFRelease(imageSource);
112
+ if (cgImage == NULL) {
108
113
  throw std::runtime_error("Couldn't decode image");
109
114
  }
110
115
 
111
- #if !TARGET_OS_OSX
112
- CGImageRef cgImage = image.CGImage;
113
- #else
114
- CGImageRef cgImage = [image CGImageForProposedRect:NULL
115
- context:NULL
116
- hints:NULL];
117
- #endif
118
116
  size_t width = CGImageGetWidth(cgImage);
119
117
  size_t height = CGImageGetHeight(cgImage);
120
- size_t bitsPerComponent = 8;
121
118
  size_t bytesPerRow = width * 4;
122
119
 
123
120
  ImageData result;
@@ -126,16 +123,18 @@ ApplePlatformContext::createImageBitmapFromData(std::span<const uint8_t> data) {
126
123
  result.data.resize(height * bytesPerRow);
127
124
  result.format = wgpu::TextureFormat::RGBA8Unorm;
128
125
 
126
+ // The draw premultiplies alpha; flag the result premultiplied so
127
+ // createImageBitmap and copyExternalImageToTexture convert consistently.
129
128
  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
130
129
  CGContextRef context = CGBitmapContextCreate(
131
- result.data.data(), width, height, bitsPerComponent, bytesPerRow,
132
- colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
133
-
130
+ result.data.data(), width, height, 8, bytesPerRow, colorSpace,
131
+ kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
134
132
  CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
135
-
136
133
  CGContextRelease(context);
137
134
  CGColorSpaceRelease(colorSpace);
135
+ CGImageRelease(cgImage);
138
136
 
137
+ result.premultiplied = true;
139
138
  return result;
140
139
  }
141
140
 
@@ -16,6 +16,13 @@ struct ImageData {
16
16
  size_t width;
17
17
  size_t height;
18
18
  wgpu::TextureFormat format;
19
+ // Whether the RGB channels are premultiplied by alpha. Each platform decoder
20
+ // records the representation it produced; createImageBitmap then converts to
21
+ // the representation requested through premultiplyAlpha, and
22
+ // copyExternalImageToTexture converts again to match the destination's
23
+ // premultipliedAlpha. Defaults to true because most native decoders
24
+ // (CoreGraphics, Android Bitmap) hand back premultiplied pixels.
25
+ bool premultiplied = true;
19
26
  };
20
27
 
21
28
  // Pixel layout of a VideoFrame. Determines whether the underlying surface is
@@ -128,26 +128,40 @@ void GPUQueue::copyExternalImageToTexture(
128
128
  throw std::runtime_error("Invalid input for GPUQueue::writeTexture()");
129
129
  }
130
130
 
131
- if (source->flipY.value_or(false)) {
132
- // Calculate the row size and total size
131
+ const bool flipY = source->flipY.value_or(false);
132
+ // premultipliedAlpha defaults to false per the WebGPU spec: an untagged
133
+ // destination expects straight alpha. Convert only when the ImageBitmap's
134
+ // representation differs, using the same rounding as the reference client.
135
+ const bool sourcePremultiplied = source->source->getPremultiplied();
136
+ const bool destinationPremultiplied =
137
+ destination->premultipliedAlpha.value_or(false);
138
+ const bool needsAlphaConversion =
139
+ bytesPerPixel == 4 && sourcePremultiplied != destinationPremultiplied;
140
+
141
+ if (flipY || needsAlphaConversion) {
133
142
  uint32_t rowSize = bytesPerPixel * source->source->getWidth();
134
143
  uint32_t totalSize = source->source->getSize();
135
144
 
136
- // Create a new buffer for the flipped data
137
- std::vector<uint8_t> flippedData(totalSize);
138
-
139
- // Flip the data vertically
140
- for (uint32_t row = 0; row < source->source->getHeight(); ++row) {
141
- std::memcpy(flippedData.data() +
142
- (source->source->getHeight() - 1 - row) * rowSize,
143
- static_cast<const uint8_t *>(source->source->getData()) +
144
- row * rowSize,
145
- rowSize);
145
+ // Stage a mutable copy so flipping and/or alpha conversion never touch the
146
+ // ImageBitmap's backing store.
147
+ std::vector<uint8_t> staged(totalSize);
148
+ const uint8_t *src =
149
+ static_cast<const uint8_t *>(source->source->getData());
150
+ if (flipY) {
151
+ for (uint32_t row = 0; row < source->source->getHeight(); ++row) {
152
+ std::memcpy(staged.data() +
153
+ (source->source->getHeight() - 1 - row) * rowSize,
154
+ src + row * rowSize, rowSize);
155
+ }
156
+ } else {
157
+ std::memcpy(staged.data(), src, totalSize);
158
+ }
159
+ if (needsAlphaConversion) {
160
+ convertAlpha(staged.data(), totalSize, sourcePremultiplied,
161
+ destinationPremultiplied);
146
162
  }
147
- // Use the flipped data for writing to texture
148
- _instance.WriteTexture(&dst, flippedData.data(), totalSize, &layout, &sz);
163
+ _instance.WriteTexture(&dst, staged.data(), totalSize, &layout, &sz);
149
164
  } else {
150
-
151
165
  _instance.WriteTexture(&dst, source->source->getData(),
152
166
  source->source->getSize(), &layout, &sz);
153
167
  }
@@ -11,6 +11,33 @@ namespace rnwgpu {
11
11
 
12
12
  namespace jsi = facebook::jsi;
13
13
 
14
+ // Convert RGBA8 pixel data in place between straight and premultiplied alpha.
15
+ // Uses the same integer rounding as the web reference polyfill in the test
16
+ // harness (setup.ts, convertAlpha) so the native result is bit-exact with the
17
+ // dawn.node client. A no-op when the source and destination representations
18
+ // already match.
19
+ inline void convertAlpha(uint8_t *data, size_t byteLength,
20
+ bool sourcePremultiplied,
21
+ bool destinationPremultiplied) {
22
+ if (sourcePremultiplied == destinationPremultiplied) {
23
+ return;
24
+ }
25
+ for (size_t i = 0; i + 3 < byteLength; i += 4) {
26
+ const uint32_t alpha = data[i + 3];
27
+ for (size_t channel = 0; channel < 3; channel++) {
28
+ const uint32_t value = data[i + channel];
29
+ if (destinationPremultiplied) {
30
+ data[i + channel] = static_cast<uint8_t>((value * alpha + 127) / 255);
31
+ } else if (alpha == 0) {
32
+ data[i + channel] = 0;
33
+ } else {
34
+ const uint32_t straight = (value * 255 + (alpha >> 1)) / alpha;
35
+ data[i + channel] = static_cast<uint8_t>(straight > 255 ? 255 : straight);
36
+ }
37
+ }
38
+ }
39
+ }
40
+
14
41
  class ImageBitmap : public NativeObject<ImageBitmap> {
15
42
  public:
16
43
  static constexpr const char *CLASS_NAME = "ImageBitmap";
@@ -26,6 +53,11 @@ public:
26
53
 
27
54
  size_t getSize() { return _imageData.data.size(); }
28
55
 
56
+ // Whether the stored pixels are premultiplied by alpha. Used by
57
+ // copyExternalImageToTexture to decide whether a conversion to the
58
+ // destination's premultipliedAlpha representation is needed.
59
+ bool getPremultiplied() { return _imageData.premultiplied; }
60
+
29
61
  void close() {
30
62
  _imageData.data.clear();
31
63
  _imageData.data.shrink_to_fit();
@@ -90,6 +90,41 @@ public:
90
90
  auto platformContext = _platformContext;
91
91
  auto callInvoker = _callInvoker;
92
92
 
93
+ // Resolve the requested alpha representation from the ImageBitmapOptions.
94
+ // The options bag is the second argument for createImageBitmap(source,
95
+ // options) and the sixth for the crop-rect overload createImageBitmap(
96
+ // source, sx, sy, sw, sh, options). premultiplyAlpha defaults to
97
+ // "default", which (like "premultiply") stores premultiplied pixels; only
98
+ // "none" keeps straight alpha. The other options (crop rect, resize,
99
+ // imageOrientation, colorSpaceConversion) are not yet implemented natively.
100
+ bool wantPremultiplied = true;
101
+ const jsi::Value *optionsArg = nullptr;
102
+ if (count >= 2 && args[1].isObject()) {
103
+ optionsArg = &args[1];
104
+ } else if (count >= 6 && args[5].isObject()) {
105
+ optionsArg = &args[5];
106
+ }
107
+ if (optionsArg != nullptr) {
108
+ auto options = optionsArg->getObject(runtime);
109
+ if (options.hasProperty(runtime, "premultiplyAlpha")) {
110
+ auto value = options.getProperty(runtime, "premultiplyAlpha");
111
+ if (value.isString() &&
112
+ value.getString(runtime).utf8(runtime) == "none") {
113
+ wantPremultiplied = false;
114
+ }
115
+ }
116
+ }
117
+
118
+ // Bring the decoded pixels into the representation requested via
119
+ // premultiplyAlpha before wrapping them in an ImageBitmap.
120
+ auto toRequestedAlpha = [wantPremultiplied](ImageData &imageData) {
121
+ if (imageData.premultiplied != wantPremultiplied) {
122
+ convertAlpha(imageData.data.data(), imageData.data.size(),
123
+ imageData.premultiplied, wantPremultiplied);
124
+ imageData.premultiplied = wantPremultiplied;
125
+ }
126
+ };
127
+
93
128
  // Check if the argument is an ArrayBuffer or ArrayBufferView
94
129
  // (TypedArray / DataView). Only a real buffer source is run through the
95
130
  // ArrayBuffer converter, which validates byteOffset/byteLength against the
@@ -119,12 +154,14 @@ public:
119
154
 
120
155
  return Promise::createPromise(
121
156
  runtime,
122
- [platformContext, callInvoker, dataCopy = std::move(dataCopy)](
157
+ [platformContext, callInvoker, toRequestedAlpha,
158
+ dataCopy = std::move(dataCopy)](
123
159
  jsi::Runtime & /*runtime*/,
124
160
  std::shared_ptr<Promise> promise) mutable {
125
161
  platformContext->createImageBitmapFromDataAsync(
126
162
  dataCopy,
127
- [callInvoker, promise](ImageData imageData) {
163
+ [callInvoker, promise, toRequestedAlpha](ImageData imageData) {
164
+ toRequestedAlpha(imageData);
128
165
  auto imageBitmap = std::make_shared<ImageBitmap>(imageData);
129
166
  callInvoker->invokeAsync([promise, imageBitmap]() {
130
167
  promise->resolve(
@@ -149,11 +186,12 @@ public:
149
186
 
150
187
  return Promise::createPromise(
151
188
  runtime,
152
- [platformContext, callInvoker, blobId, offset,
189
+ [platformContext, callInvoker, toRequestedAlpha, blobId, offset,
153
190
  size](jsi::Runtime & /*runtime*/, std::shared_ptr<Promise> promise) {
154
191
  platformContext->createImageBitmapAsync(
155
192
  blobId, offset, size,
156
- [callInvoker, promise](ImageData imageData) {
193
+ [callInvoker, promise, toRequestedAlpha](ImageData imageData) {
194
+ toRequestedAlpha(imageData);
157
195
  auto imageBitmap = std::make_shared<ImageBitmap>(imageData);
158
196
  callInvoker->invokeAsync([promise, imageBitmap]() {
159
197
  promise->resolve(
@@ -2409,6 +2409,7 @@ typedef struct WGPUSharedBufferMemoryBeginAccessDescriptor {
2409
2409
  WGPUBool initialized;
2410
2410
  size_t fenceCount;
2411
2411
  WGPUSharedFence const * fences;
2412
+ size_t signaledValueCount;
2412
2413
  uint64_t const * signaledValues;
2413
2414
  } WGPUSharedBufferMemoryBeginAccessDescriptor WGPU_STRUCTURE_ATTRIBUTE;
2414
2415
 
@@ -2417,6 +2418,7 @@ typedef struct WGPUSharedBufferMemoryBeginAccessDescriptor {
2417
2418
  /*.initialized=*/WGPU_FALSE _wgpu_COMMA \
2418
2419
  /*.fenceCount=*/0 _wgpu_COMMA \
2419
2420
  /*.fences=*/NULL _wgpu_COMMA \
2421
+ /*.signaledValueCount=*/0 _wgpu_COMMA \
2420
2422
  /*.signaledValues=*/NULL _wgpu_COMMA \
2421
2423
  })
2422
2424
 
@@ -2441,6 +2443,7 @@ typedef struct WGPUSharedBufferMemoryEndAccessState {
2441
2443
  WGPUBool initialized;
2442
2444
  size_t fenceCount;
2443
2445
  WGPUSharedFence const * fences;
2446
+ size_t signaledValueCount;
2444
2447
  uint64_t const * signaledValues;
2445
2448
  } WGPUSharedBufferMemoryEndAccessState WGPU_STRUCTURE_ATTRIBUTE;
2446
2449
 
@@ -2449,6 +2452,7 @@ typedef struct WGPUSharedBufferMemoryEndAccessState {
2449
2452
  /*.initialized=*/WGPU_FALSE _wgpu_COMMA \
2450
2453
  /*.fenceCount=*/0 _wgpu_COMMA \
2451
2454
  /*.fences=*/NULL _wgpu_COMMA \
2455
+ /*.signaledValueCount=*/0 _wgpu_COMMA \
2452
2456
  /*.signaledValues=*/NULL _wgpu_COMMA \
2453
2457
  })
2454
2458
 
@@ -3801,6 +3805,7 @@ typedef struct WGPUSharedTextureMemoryBeginAccessDescriptor {
3801
3805
  WGPUBool initialized;
3802
3806
  size_t fenceCount;
3803
3807
  WGPUSharedFence const * fences;
3808
+ size_t signaledValueCount;
3804
3809
  uint64_t const * signaledValues;
3805
3810
  } WGPUSharedTextureMemoryBeginAccessDescriptor WGPU_STRUCTURE_ATTRIBUTE;
3806
3811
 
@@ -3810,6 +3815,7 @@ typedef struct WGPUSharedTextureMemoryBeginAccessDescriptor {
3810
3815
  /*.initialized=*/WGPU_FALSE _wgpu_COMMA \
3811
3816
  /*.fenceCount=*/0 _wgpu_COMMA \
3812
3817
  /*.fences=*/NULL _wgpu_COMMA \
3818
+ /*.signaledValueCount=*/0 _wgpu_COMMA \
3813
3819
  /*.signaledValues=*/NULL _wgpu_COMMA \
3814
3820
  })
3815
3821
 
@@ -4116,6 +4122,7 @@ typedef struct WGPUSharedTextureMemoryEndAccessState {
4116
4122
  WGPUBool initialized;
4117
4123
  size_t fenceCount;
4118
4124
  WGPUSharedFence const * fences;
4125
+ size_t signaledValueCount;
4119
4126
  uint64_t const * signaledValues;
4120
4127
  } WGPUSharedTextureMemoryEndAccessState WGPU_STRUCTURE_ATTRIBUTE;
4121
4128
 
@@ -4124,6 +4131,7 @@ typedef struct WGPUSharedTextureMemoryEndAccessState {
4124
4131
  /*.initialized=*/WGPU_FALSE _wgpu_COMMA \
4125
4132
  /*.fenceCount=*/0 _wgpu_COMMA \
4126
4133
  /*.fences=*/NULL _wgpu_COMMA \
4134
+ /*.signaledValueCount=*/0 _wgpu_COMMA \
4127
4135
  /*.signaledValues=*/NULL _wgpu_COMMA \
4128
4136
  })
4129
4137
 
@@ -2887,6 +2887,7 @@ struct SharedBufferMemoryBeginAccessDescriptor {
2887
2887
  Bool initialized;
2888
2888
  size_t fenceCount = 0;
2889
2889
  SharedFence const * fences = nullptr;
2890
+ size_t signaledValueCount = 0;
2890
2891
  uint64_t const * signaledValues = nullptr;
2891
2892
  };
2892
2893
 
@@ -2915,6 +2916,7 @@ struct SharedBufferMemoryEndAccessState {
2915
2916
  Bool const initialized = {};
2916
2917
  size_t const fenceCount = 0;
2917
2918
  SharedFence const * const fences = nullptr;
2919
+ size_t const signaledValueCount = 0;
2918
2920
  uint64_t const * const signaledValues = nullptr;
2919
2921
 
2920
2922
  private:
@@ -3923,6 +3925,7 @@ struct SharedTextureMemoryBeginAccessDescriptor {
3923
3925
  Bool initialized;
3924
3926
  size_t fenceCount;
3925
3927
  SharedFence const * fences = nullptr;
3928
+ size_t signaledValueCount = 0;
3926
3929
  uint64_t const * signaledValues = nullptr;
3927
3930
  };
3928
3931
 
@@ -4166,6 +4169,7 @@ struct SharedTextureMemoryEndAccessState {
4166
4169
  Bool const initialized = {};
4167
4170
  size_t const fenceCount = {};
4168
4171
  SharedFence const * const fences = nullptr;
4172
+ size_t const signaledValueCount = 0;
4169
4173
  uint64_t const * const signaledValues = nullptr;
4170
4174
 
4171
4175
  private:
@@ -4271,7 +4275,7 @@ struct CppFTraitsImpl<CppFT, R(*)(CppArgs...), T> {
4271
4275
  static constexpr bool capturing = false;
4272
4276
 
4273
4277
  static constexpr size_t NumCppArgs = sizeof...(CppArgs);
4274
- using BaseArgsTuple = decltype([]<std::size_t... Is>(std::index_sequence<Is...>) {
4278
+ using BaseArgsTuple = typename decltype([]<std::size_t... Is>(std::index_sequence<Is...>) {
4275
4279
  return std::type_identity<std::tuple<std::tuple_element_t<Is, std::tuple<CppArgs...>>...>>{};
4276
4280
  }(std::make_index_sequence<std::is_same_v<T, Untyped> ? NumCppArgs : NumCppArgs - 1>{})
4277
4281
  )::type;
@@ -4283,7 +4287,7 @@ struct CppFTraitsImpl<CppFT, R(C::*)(CppArgs...) const, T> {
4283
4287
  static constexpr bool capturing = !std::is_convertible_v<CppFT, PtrT>;
4284
4288
 
4285
4289
  static constexpr size_t NumCppArgs = sizeof...(CppArgs);
4286
- using BaseArgsTuple = decltype([]<std::size_t... Is>(std::index_sequence<Is...>) {
4290
+ using BaseArgsTuple = typename decltype([]<std::size_t... Is>(std::index_sequence<Is...>) {
4287
4291
  return std::type_identity<std::tuple<std::tuple_element_t<Is, std::tuple<CppArgs...>>...>>{};
4288
4292
  }(std::make_index_sequence<std::is_same_v<T, Untyped> ? NumCppArgs : NumCppArgs - 1>{})
4289
4293
  )::type;
@@ -4487,8 +4491,11 @@ struct CallbackInfoHelper {
4487
4491
  std::unique_ptr<F> alloc = std::make_unique<F>(std::move(lambda));
4488
4492
  info.userdata1 = reinterpret_cast<void*>(alloc.release());
4489
4493
  } else {
4494
+ // MSVC <=19.39 doesn't support static_assert(false) and this was fixed in later C++
4495
+ // standards https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2593r1.html
4496
+ constexpr bool kAlwaysFalse = sizeof(F) == 0;
4490
4497
  static_assert(
4491
- false, "capturing lambdas aren't supported for repeatable callbacks"
4498
+ kAlwaysFalse, "capturing lambdas aren't supported for repeatable callbacks"
4492
4499
  );
4493
4500
  }
4494
4501
  } else {
@@ -5816,6 +5823,8 @@ static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, fenceCount) == o
5816
5823
  "offsetof mismatch for SharedBufferMemoryBeginAccessDescriptor::fenceCount");
5817
5824
  static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, fences) == offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, fences),
5818
5825
  "offsetof mismatch for SharedBufferMemoryBeginAccessDescriptor::fences");
5826
+ static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, signaledValueCount) == offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, signaledValueCount),
5827
+ "offsetof mismatch for SharedBufferMemoryBeginAccessDescriptor::signaledValueCount");
5819
5828
  static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, signaledValues) == offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, signaledValues),
5820
5829
  "offsetof mismatch for SharedBufferMemoryBeginAccessDescriptor::signaledValues");
5821
5830
 
@@ -5853,6 +5862,7 @@ SharedBufferMemoryEndAccessState::SharedBufferMemoryEndAccessState(SharedBufferM
5853
5862
  : initialized(rhs.initialized),
5854
5863
  fenceCount(rhs.fenceCount),
5855
5864
  fences(rhs.fences),
5865
+ signaledValueCount(rhs.signaledValueCount),
5856
5866
  signaledValues(rhs.signaledValues){
5857
5867
  Reset(rhs);
5858
5868
  }
@@ -5865,6 +5875,7 @@ SharedBufferMemoryEndAccessState& SharedBufferMemoryEndAccessState::operator=(Sh
5865
5875
  detail::AsNonConstReference(this->initialized) = std::move(rhs.initialized);
5866
5876
  detail::AsNonConstReference(this->fenceCount) = std::move(rhs.fenceCount);
5867
5877
  detail::AsNonConstReference(this->fences) = std::move(rhs.fences);
5878
+ detail::AsNonConstReference(this->signaledValueCount) = std::move(rhs.signaledValueCount);
5868
5879
  detail::AsNonConstReference(this->signaledValues) = std::move(rhs.signaledValues);
5869
5880
  Reset(rhs);
5870
5881
  return *this;
@@ -5883,6 +5894,7 @@ void SharedBufferMemoryEndAccessState::Reset(SharedBufferMemoryEndAccessState& v
5883
5894
  detail::AsNonConstReference(value.initialized) = defaultValue.initialized;
5884
5895
  detail::AsNonConstReference(value.fenceCount) = defaultValue.fenceCount;
5885
5896
  detail::AsNonConstReference(value.fences) = defaultValue.fences;
5897
+ detail::AsNonConstReference(value.signaledValueCount) = defaultValue.signaledValueCount;
5886
5898
  detail::AsNonConstReference(value.signaledValues) = defaultValue.signaledValues;
5887
5899
  }
5888
5900
 
@@ -5900,6 +5912,8 @@ static_assert(offsetof(SharedBufferMemoryEndAccessState, fenceCount) == offsetof
5900
5912
  "offsetof mismatch for SharedBufferMemoryEndAccessState::fenceCount");
5901
5913
  static_assert(offsetof(SharedBufferMemoryEndAccessState, fences) == offsetof(WGPUSharedBufferMemoryEndAccessState, fences),
5902
5914
  "offsetof mismatch for SharedBufferMemoryEndAccessState::fences");
5915
+ static_assert(offsetof(SharedBufferMemoryEndAccessState, signaledValueCount) == offsetof(WGPUSharedBufferMemoryEndAccessState, signaledValueCount),
5916
+ "offsetof mismatch for SharedBufferMemoryEndAccessState::signaledValueCount");
5903
5917
  static_assert(offsetof(SharedBufferMemoryEndAccessState, signaledValues) == offsetof(WGPUSharedBufferMemoryEndAccessState, signaledValues),
5904
5918
  "offsetof mismatch for SharedBufferMemoryEndAccessState::signaledValues");
5905
5919
 
@@ -7967,6 +7981,8 @@ static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, fenceCount) ==
7967
7981
  "offsetof mismatch for SharedTextureMemoryBeginAccessDescriptor::fenceCount");
7968
7982
  static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, fences) == offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, fences),
7969
7983
  "offsetof mismatch for SharedTextureMemoryBeginAccessDescriptor::fences");
7984
+ static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, signaledValueCount) == offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, signaledValueCount),
7985
+ "offsetof mismatch for SharedTextureMemoryBeginAccessDescriptor::signaledValueCount");
7970
7986
  static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, signaledValues) == offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, signaledValues),
7971
7987
  "offsetof mismatch for SharedTextureMemoryBeginAccessDescriptor::signaledValues");
7972
7988
 
@@ -8460,6 +8476,7 @@ SharedTextureMemoryEndAccessState::SharedTextureMemoryEndAccessState(SharedTextu
8460
8476
  : initialized(rhs.initialized),
8461
8477
  fenceCount(rhs.fenceCount),
8462
8478
  fences(rhs.fences),
8479
+ signaledValueCount(rhs.signaledValueCount),
8463
8480
  signaledValues(rhs.signaledValues){
8464
8481
  Reset(rhs);
8465
8482
  }
@@ -8472,6 +8489,7 @@ SharedTextureMemoryEndAccessState& SharedTextureMemoryEndAccessState::operator=(
8472
8489
  detail::AsNonConstReference(this->initialized) = std::move(rhs.initialized);
8473
8490
  detail::AsNonConstReference(this->fenceCount) = std::move(rhs.fenceCount);
8474
8491
  detail::AsNonConstReference(this->fences) = std::move(rhs.fences);
8492
+ detail::AsNonConstReference(this->signaledValueCount) = std::move(rhs.signaledValueCount);
8475
8493
  detail::AsNonConstReference(this->signaledValues) = std::move(rhs.signaledValues);
8476
8494
  Reset(rhs);
8477
8495
  return *this;
@@ -8490,6 +8508,7 @@ void SharedTextureMemoryEndAccessState::Reset(SharedTextureMemoryEndAccessState&
8490
8508
  detail::AsNonConstReference(value.initialized) = defaultValue.initialized;
8491
8509
  detail::AsNonConstReference(value.fenceCount) = defaultValue.fenceCount;
8492
8510
  detail::AsNonConstReference(value.fences) = defaultValue.fences;
8511
+ detail::AsNonConstReference(value.signaledValueCount) = defaultValue.signaledValueCount;
8493
8512
  detail::AsNonConstReference(value.signaledValues) = defaultValue.signaledValues;
8494
8513
  }
8495
8514
 
@@ -8507,6 +8526,8 @@ static_assert(offsetof(SharedTextureMemoryEndAccessState, fenceCount) == offseto
8507
8526
  "offsetof mismatch for SharedTextureMemoryEndAccessState::fenceCount");
8508
8527
  static_assert(offsetof(SharedTextureMemoryEndAccessState, fences) == offsetof(WGPUSharedTextureMemoryEndAccessState, fences),
8509
8528
  "offsetof mismatch for SharedTextureMemoryEndAccessState::fences");
8529
+ static_assert(offsetof(SharedTextureMemoryEndAccessState, signaledValueCount) == offsetof(WGPUSharedTextureMemoryEndAccessState, signaledValueCount),
8530
+ "offsetof mismatch for SharedTextureMemoryEndAccessState::signaledValueCount");
8510
8531
  static_assert(offsetof(SharedTextureMemoryEndAccessState, signaledValues) == offsetof(WGPUSharedTextureMemoryEndAccessState, signaledValues),
8511
8532
  "offsetof mismatch for SharedTextureMemoryEndAccessState::signaledValues");
8512
8533
 
@@ -37,6 +37,6 @@ declare global {
37
37
  destroy(): void;
38
38
  readonly yuvToRgbMatrix: number[];
39
39
  }
40
- function createImageBitmap(image: ArrayBuffer | ArrayBufferView): Promise<ImageBitmap>;
40
+ function createImageBitmap(image: ArrayBuffer | ArrayBufferView, options?: ImageBitmapOptions): Promise<ImageBitmap>;
41
41
  }
42
42
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,gCAAgC,EAChC,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,SAAS,CAAC;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SAAS,iBAAiB,CACxB,KAAK,EAAE,WAAW,GAAG,eAAe,EACpC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB"}
Binary file
@@ -8,7 +8,7 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>libwebgpu_dawn.a</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>macos-arm64_x86_64</string>
11
+ <string>ios-arm64_x86_64-simulator</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>libwebgpu_dawn.a</string>
14
14
  <key>SupportedArchitectures</key>
@@ -17,7 +17,9 @@
17
17
  <string>x86_64</string>
18
18
  </array>
19
19
  <key>SupportedPlatform</key>
20
- <string>macos</string>
20
+ <string>ios</string>
21
+ <key>SupportedPlatformVariant</key>
22
+ <string>simulator</string>
21
23
  </dict>
22
24
  <dict>
23
25
  <key>BinaryPath</key>
@@ -37,7 +39,7 @@
37
39
  <key>BinaryPath</key>
38
40
  <string>libwebgpu_dawn.a</string>
39
41
  <key>LibraryIdentifier</key>
40
- <string>ios-arm64_x86_64-simulator</string>
42
+ <string>macos-arm64_x86_64</string>
41
43
  <key>LibraryPath</key>
42
44
  <string>libwebgpu_dawn.a</string>
43
45
  <key>SupportedArchitectures</key>
@@ -46,9 +48,7 @@
46
48
  <string>x86_64</string>
47
49
  </array>
48
50
  <key>SupportedPlatform</key>
49
- <string>ios</string>
50
- <key>SupportedPlatformVariant</key>
51
- <string>simulator</string>
51
+ <string>macos</string>
52
52
  </dict>
53
53
  </array>
54
54
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webgpu",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "React Native WebGPU",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -22,7 +22,8 @@
22
22
  "app.plugin.js",
23
23
  "plugin/build/**"
24
24
  ],
25
- "dawn": "chromium/7849",
25
+ "dawn": "chrome-m150",
26
+ "dawnCommit": "63f25feec51e9351fb25222b6d5de1af791d7c4f",
26
27
  "scripts": {
27
28
  "test": "NODE_OPTIONS='--experimental-require-module' jest -i",
28
29
  "test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i",
@@ -23,7 +23,8 @@ Pod::Spec.new do |s|
23
23
 
24
24
  # The VideoPlayer API uses AVFoundation / CoreMedia, and shared-texture
25
25
  # surfaces use CoreVideo (CVPixelBuffer). Link them so their symbols resolve.
26
- s.frameworks = "AVFoundation", "CoreMedia", "CoreVideo"
26
+ # ImageIO provides CGImageSource, the image decoder behind createImageBitmap.
27
+ s.frameworks = "AVFoundation", "CoreMedia", "CoreVideo", "ImageIO"
27
28
 
28
29
  s.pod_target_xcconfig = {
29
30
  'HEADER_SEARCH_PATHS' => '$(PODS_TARGET_SRCROOT)/cpp',
package/src/index.tsx CHANGED
@@ -110,5 +110,6 @@ declare global {
110
110
  // Extend createImageBitmap to accept ArrayBuffer/TypedArray (encoded image bytes)
111
111
  function createImageBitmap(
112
112
  image: ArrayBuffer | ArrayBufferView,
113
+ options?: ImageBitmapOptions,
113
114
  ): Promise<ImageBitmap>;
114
115
  }