diff --git a/apps/example/ios/Podfile.lock b/apps/example/ios/Podfile.lock
index aa4edec9d..178e151d4 100644
--- a/apps/example/ios/Podfile.lock
+++ b/apps/example/ios/Podfile.lock
@@ -1433,7 +1433,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- - react-native-wgpu (0.2.1):
+ - react-native-wgpu (0.2.2):
- DoubleConversion
- glog
- hermes-engine
@@ -1833,7 +1833,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- - RNReanimated (3.17.5):
+ - RNReanimated (3.19.1):
- DoubleConversion
- glog
- hermes-engine
@@ -1856,10 +1856,10 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- - RNReanimated/reanimated (= 3.17.5)
- - RNReanimated/worklets (= 3.17.5)
+ - RNReanimated/reanimated (= 3.19.1)
+ - RNReanimated/worklets (= 3.19.1)
- Yoga
- - RNReanimated/reanimated (3.17.5):
+ - RNReanimated/reanimated (3.19.1):
- DoubleConversion
- glog
- hermes-engine
@@ -1882,9 +1882,9 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- - RNReanimated/reanimated/apple (= 3.17.5)
+ - RNReanimated/reanimated/apple (= 3.19.1)
- Yoga
- - RNReanimated/reanimated/apple (3.17.5):
+ - RNReanimated/reanimated/apple (3.19.1):
- DoubleConversion
- glog
- hermes-engine
@@ -1908,7 +1908,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- - RNReanimated/worklets (3.17.5):
+ - RNReanimated/worklets (3.19.1):
- DoubleConversion
- glog
- hermes-engine
@@ -1931,9 +1931,9 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- - RNReanimated/worklets/apple (= 3.17.5)
+ - RNReanimated/worklets/apple (= 3.19.1)
- Yoga
- - RNReanimated/worklets/apple (3.17.5):
+ - RNReanimated/worklets/apple (3.19.1):
- DoubleConversion
- glog
- hermes-engine
@@ -2246,7 +2246,7 @@ SPEC CHECKSUMS:
React-microtasksnativemodule: ca2804a25fdcefffa0aa942aa23ab53b99614a34
react-native-safe-area-context: 00d03dc688ba86664be66f9e3f203fc7d747d899
react-native-skia: 443d0725a6cbbcce886edb96b591935eb3bc36d8
- react-native-wgpu: 55ba6ce8b236d09f103b3568b48ce8c0477f517e
+ react-native-wgpu: e7754c8f25598bfc7e77e5938acce1445f8f2f2b
React-NativeModulesApple: 452b86b29fae99ed0a4015dca3ad9cd222f88abf
React-oscompat: ef5df1c734f19b8003e149317d041b8ce1f7d29c
React-perflogger: 6fd2f6811533e9c19a61e855c3033eecbf4ad2a0
@@ -2282,7 +2282,7 @@ SPEC CHECKSUMS:
ReactTestApp-DevSupport: 8f2bfaea9444fcf141b1f694c02d2af51fd6ec1c
ReactTestApp-Resources: 1bd9ff10e4c24f2ad87101a32023721ae923bccf
RNGestureHandler: 5d8431415d4b8518e86e289e9ad5bb9be78f6dba
- RNReanimated: c567de23384730756bb19ff55490819980536b09
+ RNReanimated: 44c559bda6bcfa00af5be64f5c26c1b1184b83ca
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 9f110fc4b7aa538663cba3c14cbb1c335f43c13f
diff --git a/apps/example/package.json b/apps/example/package.json
index 7dce8612e..591e58253 100644
--- a/apps/example/package.json
+++ b/apps/example/package.json
@@ -29,7 +29,7 @@
"react-native": "0.79.2",
"react-native-gesture-handler": "^2.17.1",
"react-native-macos": "^0.78.3",
- "react-native-reanimated": "^3.12.1",
+ "react-native-reanimated": "3.19.1",
"react-native-safe-area-context": "^5.4.0",
"react-native-wgpu": "*",
"teapot": "^1.0.0",
diff --git a/apps/example/src/Resize/Resize.tsx b/apps/example/src/Resize/Resize.tsx
index 467f5aaea..ca586d26c 100644
--- a/apps/example/src/Resize/Resize.tsx
+++ b/apps/example/src/Resize/Resize.tsx
@@ -62,14 +62,21 @@ export const Resize = () => {
count: sampleCount,
},
});
- let currentSize = { width: 0, height: 0 };
let renderTarget: GPUTexture | undefined;
let renderTargetView: GPUTextureView;
-
return () => {
+ const currentWidth = canvas.clientWidth * PixelRatio.get();
+ const currentHeight = canvas.clientHeight * PixelRatio.get();
+
+ // The canvas size is animating via CSS.
+ // When the size changes, we need to reallocate the render target.
+ // We also need to set the physical size of the canvas to match the computed CSS size.
if (
- currentSize.width !== canvas.clientWidth ||
- currentSize.height !== canvas.clientHeight
+ (currentWidth !== canvas.width ||
+ currentHeight !== canvas.height ||
+ !renderTargetView) &&
+ currentWidth &&
+ currentHeight
) {
if (renderTarget !== undefined) {
// Destroy the previous render target
@@ -78,13 +85,10 @@ export const Resize = () => {
// Setting the canvas width and height will automatically resize the textures returned
// when calling getCurrentTexture() on the context.
- canvas.width = canvas.clientWidth * PixelRatio.get();
- canvas.height = canvas.clientHeight * PixelRatio.get();
+ canvas.width = currentWidth;
+ canvas.height = currentHeight;
- currentSize = {
- width: canvas.clientWidth,
- height: canvas.clientHeight,
- };
+ // Resize the multisampled render target to match the new canvas size.
renderTarget = device.createTexture({
size: [canvas.width, canvas.height],
sampleCount,
@@ -94,15 +98,16 @@ export const Resize = () => {
renderTargetView = renderTarget.createView();
}
+
if (renderTargetView) {
const commandEncoder = device.createCommandEncoder();
- const a = 0.7;
+
const renderPassDescriptor: GPURenderPassDescriptor = {
colorAttachments: [
{
view: renderTargetView,
resolveTarget: context.getCurrentTexture().createView(),
- clearValue: [a, a, a, a],
+ clearValue: [0.5, 0.5, 0.5, 0.5],
loadOp: "clear",
storeOp: "store",
},
@@ -125,7 +130,7 @@ export const Resize = () => {
return (
-
+
);
diff --git a/packages/webgpu/android/src/main/java/com/webgpu/WebGPUAHBView.java b/packages/webgpu/android/src/main/java/com/webgpu/WebGPUAHBView.java
index 073b7351e..46139c84e 100644
--- a/packages/webgpu/android/src/main/java/com/webgpu/WebGPUAHBView.java
+++ b/packages/webgpu/android/src/main/java/com/webgpu/WebGPUAHBView.java
@@ -4,93 +4,295 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Matrix;
+import android.graphics.Paint;
import android.graphics.PixelFormat;
+import android.graphics.Rect;
import android.hardware.HardwareBuffer;
import android.media.Image;
import android.media.ImageReader;
import android.os.Build;
+import android.os.Handler;
+import android.os.Looper;
+import android.view.Surface;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
-@SuppressLint("ViewConstructor")
+import java.nio.ByteBuffer;
+
@RequiresApi(api = Build.VERSION_CODES.Q)
+@SuppressLint("ViewConstructor")
public class WebGPUAHBView extends View implements ImageReader.OnImageAvailableListener {
- private ImageReader mReader;
-
- private Bitmap mBitmap = null;
-
- private final Matrix matrix = new Matrix();
+ private static final int MAX_IMAGES = 3;
+ private static final String TAG = "WebGPUAHBView";
- WebGPUAPI mApi;
+ private final WebGPUAPI mApi;
+ private ImageReader mImageReader;
+ private Surface mSurface;
+ private Image mCurrentImage;
+ private Bitmap mCachedBitmap;
+ private final Paint mPaint;
+ private final Handler mHandler;
+ private final Object mImageLock = new Object();
+ private boolean mSurfaceCreated = false;
+ private int mConfiguredWidth = 0;
+ private int mConfiguredHeight = 0;
public WebGPUAHBView(Context context, WebGPUAPI api) {
super(context);
mApi = api;
- }
+ mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
+ mHandler = new Handler(Looper.getMainLooper());
+
+ // Enable hardware acceleration for this view
+ setLayerType(LAYER_TYPE_HARDWARE, null);
- private ImageReader createReader() {
- ImageReader reader = ImageReader.newInstance(getWidth(), getHeight(), PixelFormat.RGBA_8888, 2, HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE |
- HardwareBuffer.USAGE_GPU_COLOR_OUTPUT);
- reader.setOnImageAvailableListener(this, null);
- return reader;
+ // Make sure we get drawn
+ setWillNotDraw(false);
}
@Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- if (mReader == null) {
- mReader = createReader();
- mApi.surfaceCreated(mReader.getSurface());
- } else {
- mApi.surfaceChanged(mReader.getSurface());
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+
+ if (w > 0 && h > 0) {
+ // Recreate ImageReader with new dimensions
+ setupImageReader(w, h);
+ }
+ }
+
+ private void setupImageReader(int width, int height) {
+ // Don't recreate if dimensions haven't changed
+ if (width == mConfiguredWidth && height == mConfiguredHeight && mImageReader != null) {
+ return;
+ }
+
+ // Clean up previous ImageReader
+ cleanupImageReader();
+
+ try {
+ // Create ImageReader with HardwareBuffer support
+ mImageReader = ImageReader.newInstance(
+ width,
+ height,
+ PixelFormat.RGBA_8888,
+ MAX_IMAGES,
+ HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE |
+ HardwareBuffer.USAGE_GPU_COLOR_OUTPUT |
+ HardwareBuffer.USAGE_COMPOSER_OVERLAY |
+ HardwareBuffer.USAGE_CPU_READ_RARELY // For fallback to Bitmap if needed
+ );
+
+ mImageReader.setOnImageAvailableListener(this, mHandler);
+
+ // Get the Surface for WebGPU to render to
+ mSurface = mImageReader.getSurface();
+
+ mConfiguredWidth = width;
+ mConfiguredHeight = height;
+
+ // Notify WebGPU about the new surface
+ if (!mSurfaceCreated) {
+ mApi.surfaceCreated(mSurface);
+ mSurfaceCreated = true;
+ } else {
+ mApi.surfaceChanged(mSurface);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Fallback to offscreen if ImageReader creation fails
+ mApi.surfaceOffscreen();
}
}
@Override
public void onImageAvailable(ImageReader reader) {
- try (Image image = reader.acquireLatestImage()) {
- if (image != null) {
- HardwareBuffer hb = image.getHardwareBuffer();
- if (hb != null) {
- Bitmap bitmap = Bitmap.wrapHardwareBuffer(hb, null);
- if (bitmap != null) {
- mBitmap = bitmap;
- hb.close();
- invalidate();
- }
+ synchronized (mImageLock) {
+ // Close previous image if exists
+ if (mCurrentImage != null) {
+ mCurrentImage.close();
+ mCurrentImage = null;
+ }
+
+ try {
+ // Get the latest image
+ mCurrentImage = reader.acquireLatestImage();
+
+ if (mCurrentImage != null) {
+ // Request a redraw on the UI thread
+ postInvalidateOnAnimation();
}
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
}
@Override
- protected void onDraw(@NonNull Canvas canvas) {
+ protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
- if (mBitmap != null) {
- float viewWidth = getWidth();
- float viewHeight = getHeight();
- float bitmapWidth = mBitmap.getWidth();
- float bitmapHeight = mBitmap.getHeight();
- // Calculate the scale factors
- float scaleX = viewWidth / bitmapWidth;
- float scaleY = viewHeight / bitmapHeight;
+ synchronized (mImageLock) {
+ if (mCurrentImage == null) {
+ return;
+ }
+
+ try {
+ // Try to use HardwareBuffer directly (most efficient path)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ HardwareBuffer hardwareBuffer = mCurrentImage.getHardwareBuffer();
- // Reset the matrix and apply scaling
- matrix.reset();
- matrix.setScale(scaleX, scaleY);
+ if (hardwareBuffer != null) {
+ // Draw using HardwareBuffer
+ drawHardwareBuffer(canvas, hardwareBuffer);
+ return;
+ }
+ }
- canvas.drawBitmap(mBitmap, matrix, null);
+ // Fallback: Convert Image to Bitmap
+ drawImageAsBitmap(canvas, mCurrentImage);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void drawHardwareBuffer(Canvas canvas, HardwareBuffer hardwareBuffer) {
+ // On Android Q+, we can create a Bitmap from HardwareBuffer
+ try {
+ // Create or reuse bitmap with matching dimensions
+ if (mCachedBitmap == null ||
+ mCachedBitmap.getWidth() != hardwareBuffer.getWidth() ||
+ mCachedBitmap.getHeight() != hardwareBuffer.getHeight()) {
+
+ if (mCachedBitmap != null) {
+ mCachedBitmap.recycle();
+ }
+
+ // Create a hardware-backed Bitmap from the HardwareBuffer
+ mCachedBitmap = Bitmap.wrapHardwareBuffer(hardwareBuffer, null);
+ } else {
+ // Reuse existing bitmap and update with new HardwareBuffer content
+ mCachedBitmap = Bitmap.wrapHardwareBuffer(hardwareBuffer, null);
+ }
+
+ if (mCachedBitmap != null) {
+ // Draw the bitmap to canvas
+ canvas.drawBitmap(mCachedBitmap, 0, 0, mPaint);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ // Fallback to Image-based rendering
+ drawImageAsBitmap(canvas, mCurrentImage);
+ }
+ }
+
+ private void drawImageAsBitmap(Canvas canvas, Image image) {
+ // Fallback method: manually convert Image to Bitmap
+ if (image.getFormat() != PixelFormat.RGBA_8888) {
+ return;
+ }
+
+ Image.Plane[] planes = image.getPlanes();
+ if (planes.length == 0) {
+ return;
+ }
+
+ ByteBuffer buffer = planes[0].getBuffer();
+ int pixelStride = planes[0].getPixelStride();
+ int rowStride = planes[0].getRowStride();
+ int rowPadding = rowStride - pixelStride * image.getWidth();
+
+ // Create or reuse bitmap
+ int bitmapWidth = image.getWidth() + rowPadding / pixelStride;
+ if (mCachedBitmap == null ||
+ mCachedBitmap.getWidth() != bitmapWidth ||
+ mCachedBitmap.getHeight() != image.getHeight()) {
+
+ if (mCachedBitmap != null) {
+ mCachedBitmap.recycle();
+ }
+ mCachedBitmap = Bitmap.createBitmap(
+ bitmapWidth,
+ image.getHeight(),
+ Bitmap.Config.ARGB_8888
+ );
+ }
+
+ mCachedBitmap.copyPixelsFromBuffer(buffer);
+
+ // Draw only the valid portion (without padding)
+ Rect src = new Rect(0, 0, image.getWidth(), image.getHeight());
+ Rect dst = new Rect(0, 0, getWidth(), getHeight());
+ canvas.drawBitmap(mCachedBitmap, src, dst, mPaint);
+ }
+
+ private void cleanupImageReader() {
+ synchronized (mImageLock) {
+ if (mCurrentImage != null) {
+ mCurrentImage.close();
+ mCurrentImage = null;
+ }
+
+ if (mImageReader != null) {
+ mImageReader.close();
+ mImageReader = null;
+ }
+
+ if (mSurface != null) {
+ mSurface.release();
+ mSurface = null;
+ }
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- mApi.surfaceDestroyed();
+
+ // Notify WebGPU that surface is being destroyed
+ if (mSurfaceCreated) {
+ mApi.surfaceDestroyed();
+ mSurfaceCreated = false;
+ }
+
+ // Clean up resources
+ cleanupImageReader();
+
+ if (mCachedBitmap != null) {
+ mCachedBitmap.recycle();
+ mCachedBitmap = null;
+ }
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+
+ // Re-setup if we have valid dimensions
+ if (getWidth() > 0 && getHeight() > 0) {
+ setupImageReader(getWidth(), getHeight());
+ }
+ }
+
+ @Override
+ public void setAlpha(float alpha) {
+ super.setAlpha(alpha);
+ mPaint.setAlpha((int) (alpha * 255));
+ invalidate();
+ }
+
+ @Override
+ protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+
+ if (visibility == VISIBLE && mSurface == null && getWidth() > 0 && getHeight() > 0) {
+ // Re-create surface if needed when becoming visible
+ setupImageReader(getWidth(), getHeight());
+ }
}
}
diff --git a/packages/webgpu/android/src/main/java/com/webgpu/WebGPUView.java b/packages/webgpu/android/src/main/java/com/webgpu/WebGPUView.java
index 1531befac..3f73a1066 100644
--- a/packages/webgpu/android/src/main/java/com/webgpu/WebGPUView.java
+++ b/packages/webgpu/android/src/main/java/com/webgpu/WebGPUView.java
@@ -39,11 +39,11 @@ public void setTransparent(boolean value) {
}
mTransparent = value;
if (mTransparent) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- mView = new WebGPUAHBView(ctx, this);
- } else {
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+// mView = new WebGPUAHBView(ctx, this);
+// } else {
mView = new WebGPUTextureView(ctx, this);
- }
+// }
} else {
mView = new WebGPUSurfaceView(ctx, this);
}
diff --git a/packages/webgpu/apple/ApplePlatformContext.h b/packages/webgpu/apple/ApplePlatformContext.h
index 9f45e6dcc..395cac25a 100644
--- a/packages/webgpu/apple/ApplePlatformContext.h
+++ b/packages/webgpu/apple/ApplePlatformContext.h
@@ -1,6 +1,7 @@
#pragma once
#include "PlatformContext.h"
+#include
namespace rnwgpu {
diff --git a/packages/webgpu/apple/RNWGUIKit.h b/packages/webgpu/apple/RNWGUIKit.h
index 32bca9f21..459331bb0 100644
--- a/packages/webgpu/apple/RNWGUIKit.h
+++ b/packages/webgpu/apple/RNWGUIKit.h
@@ -1,3 +1,6 @@
+#ifndef PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
+#define PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
+
#if !TARGET_OS_OSX
#import
#else
@@ -9,3 +12,5 @@ typedef UIView RNWGPlatformView;
#else
typedef NSView RNWGPlatformView;
#endif
+
+#endif // PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
diff --git a/packages/webgpu/apple/platform/ThreadUtils.cpp b/packages/webgpu/apple/platform/ThreadUtils.cpp
index b9073de7c..4a2051fb0 100644
--- a/packages/webgpu/apple/platform/ThreadUtils.cpp
+++ b/packages/webgpu/apple/platform/ThreadUtils.cpp
@@ -8,6 +8,7 @@
#include "ThreadUtils.h"
#include
#include
+#include
#include
namespace margelo {
diff --git a/packages/webgpu/cpp/WGPULogger.h b/packages/webgpu/cpp/WGPULogger.h
index d7b0329b4..e25aadac5 100644
--- a/packages/webgpu/cpp/WGPULogger.h
+++ b/packages/webgpu/cpp/WGPULogger.h
@@ -4,6 +4,7 @@
#pragma once
+#include
#include
#include
diff --git a/packages/webgpu/cpp/dawn_logging.cpp b/packages/webgpu/cpp/dawn_logging.cpp
index a7aa3420d..5bbd6caeb 100644
--- a/packages/webgpu/cpp/dawn_logging.cpp
+++ b/packages/webgpu/cpp/dawn_logging.cpp
@@ -1,5 +1,7 @@
+#include
#include
#include
+#include
#ifdef __ANDROID__
#include
@@ -21,10 +23,8 @@ class LogMessage {
public:
explicit LogMessage(LogSeverity severity);
~LogMessage();
-
LogMessage(LogMessage&& other);
LogMessage& operator=(LogMessage&& other);
-
template
LogMessage& operator<<(T&& value) {
mStream << value;
@@ -34,7 +34,6 @@ class LogMessage {
private:
LogMessage(const LogMessage& other) = delete;
LogMessage& operator=(const LogMessage& other) = delete;
-
LogSeverity mSeverity;
std::ostringstream mStream;
};
@@ -42,7 +41,7 @@ class LogMessage {
// Implementation of LogMessage methods
LogMessage::LogMessage(LogSeverity severity) : mSeverity(severity) {}
-LogMessage::LogMessage(LogMessage&& other)
+LogMessage::LogMessage(LogMessage&& other)
: mSeverity(other.mSeverity), mStream(std::move(other.mStream)) {}
LogMessage& LogMessage::operator=(LogMessage&& other) {
@@ -55,11 +54,9 @@ LogMessage& LogMessage::operator=(LogMessage&& other) {
LogMessage::~LogMessage() {
std::string fullMessage = mStream.str();
-
if (fullMessage.empty()) {
return;
}
-
const char* severityName;
switch (mSeverity) {
case LogSeverity::Debug: severityName = "Debug"; break;
diff --git a/packages/webgpu/cpp/jsi/RNFHybridObject.cpp b/packages/webgpu/cpp/jsi/RNFHybridObject.cpp
index 415bea47c..ac9ee8c0d 100644
--- a/packages/webgpu/cpp/jsi/RNFHybridObject.cpp
+++ b/packages/webgpu/cpp/jsi/RNFHybridObject.cpp
@@ -5,9 +5,10 @@
#include "RNFJSIConverter.h"
#include "WGPULogger.h"
-#include
+#include
#include
#include
+#include
namespace margelo {
diff --git a/packages/webgpu/cpp/jsi/RNFJSIConverter.h b/packages/webgpu/cpp/jsi/RNFJSIConverter.h
index df1f74852..14daba23f 100644
--- a/packages/webgpu/cpp/jsi/RNFJSIConverter.h
+++ b/packages/webgpu/cpp/jsi/RNFJSIConverter.h
@@ -29,7 +29,7 @@
#include "ThreadPool.h"
// This number is the maximum integer that can be represented exactly as a double
-#define MAX_SAFE_INTEGER uint64_t(9007199254740991)
+#define MAX_SAFE_INTEGER static_cast(9007199254740991)
#if __has_include()
#include
diff --git a/packages/webgpu/cpp/jsi/RNFPromise.cpp b/packages/webgpu/cpp/jsi/RNFPromise.cpp
index 1beff44a8..f2d92b71f 100644
--- a/packages/webgpu/cpp/jsi/RNFPromise.cpp
+++ b/packages/webgpu/cpp/jsi/RNFPromise.cpp
@@ -4,6 +4,8 @@
#include "RNFPromise.h"
#include
#include
+#include
+#include
#include
#include
diff --git a/packages/webgpu/cpp/jsi/RNFWorkletRuntimeRegistry.cpp b/packages/webgpu/cpp/jsi/RNFWorkletRuntimeRegistry.cpp
index 762e842ed..319d2391e 100644
--- a/packages/webgpu/cpp/jsi/RNFWorkletRuntimeRegistry.cpp
+++ b/packages/webgpu/cpp/jsi/RNFWorkletRuntimeRegistry.cpp
@@ -2,6 +2,7 @@
// Created by Marc Rousavy on 22.02.24.
//
#include "RNFWorkletRuntimeRegistry.h"
+#include
namespace margelo {
diff --git a/packages/webgpu/cpp/rnwgpu/SurfaceRegistry.h b/packages/webgpu/cpp/rnwgpu/SurfaceRegistry.h
index fa93c1c1e..110a45d44 100644
--- a/packages/webgpu/cpp/rnwgpu/SurfaceRegistry.h
+++ b/packages/webgpu/cpp/rnwgpu/SurfaceRegistry.h
@@ -3,6 +3,7 @@
#include
#include
#include
+#include
#include "webgpu/webgpu_cpp.h"
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPU.cpp b/packages/webgpu/cpp/rnwgpu/api/GPU.cpp
index ca64fd020..54034e5e9 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPU.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPU.cpp
@@ -1,5 +1,9 @@
#include "GPU.h"
+#include
+#include
+#include
+#include
#include
#include
@@ -50,7 +54,7 @@ GPU::requestAdapter(
std::unordered_set GPU::getWgslLanguageFeatures() {
wgpu::SupportedWGSLLanguageFeatures supportedFeatures = {};
_instance.GetWGSLLanguageFeatures(&supportedFeatures);
-
+
std::unordered_set result;
for (size_t i = 0; i < supportedFeatures.featureCount; i++) {
wgpu::WGSLLanguageFeatureName feature = supportedFeatures.features[i];
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPU.h b/packages/webgpu/cpp/rnwgpu/api/GPU.h
index 9a3a89590..d64f08122 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPU.h
+++ b/packages/webgpu/cpp/rnwgpu/api/GPU.h
@@ -29,10 +29,8 @@ class GPU : public m::HybridObject {
public:
GPU() : HybridObject("GPU") {
static const auto kTimedWaitAny = wgpu::InstanceFeatureName::TimedWaitAny;
- wgpu::InstanceDescriptor instanceDesc{
- .requiredFeatureCount = 1,
- .requiredFeatures = &kTimedWaitAny
- };
+ wgpu::InstanceDescriptor instanceDesc{.requiredFeatureCount = 1,
+ .requiredFeatures = &kTimedWaitAny};
// For limits:
wgpu::InstanceLimits limits{.timedWaitAnyMaxCount = 64};
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUAdapter.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUAdapter.cpp
index 3d5a87fdb..1bc6dd773 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUAdapter.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUAdapter.cpp
@@ -1,6 +1,9 @@
#include "GPUAdapter.h"
+#include
+#include
#include
+#include
#include
#include
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.cpp
index 06c57d9d1..d96ba8e92 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUBuffer.cpp
@@ -1,5 +1,6 @@
#include "GPUBuffer.h"
+#include
#include
#include "Convertors.h"
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.cpp
index ea3127420..66fe437f2 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.cpp
@@ -1,4 +1,5 @@
#include "GPUCanvasContext.h"
+#include
#include "Convertors.h"
#include "RNWebGPUManager.h"
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.h b/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.h
index 4e8f0b447..9eb9928f5 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.h
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.h
@@ -2,6 +2,7 @@
#include
#include
+#include
#include "Unions.h"
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.cpp
index e0e068ad9..6d6ad6c41 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUCommandEncoder.cpp
@@ -1,5 +1,7 @@
#include "GPUCommandEncoder.h"
+#include
+#include
#include
#include "Convertors.h"
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.cpp
index b3d27f24c..b74f273a0 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUComputePassEncoder.cpp
@@ -1,4 +1,6 @@
#include "GPUComputePassEncoder.h"
+#include
+#include
namespace rnwgpu {
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.cpp
index ec6ad7f9e..4a8be1d72 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUComputePipeline.cpp
@@ -1,4 +1,5 @@
#include "GPUComputePipeline.h"
+#include
namespace rnwgpu {
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUDevice.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUDevice.cpp
index 2d07422a1..5e44783dd 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUDevice.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUDevice.cpp
@@ -1,5 +1,8 @@
#include "GPUDevice.h"
+#include
+#include
+#include
#include
#include "Convertors.h"
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp
index 157140f80..51f31aa39 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp
@@ -1,4 +1,5 @@
#include "GPUDeviceLostInfo.h"
+#include
namespace rnwgpu {
wgpu::DeviceLostReason getReason();
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUQueue.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUQueue.cpp
index eae1d4806..6cbb5d897 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUQueue.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUQueue.cpp
@@ -1,6 +1,8 @@
#include "GPUQueue.h"
#include
+#include
+#include
#include "Convertors.h"
@@ -38,7 +40,7 @@ void GPUQueue::writeBuffer(std::shared_ptr buffer,
// Note that in the JS semantics of WebGPU, writeBuffer works in number of
// elements of the typed arrays.
- if (dataOffsetElements > uint64_t(src.size / src.bytesPerElement)) {
+ if (dataOffsetElements > static_cast(src.size / src.bytesPerElement)) {
throw std::runtime_error("dataOffset is larger than data's size.");
return;
}
@@ -49,7 +51,7 @@ void GPUQueue::writeBuffer(std::shared_ptr buffer,
// Size defaults to dataSize - dataOffset. Instead of computing in elements,
// we directly use it in bytes, and convert the provided value, if any, in
// bytes.
- uint64_t size64 = uint64_t(src.size);
+ uint64_t size64 = static_cast(src.size);
if (sizeElements.has_value()) {
if (sizeElements.value() >
std::numeric_limits::max() / src.bytesPerElement) {
@@ -59,7 +61,7 @@ void GPUQueue::writeBuffer(std::shared_ptr buffer,
size64 = sizeElements.value() * src.bytesPerElement;
}
- if (size64 > uint64_t(src.size)) {
+ if (size64 > static_cast(src.size)) {
throw std::runtime_error("size + dataOffset is larger than data's size.");
return;
}
@@ -80,7 +82,7 @@ std::future GPUQueue::onSubmittedWorkDone() {
return _instance.OnSubmittedWorkDone(
wgpu::CallbackMode::WaitAnyOnly,
[](wgpu::QueueWorkDoneStatus status, wgpu::StringView message) {
- // Handle the callback if needed
+ // Handle the callback if needed
});
});
}
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp b/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp
index b56fa5aa8..ece7257ea 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp
@@ -1,5 +1,8 @@
#include "GPURenderBundleEncoder.h"
+#include
+#include
+
#include "Convertors.h"
namespace rnwgpu {
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.cpp b/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.cpp
index 1247d69e6..5a5825589 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPURenderPassEncoder.cpp
@@ -1,3 +1,7 @@
+#include
+#include
+#include
+
#include "GPURenderPassEncoder.h"
#include "Convertors.h"
diff --git a/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.cpp b/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.cpp
index 6081cb118..214adc013 100644
--- a/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.cpp
+++ b/packages/webgpu/cpp/rnwgpu/api/GPUShaderModule.cpp
@@ -1,6 +1,7 @@
#include "GPUShaderModule.h"
#include
+#include
namespace rnwgpu {
diff --git a/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h b/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h
index 45b6202ec..15a450625 100644
--- a/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h
+++ b/packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h
@@ -441,7 +441,8 @@ static void convertJSUnionToEnum(const std::string &inUnion,
} else if (inUnion == "dawn-native") {
*outEnum = wgpu::FeatureName::DawnNative;
} else if (inUnion == "chromium-experimental-timestamp-query-inside-passes") {
- *outEnum = wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses;
+ *outEnum =
+ wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses;
} else if (inUnion == "implicit-device-synchronization") {
*outEnum = wgpu::FeatureName::ImplicitDeviceSynchronization;
} else if (inUnion == "transient-attachments") {
@@ -613,7 +614,7 @@ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
case wgpu::FeatureName::ANGLETextureSharing:
*outUnion = "angle-texture-sharing";
break;
- case wgpu::FeatureName::ChromiumExperimentalSubgroupMatrix:
+ case wgpu::FeatureName::ChromiumExperimentalSubgroupMatrix:
*outUnion = "chromium-experimental-subgroups-matrix";
break;
case wgpu::FeatureName::PixelLocalStorageCoherent:
diff --git a/packages/webgpu/cpp/threading/Dispatcher.cpp b/packages/webgpu/cpp/threading/Dispatcher.cpp
index a780f4594..580896840 100644
--- a/packages/webgpu/cpp/threading/Dispatcher.cpp
+++ b/packages/webgpu/cpp/threading/Dispatcher.cpp
@@ -1,10 +1,11 @@
//
// Created by Marc Rousavy on 12.03.24.
//
+#include
+#include
#include "Dispatcher.h"
-#include
#include "RNFJSIHelper.h"
namespace margelo {
diff --git a/packages/webgpu/cpp/threading/ThreadPool.cpp b/packages/webgpu/cpp/threading/ThreadPool.cpp
index 181977fb5..95ea6890f 100644
--- a/packages/webgpu/cpp/threading/ThreadPool.cpp
+++ b/packages/webgpu/cpp/threading/ThreadPool.cpp
@@ -10,6 +10,8 @@
#include
#include
+#include
+#include
namespace margelo {
diff --git a/packages/webgpu/scripts/build/dawn-configuration.ts b/packages/webgpu/scripts/build/dawn-configuration.ts
index 8ac0283ce..7cc4774c7 100644
--- a/packages/webgpu/scripts/build/dawn-configuration.ts
+++ b/packages/webgpu/scripts/build/dawn-configuration.ts
@@ -82,7 +82,7 @@ export const checkBuildArtifacts = () => {
.filter((arch) => arch !== "arm64" && arch !== "universal")
.forEach((platform) => {
libs.forEach((lib) => {
- checkFileExists(`libs/android/${platform}/${lib}.a`);
+ checkFileExists(`libs/android/${platform}/${lib}.so`);
});
});
libs.forEach((lib) => {
diff --git a/packages/webgpu/src/Canvas.tsx b/packages/webgpu/src/Canvas.tsx
index ea6907e8a..65e0c3965 100644
--- a/packages/webgpu/src/Canvas.tsx
+++ b/packages/webgpu/src/Canvas.tsx
@@ -137,7 +137,7 @@ export const Canvas = forwardRef<
return (
diff --git a/yarn.lock b/yarn.lock
index 79b1deaf2..bfc6803c2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4507,7 +4507,7 @@ __metadata:
react-native: 0.79.2
react-native-gesture-handler: ^2.17.1
react-native-macos: ^0.78.3
- react-native-reanimated: ^3.12.1
+ react-native-reanimated: 3.19.1
react-native-safe-area-context: ^5.4.0
react-native-test-app: 4.3.10
react-native-wgpu: "*"
@@ -11996,9 +11996,9 @@ __metadata:
languageName: node
linkType: hard
-"react-native-reanimated@npm:^3.12.1":
- version: 3.17.5
- resolution: "react-native-reanimated@npm:3.17.5"
+"react-native-reanimated@npm:3.19.1":
+ version: 3.19.1
+ resolution: "react-native-reanimated@npm:3.19.1"
dependencies:
"@babel/plugin-transform-arrow-functions": ^7.0.0-0
"@babel/plugin-transform-class-properties": ^7.0.0-0
@@ -12016,7 +12016,7 @@ __metadata:
"@babel/core": ^7.0.0-0
react: "*"
react-native: "*"
- checksum: fe667e4764f691b2e752eaedb7527fd8ac251637ae9e7dd9ab124abae85627839b5daea064befc5e09ca710ef673d5501ed11286eb39dfcb04f5d57b2d47e49c
+ checksum: 679c737e6fc775102a31c077552b37889c3a18eeefcfd5b213925d2014ce71d0643cf7501e03ac3b65157eea862c9976dca3987eaa2e3377d21fc095b82cb998
languageName: node
linkType: hard