react-native-wgpu 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +1 -1
- package/android/build.gradle +2 -1
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +247 -45
- package/android/src/main/java/com/webgpu/WebGPUView.java +4 -4
- package/apple/ApplePlatformContext.h +1 -0
- package/apple/RNWGUIKit.h +5 -0
- package/apple/platform/ThreadUtils.cpp +1 -0
- package/cpp/WGPULogger.h +1 -0
- package/cpp/dawn/dawn_proc_table.h +31 -10
- package/cpp/dawn/native/D3D11Backend.h +8 -2
- package/cpp/dawn/native/D3DBackend.h +0 -3
- package/cpp/dawn/native/DawnNative.h +4 -0
- package/cpp/dawn/platform/DawnPlatform.h +2 -1
- package/cpp/dawn/webgpu_cpp_print.h +202 -25
- package/cpp/dawn_logging.cpp +3 -6
- package/cpp/jsi/RNFHybridObject.cpp +2 -1
- package/cpp/jsi/RNFJSIConverter.h +5 -2
- package/cpp/jsi/RNFPromise.cpp +2 -0
- package/cpp/jsi/RNFWorkletRuntimeRegistry.cpp +1 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +1 -0
- package/cpp/rnwgpu/api/GPU.cpp +5 -1
- package/cpp/rnwgpu/api/GPU.h +7 -3
- package/cpp/rnwgpu/api/GPUAdapter.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +1 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +1 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +2 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +2 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +1 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +3 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +1 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +9 -5
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +3 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +4 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +3 -2
- package/cpp/threading/Dispatcher.cpp +2 -1
- package/cpp/threading/ThreadPool.cpp +2 -0
- package/cpp/webgpu/webgpu.h +571 -261
- package/cpp/webgpu/webgpu_cpp.h +871 -313
- package/lib/typescript/src/__tests__/setup.d.ts +0 -1
- package/lib/typescript/src/__tests__/setup.d.ts.map +1 -1
- package/libs/android/arm64-v8a/libwebgpu_dawn.a +0 -0
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.a +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.a +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.a +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
- package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/dawn.json +422 -206
- package/package.json +1 -1
- package/src/__tests__/Constants.spec.ts +2 -4
- package/src/__tests__/Device.spec.ts +42 -24
- package/src/__tests__/GPU.spec.ts +115 -105
- package/src/__tests__/setup.ts +0 -1
package/android/CMakeLists.txt
CHANGED
package/android/build.gradle
CHANGED
|
@@ -81,7 +81,8 @@ android {
|
|
|
81
81
|
cppFlags "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
|
|
82
82
|
abiFilters (*reactNativeArchitectures())
|
|
83
83
|
arguments '-DANDROID_STL=c++_shared',
|
|
84
|
-
"-DNODE_MODULES_DIR=${nodeModules}"
|
|
84
|
+
"-DNODE_MODULES_DIR=${nodeModules}",
|
|
85
|
+
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
}
|
|
@@ -4,93 +4,295 @@ import android.annotation.SuppressLint;
|
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.graphics.Bitmap;
|
|
6
6
|
import android.graphics.Canvas;
|
|
7
|
-
import android.graphics.
|
|
7
|
+
import android.graphics.Paint;
|
|
8
8
|
import android.graphics.PixelFormat;
|
|
9
|
+
import android.graphics.Rect;
|
|
9
10
|
import android.hardware.HardwareBuffer;
|
|
10
11
|
import android.media.Image;
|
|
11
12
|
import android.media.ImageReader;
|
|
12
13
|
import android.os.Build;
|
|
14
|
+
import android.os.Handler;
|
|
15
|
+
import android.os.Looper;
|
|
16
|
+
import android.view.Surface;
|
|
13
17
|
import android.view.View;
|
|
14
18
|
|
|
15
19
|
import androidx.annotation.NonNull;
|
|
16
20
|
import androidx.annotation.RequiresApi;
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
import java.nio.ByteBuffer;
|
|
23
|
+
|
|
19
24
|
@RequiresApi(api = Build.VERSION_CODES.Q)
|
|
25
|
+
@SuppressLint("ViewConstructor")
|
|
20
26
|
public class WebGPUAHBView extends View implements ImageReader.OnImageAvailableListener {
|
|
21
27
|
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
private Bitmap mBitmap = null;
|
|
25
|
-
|
|
26
|
-
private final Matrix matrix = new Matrix();
|
|
28
|
+
private static final int MAX_IMAGES = 3;
|
|
29
|
+
private static final String TAG = "WebGPUAHBView";
|
|
27
30
|
|
|
28
|
-
WebGPUAPI mApi;
|
|
31
|
+
private final WebGPUAPI mApi;
|
|
32
|
+
private ImageReader mImageReader;
|
|
33
|
+
private Surface mSurface;
|
|
34
|
+
private Image mCurrentImage;
|
|
35
|
+
private Bitmap mCachedBitmap;
|
|
36
|
+
private final Paint mPaint;
|
|
37
|
+
private final Handler mHandler;
|
|
38
|
+
private final Object mImageLock = new Object();
|
|
39
|
+
private boolean mSurfaceCreated = false;
|
|
40
|
+
private int mConfiguredWidth = 0;
|
|
41
|
+
private int mConfiguredHeight = 0;
|
|
29
42
|
|
|
30
43
|
public WebGPUAHBView(Context context, WebGPUAPI api) {
|
|
31
44
|
super(context);
|
|
32
45
|
mApi = api;
|
|
33
|
-
|
|
46
|
+
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
|
47
|
+
mHandler = new Handler(Looper.getMainLooper());
|
|
48
|
+
|
|
49
|
+
// Enable hardware acceleration for this view
|
|
50
|
+
setLayerType(LAYER_TYPE_HARDWARE, null);
|
|
34
51
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
HardwareBuffer.USAGE_GPU_COLOR_OUTPUT);
|
|
38
|
-
reader.setOnImageAvailableListener(this, null);
|
|
39
|
-
return reader;
|
|
52
|
+
// Make sure we get drawn
|
|
53
|
+
setWillNotDraw(false);
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
@Override
|
|
43
|
-
protected void
|
|
44
|
-
super.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
58
|
+
super.onSizeChanged(w, h, oldw, oldh);
|
|
59
|
+
|
|
60
|
+
if (w > 0 && h > 0) {
|
|
61
|
+
// Recreate ImageReader with new dimensions
|
|
62
|
+
setupImageReader(w, h);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private void setupImageReader(int width, int height) {
|
|
67
|
+
// Don't recreate if dimensions haven't changed
|
|
68
|
+
if (width == mConfiguredWidth && height == mConfiguredHeight && mImageReader != null) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Clean up previous ImageReader
|
|
73
|
+
cleanupImageReader();
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
// Create ImageReader with HardwareBuffer support
|
|
77
|
+
mImageReader = ImageReader.newInstance(
|
|
78
|
+
width,
|
|
79
|
+
height,
|
|
80
|
+
PixelFormat.RGBA_8888,
|
|
81
|
+
MAX_IMAGES,
|
|
82
|
+
HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE |
|
|
83
|
+
HardwareBuffer.USAGE_GPU_COLOR_OUTPUT |
|
|
84
|
+
HardwareBuffer.USAGE_COMPOSER_OVERLAY |
|
|
85
|
+
HardwareBuffer.USAGE_CPU_READ_RARELY // For fallback to Bitmap if needed
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
mImageReader.setOnImageAvailableListener(this, mHandler);
|
|
89
|
+
|
|
90
|
+
// Get the Surface for WebGPU to render to
|
|
91
|
+
mSurface = mImageReader.getSurface();
|
|
92
|
+
|
|
93
|
+
mConfiguredWidth = width;
|
|
94
|
+
mConfiguredHeight = height;
|
|
95
|
+
|
|
96
|
+
// Notify WebGPU about the new surface
|
|
97
|
+
if (!mSurfaceCreated) {
|
|
98
|
+
mApi.surfaceCreated(mSurface);
|
|
99
|
+
mSurfaceCreated = true;
|
|
100
|
+
} else {
|
|
101
|
+
mApi.surfaceChanged(mSurface);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
} catch (Exception e) {
|
|
105
|
+
e.printStackTrace();
|
|
106
|
+
// Fallback to offscreen if ImageReader creation fails
|
|
107
|
+
mApi.surfaceOffscreen();
|
|
50
108
|
}
|
|
51
109
|
}
|
|
52
110
|
|
|
53
111
|
@Override
|
|
54
112
|
public void onImageAvailable(ImageReader reader) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
113
|
+
synchronized (mImageLock) {
|
|
114
|
+
// Close previous image if exists
|
|
115
|
+
if (mCurrentImage != null) {
|
|
116
|
+
mCurrentImage.close();
|
|
117
|
+
mCurrentImage = null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
// Get the latest image
|
|
122
|
+
mCurrentImage = reader.acquireLatestImage();
|
|
123
|
+
|
|
124
|
+
if (mCurrentImage != null) {
|
|
125
|
+
// Request a redraw on the UI thread
|
|
126
|
+
postInvalidateOnAnimation();
|
|
65
127
|
}
|
|
128
|
+
} catch (Exception e) {
|
|
129
|
+
e.printStackTrace();
|
|
66
130
|
}
|
|
67
131
|
}
|
|
68
132
|
}
|
|
69
133
|
|
|
70
134
|
@Override
|
|
71
|
-
protected void onDraw(
|
|
135
|
+
protected void onDraw(Canvas canvas) {
|
|
72
136
|
super.onDraw(canvas);
|
|
73
|
-
if (mBitmap != null) {
|
|
74
|
-
float viewWidth = getWidth();
|
|
75
|
-
float viewHeight = getHeight();
|
|
76
|
-
float bitmapWidth = mBitmap.getWidth();
|
|
77
|
-
float bitmapHeight = mBitmap.getHeight();
|
|
78
137
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
138
|
+
synchronized (mImageLock) {
|
|
139
|
+
if (mCurrentImage == null) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
// Try to use HardwareBuffer directly (most efficient path)
|
|
145
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
146
|
+
HardwareBuffer hardwareBuffer = mCurrentImage.getHardwareBuffer();
|
|
82
147
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
148
|
+
if (hardwareBuffer != null) {
|
|
149
|
+
// Draw using HardwareBuffer
|
|
150
|
+
drawHardwareBuffer(canvas, hardwareBuffer);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
86
154
|
|
|
87
|
-
|
|
155
|
+
// Fallback: Convert Image to Bitmap
|
|
156
|
+
drawImageAsBitmap(canvas, mCurrentImage);
|
|
157
|
+
|
|
158
|
+
} catch (Exception e) {
|
|
159
|
+
e.printStackTrace();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private void drawHardwareBuffer(Canvas canvas, HardwareBuffer hardwareBuffer) {
|
|
165
|
+
// On Android Q+, we can create a Bitmap from HardwareBuffer
|
|
166
|
+
try {
|
|
167
|
+
// Create or reuse bitmap with matching dimensions
|
|
168
|
+
if (mCachedBitmap == null ||
|
|
169
|
+
mCachedBitmap.getWidth() != hardwareBuffer.getWidth() ||
|
|
170
|
+
mCachedBitmap.getHeight() != hardwareBuffer.getHeight()) {
|
|
171
|
+
|
|
172
|
+
if (mCachedBitmap != null) {
|
|
173
|
+
mCachedBitmap.recycle();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Create a hardware-backed Bitmap from the HardwareBuffer
|
|
177
|
+
mCachedBitmap = Bitmap.wrapHardwareBuffer(hardwareBuffer, null);
|
|
178
|
+
} else {
|
|
179
|
+
// Reuse existing bitmap and update with new HardwareBuffer content
|
|
180
|
+
mCachedBitmap = Bitmap.wrapHardwareBuffer(hardwareBuffer, null);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (mCachedBitmap != null) {
|
|
184
|
+
// Draw the bitmap to canvas
|
|
185
|
+
canvas.drawBitmap(mCachedBitmap, 0, 0, mPaint);
|
|
186
|
+
}
|
|
187
|
+
} catch (Exception e) {
|
|
188
|
+
e.printStackTrace();
|
|
189
|
+
// Fallback to Image-based rendering
|
|
190
|
+
drawImageAsBitmap(canvas, mCurrentImage);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private void drawImageAsBitmap(Canvas canvas, Image image) {
|
|
195
|
+
// Fallback method: manually convert Image to Bitmap
|
|
196
|
+
if (image.getFormat() != PixelFormat.RGBA_8888) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
Image.Plane[] planes = image.getPlanes();
|
|
201
|
+
if (planes.length == 0) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
ByteBuffer buffer = planes[0].getBuffer();
|
|
206
|
+
int pixelStride = planes[0].getPixelStride();
|
|
207
|
+
int rowStride = planes[0].getRowStride();
|
|
208
|
+
int rowPadding = rowStride - pixelStride * image.getWidth();
|
|
209
|
+
|
|
210
|
+
// Create or reuse bitmap
|
|
211
|
+
int bitmapWidth = image.getWidth() + rowPadding / pixelStride;
|
|
212
|
+
if (mCachedBitmap == null ||
|
|
213
|
+
mCachedBitmap.getWidth() != bitmapWidth ||
|
|
214
|
+
mCachedBitmap.getHeight() != image.getHeight()) {
|
|
215
|
+
|
|
216
|
+
if (mCachedBitmap != null) {
|
|
217
|
+
mCachedBitmap.recycle();
|
|
218
|
+
}
|
|
219
|
+
mCachedBitmap = Bitmap.createBitmap(
|
|
220
|
+
bitmapWidth,
|
|
221
|
+
image.getHeight(),
|
|
222
|
+
Bitmap.Config.ARGB_8888
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
mCachedBitmap.copyPixelsFromBuffer(buffer);
|
|
227
|
+
|
|
228
|
+
// Draw only the valid portion (without padding)
|
|
229
|
+
Rect src = new Rect(0, 0, image.getWidth(), image.getHeight());
|
|
230
|
+
Rect dst = new Rect(0, 0, getWidth(), getHeight());
|
|
231
|
+
canvas.drawBitmap(mCachedBitmap, src, dst, mPaint);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private void cleanupImageReader() {
|
|
235
|
+
synchronized (mImageLock) {
|
|
236
|
+
if (mCurrentImage != null) {
|
|
237
|
+
mCurrentImage.close();
|
|
238
|
+
mCurrentImage = null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (mImageReader != null) {
|
|
242
|
+
mImageReader.close();
|
|
243
|
+
mImageReader = null;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (mSurface != null) {
|
|
247
|
+
mSurface.release();
|
|
248
|
+
mSurface = null;
|
|
249
|
+
}
|
|
88
250
|
}
|
|
89
251
|
}
|
|
90
252
|
|
|
91
253
|
@Override
|
|
92
254
|
protected void onDetachedFromWindow() {
|
|
93
255
|
super.onDetachedFromWindow();
|
|
94
|
-
|
|
256
|
+
|
|
257
|
+
// Notify WebGPU that surface is being destroyed
|
|
258
|
+
if (mSurfaceCreated) {
|
|
259
|
+
mApi.surfaceDestroyed();
|
|
260
|
+
mSurfaceCreated = false;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Clean up resources
|
|
264
|
+
cleanupImageReader();
|
|
265
|
+
|
|
266
|
+
if (mCachedBitmap != null) {
|
|
267
|
+
mCachedBitmap.recycle();
|
|
268
|
+
mCachedBitmap = null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@Override
|
|
273
|
+
protected void onAttachedToWindow() {
|
|
274
|
+
super.onAttachedToWindow();
|
|
275
|
+
|
|
276
|
+
// Re-setup if we have valid dimensions
|
|
277
|
+
if (getWidth() > 0 && getHeight() > 0) {
|
|
278
|
+
setupImageReader(getWidth(), getHeight());
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@Override
|
|
283
|
+
public void setAlpha(float alpha) {
|
|
284
|
+
super.setAlpha(alpha);
|
|
285
|
+
mPaint.setAlpha((int) (alpha * 255));
|
|
286
|
+
invalidate();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@Override
|
|
290
|
+
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
|
|
291
|
+
super.onVisibilityChanged(changedView, visibility);
|
|
292
|
+
|
|
293
|
+
if (visibility == VISIBLE && mSurface == null && getWidth() > 0 && getHeight() > 0) {
|
|
294
|
+
// Re-create surface if needed when becoming visible
|
|
295
|
+
setupImageReader(getWidth(), getHeight());
|
|
296
|
+
}
|
|
95
297
|
}
|
|
96
298
|
}
|
|
@@ -39,11 +39,11 @@ public class WebGPUView extends ReactViewGroup implements WebGPUAPI {
|
|
|
39
39
|
}
|
|
40
40
|
mTransparent = value;
|
|
41
41
|
if (mTransparent) {
|
|
42
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
43
|
-
mView = new WebGPUAHBView(ctx, this);
|
|
44
|
-
} else {
|
|
42
|
+
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
43
|
+
// mView = new WebGPUAHBView(ctx, this);
|
|
44
|
+
// } else {
|
|
45
45
|
mView = new WebGPUTextureView(ctx, this);
|
|
46
|
-
}
|
|
46
|
+
// }
|
|
47
47
|
} else {
|
|
48
48
|
mView = new WebGPUSurfaceView(ctx, this);
|
|
49
49
|
}
|
package/apple/RNWGUIKit.h
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
#ifndef PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
|
|
2
|
+
#define PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
|
|
3
|
+
|
|
1
4
|
#if !TARGET_OS_OSX
|
|
2
5
|
#import <UIKit/UIKit.h>
|
|
3
6
|
#else
|
|
@@ -9,3 +12,5 @@ typedef UIView RNWGPlatformView;
|
|
|
9
12
|
#else
|
|
10
13
|
typedef NSView RNWGPlatformView;
|
|
11
14
|
#endif
|
|
15
|
+
|
|
16
|
+
#endif // PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
|
package/cpp/WGPULogger.h
CHANGED
|
@@ -6,18 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
// Note: Often allocated as a static global. Do not add a complex constructor.
|
|
8
8
|
typedef struct DawnProcTable {
|
|
9
|
-
WGPUProcAdapterInfoFreeMembers adapterInfoFreeMembers;
|
|
10
|
-
WGPUProcAdapterPropertiesMemoryHeapsFreeMembers adapterPropertiesMemoryHeapsFreeMembers;
|
|
11
|
-
WGPUProcAdapterPropertiesSubgroupMatrixConfigsFreeMembers adapterPropertiesSubgroupMatrixConfigsFreeMembers;
|
|
12
9
|
WGPUProcCreateInstance createInstance;
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
WGPUProcGetInstanceFeatures getInstanceFeatures;
|
|
11
|
+
WGPUProcGetInstanceLimits getInstanceLimits;
|
|
12
|
+
WGPUProcHasInstanceFeature hasInstanceFeature;
|
|
15
13
|
WGPUProcGetProcAddress getProcAddress;
|
|
16
|
-
WGPUProcSharedBufferMemoryEndAccessStateFreeMembers sharedBufferMemoryEndAccessStateFreeMembers;
|
|
17
|
-
WGPUProcSharedTextureMemoryEndAccessStateFreeMembers sharedTextureMemoryEndAccessStateFreeMembers;
|
|
18
|
-
WGPUProcSupportedFeaturesFreeMembers supportedFeaturesFreeMembers;
|
|
19
|
-
WGPUProcSupportedWGSLLanguageFeaturesFreeMembers supportedWGSLLanguageFeaturesFreeMembers;
|
|
20
|
-
WGPUProcSurfaceCapabilitiesFreeMembers surfaceCapabilitiesFreeMembers;
|
|
21
14
|
|
|
22
15
|
WGPUProcAdapterCreateDevice adapterCreateDevice;
|
|
23
16
|
WGPUProcAdapterGetFeatures adapterGetFeatures;
|
|
@@ -30,6 +23,13 @@ typedef struct DawnProcTable {
|
|
|
30
23
|
WGPUProcAdapterAddRef adapterAddRef;
|
|
31
24
|
WGPUProcAdapterRelease adapterRelease;
|
|
32
25
|
|
|
26
|
+
WGPUProcAdapterInfoFreeMembers adapterInfoFreeMembers;
|
|
27
|
+
|
|
28
|
+
WGPUProcAdapterPropertiesMemoryHeapsFreeMembers adapterPropertiesMemoryHeapsFreeMembers;
|
|
29
|
+
|
|
30
|
+
WGPUProcAdapterPropertiesSubgroupMatrixConfigsFreeMembers adapterPropertiesSubgroupMatrixConfigsFreeMembers;
|
|
31
|
+
|
|
32
|
+
WGPUProcBindGroupDestroy bindGroupDestroy;
|
|
33
33
|
WGPUProcBindGroupSetLabel bindGroupSetLabel;
|
|
34
34
|
WGPUProcBindGroupAddRef bindGroupAddRef;
|
|
35
35
|
WGPUProcBindGroupRelease bindGroupRelease;
|
|
@@ -38,6 +38,7 @@ typedef struct DawnProcTable {
|
|
|
38
38
|
WGPUProcBindGroupLayoutAddRef bindGroupLayoutAddRef;
|
|
39
39
|
WGPUProcBindGroupLayoutRelease bindGroupLayoutRelease;
|
|
40
40
|
|
|
41
|
+
WGPUProcBufferCreateTexelView bufferCreateTexelView;
|
|
41
42
|
WGPUProcBufferDestroy bufferDestroy;
|
|
42
43
|
WGPUProcBufferGetConstMappedRange bufferGetConstMappedRange;
|
|
43
44
|
WGPUProcBufferGetMappedRange bufferGetMappedRange;
|
|
@@ -94,6 +95,8 @@ typedef struct DawnProcTable {
|
|
|
94
95
|
WGPUProcComputePipelineAddRef computePipelineAddRef;
|
|
95
96
|
WGPUProcComputePipelineRelease computePipelineRelease;
|
|
96
97
|
|
|
98
|
+
WGPUProcDawnDrmFormatCapabilitiesFreeMembers dawnDrmFormatCapabilitiesFreeMembers;
|
|
99
|
+
|
|
97
100
|
WGPUProcDeviceCreateBindGroup deviceCreateBindGroup;
|
|
98
101
|
WGPUProcDeviceCreateBindGroupLayout deviceCreateBindGroupLayout;
|
|
99
102
|
WGPUProcDeviceCreateBuffer deviceCreateBuffer;
|
|
@@ -245,6 +248,8 @@ typedef struct DawnProcTable {
|
|
|
245
248
|
WGPUProcSharedBufferMemoryAddRef sharedBufferMemoryAddRef;
|
|
246
249
|
WGPUProcSharedBufferMemoryRelease sharedBufferMemoryRelease;
|
|
247
250
|
|
|
251
|
+
WGPUProcSharedBufferMemoryEndAccessStateFreeMembers sharedBufferMemoryEndAccessStateFreeMembers;
|
|
252
|
+
|
|
248
253
|
WGPUProcSharedFenceExportInfo sharedFenceExportInfo;
|
|
249
254
|
WGPUProcSharedFenceAddRef sharedFenceAddRef;
|
|
250
255
|
WGPUProcSharedFenceRelease sharedFenceRelease;
|
|
@@ -258,6 +263,14 @@ typedef struct DawnProcTable {
|
|
|
258
263
|
WGPUProcSharedTextureMemoryAddRef sharedTextureMemoryAddRef;
|
|
259
264
|
WGPUProcSharedTextureMemoryRelease sharedTextureMemoryRelease;
|
|
260
265
|
|
|
266
|
+
WGPUProcSharedTextureMemoryEndAccessStateFreeMembers sharedTextureMemoryEndAccessStateFreeMembers;
|
|
267
|
+
|
|
268
|
+
WGPUProcSupportedFeaturesFreeMembers supportedFeaturesFreeMembers;
|
|
269
|
+
|
|
270
|
+
WGPUProcSupportedInstanceFeaturesFreeMembers supportedInstanceFeaturesFreeMembers;
|
|
271
|
+
|
|
272
|
+
WGPUProcSupportedWGSLLanguageFeaturesFreeMembers supportedWGSLLanguageFeaturesFreeMembers;
|
|
273
|
+
|
|
261
274
|
WGPUProcSurfaceConfigure surfaceConfigure;
|
|
262
275
|
WGPUProcSurfaceGetCapabilities surfaceGetCapabilities;
|
|
263
276
|
WGPUProcSurfaceGetCurrentTexture surfaceGetCurrentTexture;
|
|
@@ -267,6 +280,12 @@ typedef struct DawnProcTable {
|
|
|
267
280
|
WGPUProcSurfaceAddRef surfaceAddRef;
|
|
268
281
|
WGPUProcSurfaceRelease surfaceRelease;
|
|
269
282
|
|
|
283
|
+
WGPUProcSurfaceCapabilitiesFreeMembers surfaceCapabilitiesFreeMembers;
|
|
284
|
+
|
|
285
|
+
WGPUProcTexelBufferViewSetLabel texelBufferViewSetLabel;
|
|
286
|
+
WGPUProcTexelBufferViewAddRef texelBufferViewAddRef;
|
|
287
|
+
WGPUProcTexelBufferViewRelease texelBufferViewRelease;
|
|
288
|
+
|
|
270
289
|
WGPUProcTextureCreateErrorView textureCreateErrorView;
|
|
271
290
|
WGPUProcTextureCreateView textureCreateView;
|
|
272
291
|
WGPUProcTextureDestroy textureDestroy;
|
|
@@ -278,7 +297,9 @@ typedef struct DawnProcTable {
|
|
|
278
297
|
WGPUProcTextureGetSampleCount textureGetSampleCount;
|
|
279
298
|
WGPUProcTextureGetUsage textureGetUsage;
|
|
280
299
|
WGPUProcTextureGetWidth textureGetWidth;
|
|
300
|
+
WGPUProcTexturePin texturePin;
|
|
281
301
|
WGPUProcTextureSetLabel textureSetLabel;
|
|
302
|
+
WGPUProcTextureUnpin textureUnpin;
|
|
282
303
|
WGPUProcTextureAddRef textureAddRef;
|
|
283
304
|
WGPUProcTextureRelease textureRelease;
|
|
284
305
|
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
#include <wrl/client.h>
|
|
33
33
|
|
|
34
34
|
#include <memory>
|
|
35
|
+
#include <optional>
|
|
35
36
|
|
|
36
37
|
#include "dawn/native/D3DBackend.h"
|
|
37
38
|
|
|
@@ -61,9 +62,14 @@ struct DAWN_NATIVE_EXPORT SharedTextureMemoryD3D11Texture2DDescriptor : wgpu::Ch
|
|
|
61
62
|
// If this flag is true, Dawn is required to signal a fence before EndAccess() and return it in
|
|
62
63
|
// SharedTextureMemoryEndAccessState's fences list.
|
|
63
64
|
// If it's false, no fence signaling is needed and EndAccess() might return empty fence list.
|
|
64
|
-
//
|
|
65
|
+
// Notes:
|
|
66
|
+
// - This flag is not relevant if the feature SharedFenceDXGISharedHandle is disabled/not
|
|
65
67
|
// supported.
|
|
66
|
-
|
|
68
|
+
// - This flag if present will override the requiresEndAccessFence flag in
|
|
69
|
+
// SharedTextureMemoryD3D11BeginState
|
|
70
|
+
// TODO(chromium:335003893): This flag is deprecated. Remove it once clients are updated to use
|
|
71
|
+
// SharedTextureMemoryD3D11BeginState's requiresEndAccessFence.
|
|
72
|
+
std::optional<bool> requiresEndAccessFence;
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
} // namespace dawn::native::d3d11
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
|
|
31
31
|
#include <dxgi1_4.h>
|
|
32
32
|
#include <webgpu/webgpu_cpp_chained_struct.h>
|
|
33
|
-
#include <windows.h>
|
|
34
33
|
#include <wrl/client.h>
|
|
35
34
|
|
|
36
35
|
#include <memory>
|
|
@@ -40,8 +39,6 @@
|
|
|
40
39
|
|
|
41
40
|
namespace dawn::native::d3d {
|
|
42
41
|
|
|
43
|
-
class ExternalImageDXGIImpl;
|
|
44
|
-
|
|
45
42
|
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<IDXGIAdapter> GetDXGIAdapter(WGPUAdapter adapter);
|
|
46
43
|
|
|
47
44
|
// Can be chained in WGPURequestAdapterOptions
|
|
@@ -340,6 +340,8 @@ DAWN_NATIVE_EXPORT MemoryUsageInfo ComputeEstimatedMemoryUsageInfo(WGPUDevice de
|
|
|
340
340
|
struct DAWN_NATIVE_EXPORT AllocatorMemoryInfo {
|
|
341
341
|
uint64_t totalUsedMemory = 0;
|
|
342
342
|
uint64_t totalAllocatedMemory = 0;
|
|
343
|
+
uint64_t totalLazyAllocatedMemory = 0;
|
|
344
|
+
uint64_t totalLazyUsedMemory = 0;
|
|
343
345
|
};
|
|
344
346
|
DAWN_NATIVE_EXPORT AllocatorMemoryInfo GetAllocatorMemoryInfo(WGPUDevice device);
|
|
345
347
|
|
|
@@ -352,6 +354,8 @@ DAWN_NATIVE_EXPORT bool ReduceMemoryUsage(WGPUDevice device);
|
|
|
352
354
|
// caches, etc.
|
|
353
355
|
DAWN_NATIVE_EXPORT void PerformIdleTasks(const wgpu::Device& device);
|
|
354
356
|
|
|
357
|
+
DAWN_NATIVE_EXPORT bool IsDeviceLost(WGPUDevice device);
|
|
358
|
+
|
|
355
359
|
} // namespace dawn::native
|
|
356
360
|
|
|
357
361
|
#endif // INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
|
|
@@ -99,8 +99,9 @@ class DAWN_PLATFORM_EXPORT WorkerTaskPool {
|
|
|
99
99
|
// in `namespace features`.
|
|
100
100
|
enum class Features {
|
|
101
101
|
kWebGPUUseDXC,
|
|
102
|
-
kWebGPUUseTintIR,
|
|
103
102
|
kWebGPUUseVulkanMemoryModel,
|
|
103
|
+
kWebGPUEnableRangeAnalysisForRobustness,
|
|
104
|
+
kWebGPUUseSpirv14,
|
|
104
105
|
};
|
|
105
106
|
|
|
106
107
|
class DAWN_PLATFORM_EXPORT Platform {
|