react-native-wgpu 0.1.18 → 0.1.20

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 (63) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/cpp/AndroidPlatformContext.h +1 -1
  3. package/android/src/main/java/com/webgpu/WebGPUAHBView.java +41 -33
  4. package/android/src/main/java/com/webgpu/{SurfaceView2.java → WebGPUSurfaceViewWithSC.java} +3 -3
  5. package/android/src/main/java/com/webgpu/WebGPUView.java +15 -42
  6. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +3 -3
  7. package/android/src/oldarch/com/webgpu/WebGPUViewManagerSpec.java +1 -1
  8. package/apple/ApplePlatformContext.mm +11 -3
  9. package/apple/MetalView.h +2 -2
  10. package/apple/MetalView.mm +12 -0
  11. package/apple/RNWGUIKit.h +11 -0
  12. package/apple/WebGPUModule.mm +3 -12
  13. package/apple/WebGPUViewManager.mm +3 -2
  14. package/cpp/dawn/dawn_proc.h +50 -0
  15. package/cpp/dawn/dawn_proc_table.h +300 -0
  16. package/cpp/dawn/dawn_thread_dispatch_proc.h +47 -0
  17. package/cpp/dawn/native/D3D11Backend.h +64 -0
  18. package/cpp/dawn/native/D3D12Backend.h +68 -0
  19. package/cpp/dawn/native/D3DBackend.h +59 -0
  20. package/cpp/dawn/native/DawnNative.h +313 -0
  21. package/cpp/dawn/native/MetalBackend.h +55 -0
  22. package/cpp/dawn/native/NullBackend.h +39 -0
  23. package/cpp/dawn/native/OpenGLBackend.h +82 -0
  24. package/cpp/dawn/native/VulkanBackend.h +183 -0
  25. package/cpp/dawn/native/dawn_native_export.h +49 -0
  26. package/cpp/dawn/platform/DawnPlatform.h +165 -0
  27. package/cpp/dawn/platform/dawn_platform_export.h +49 -0
  28. package/cpp/dawn/webgpu_cpp_print.h +2484 -0
  29. package/cpp/rnwgpu/api/GPU.h +1 -1
  30. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +4 -0
  31. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -16
  32. package/cpp/webgpu/webgpu_glfw.h +71 -0
  33. package/lib/commonjs/Canvas.js +2 -5
  34. package/lib/commonjs/Canvas.js.map +1 -1
  35. package/lib/module/Canvas.js +2 -5
  36. package/lib/module/Canvas.js.map +1 -1
  37. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  38. package/lib/typescript/src/Canvas.d.ts +1 -2
  39. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  40. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -2
  41. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  42. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  43. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  44. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  45. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  46. package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  47. package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  48. package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
  49. package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
  50. package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
  51. package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
  52. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  53. package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  54. package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
  55. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
  56. package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
  57. package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
  58. package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  59. package/package.json +2 -1
  60. package/react-native-wgpu.podspec +1 -1
  61. package/src/Canvas.tsx +51 -65
  62. package/src/WebGPUViewNativeComponent.ts +2 -2
  63. package/cpp/rnwgpu/api/WebGPUCanvasContextFactory.h +0 -59
@@ -47,7 +47,7 @@ static def findNodeModules(baseDir) {
47
47
  basePath = basePath.getParent()
48
48
  }
49
49
 
50
- throw new GradleException("react-native-filament: Failed to find node_modules/ path!")
50
+ throw new GradleException("react-native-wgpu: Failed to find node_modules/ path!")
51
51
  }
52
52
 
53
53
  def nodeModules = findNodeModules(projectDir)
@@ -34,7 +34,7 @@ public:
34
34
 
35
35
  wgpu::Surface makeSurface(wgpu::Instance instance, void *window, int width,
36
36
  int height) override {
37
- wgpu::SurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc;
37
+ wgpu::SurfaceSourceAndroidNativeWindow androidSurfaceDesc;
38
38
  androidSurfaceDesc.window = reinterpret_cast<ANativeWindow *>(window);
39
39
  wgpu::SurfaceDescriptor surfaceDescriptor;
40
40
  surfaceDescriptor.nextInChain = &androidSurfaceDesc;
@@ -15,14 +15,12 @@ import android.view.View;
15
15
  import androidx.annotation.NonNull;
16
16
  import androidx.annotation.RequiresApi;
17
17
 
18
- import java.util.LinkedList;
19
- import java.util.Queue;
20
-
21
18
  @SuppressLint("ViewConstructor")
22
19
  @RequiresApi(api = Build.VERSION_CODES.Q)
23
- public class WebGPUAHBView extends View {
20
+ public class WebGPUAHBView extends View implements ImageReader.OnImageAvailableListener {
21
+
22
+ private ImageReader mReader;
24
23
 
25
- private final Queue<ImageReader> mImageReaders = new LinkedList<>();
26
24
  private Bitmap mBitmap = null;
27
25
 
28
26
  private final Matrix matrix = new Matrix();
@@ -34,48 +32,58 @@ public class WebGPUAHBView extends View {
34
32
  mApi = api;
35
33
  }
36
34
 
35
+ private ImageReader createReader() {
36
+ ImageReader reader = ImageReader.newInstance(getWidth(), getHeight(), PixelFormat.RGBA_8888, 2, HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE |
37
+ HardwareBuffer.USAGE_GPU_COLOR_OUTPUT);
38
+ reader.setOnImageAvailableListener(this, null);
39
+ return reader;
40
+ }
41
+
37
42
  @Override
38
43
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
39
44
  super.onLayout(changed, left, top, right, bottom);
40
- long usage = HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE |
41
- HardwareBuffer.USAGE_GPU_COLOR_OUTPUT;
42
- ImageReader imageReader = ImageReader.newInstance(getWidth(), getHeight(), PixelFormat.RGBA_8888, 2, usage);
43
- if (mImageReaders.isEmpty()) {
44
- mApi.surfaceCreated(imageReader.getSurface());
45
+ if (mReader == null) {
46
+ mReader = createReader();
47
+ mApi.surfaceCreated(mReader.getSurface());
45
48
  } else {
46
- mApi.surfaceChanged(imageReader.getSurface());
49
+ mApi.surfaceChanged(mReader.getSurface());
47
50
  }
48
- imageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
49
- @Override
50
- public void onImageAvailable(ImageReader reader) {
51
- try (Image image = reader.acquireLatestImage()) {
52
- if (image != null) {
53
- HardwareBuffer hb = image.getHardwareBuffer();
54
- if (hb != null) {
55
- Bitmap bitmap = Bitmap.wrapHardwareBuffer(hb, null);
56
- if (bitmap != null) {
57
- mBitmap = bitmap;
58
- hb.close();
59
- invalidate();
60
- ImageReader imageReader = mImageReaders.poll();
61
- ImageReader ir;
62
- while((ir = mImageReaders.poll()) != null) {
63
- ir.close();
64
- }
65
- mImageReaders.add(imageReader);
66
- }
67
- }
51
+ }
52
+
53
+ @Override
54
+ public void onImageAvailable(ImageReader reader) {
55
+ try (Image image = reader.acquireLatestImage()) {
56
+ if (image != null) {
57
+ HardwareBuffer hb = image.getHardwareBuffer();
58
+ if (hb != null) {
59
+ Bitmap bitmap = Bitmap.wrapHardwareBuffer(hb, null);
60
+ if (bitmap != null) {
61
+ mBitmap = bitmap;
62
+ hb.close();
63
+ invalidate();
68
64
  }
69
65
  }
70
66
  }
71
- }, null);
72
- mImageReaders.add(imageReader);
67
+ }
73
68
  }
74
69
 
75
70
  @Override
76
71
  protected void onDraw(@NonNull Canvas canvas) {
77
72
  super.onDraw(canvas);
78
73
  if (mBitmap != null) {
74
+ float viewWidth = getWidth();
75
+ float viewHeight = getHeight();
76
+ float bitmapWidth = mBitmap.getWidth();
77
+ float bitmapHeight = mBitmap.getHeight();
78
+
79
+ // Calculate the scale factors
80
+ float scaleX = viewWidth / bitmapWidth;
81
+ float scaleY = viewHeight / bitmapHeight;
82
+
83
+ // Reset the matrix and apply scaling
84
+ matrix.reset();
85
+ matrix.setScale(scaleX, scaleY);
86
+
79
87
  canvas.drawBitmap(mBitmap, matrix, null);
80
88
  }
81
89
  }
@@ -15,13 +15,13 @@ import androidx.annotation.RequiresApi;
15
15
 
16
16
  @SuppressLint("ViewConstructor")
17
17
  @RequiresApi(api = Build.VERSION_CODES.Q)
18
- public class SurfaceView2 extends SurfaceView implements SurfaceHolder.Callback {
18
+ public class WebGPUSurfaceViewWithSC extends SurfaceView implements SurfaceHolder.Callback {
19
19
 
20
20
  WebGPUAPI mApi;
21
21
  SurfaceControl mSurfaceControl;
22
22
  Surface mSurface;
23
23
 
24
- public SurfaceView2(Context context, WebGPUAPI api) {
24
+ public WebGPUSurfaceViewWithSC(Context context, WebGPUAPI api) {
25
25
  super(context);
26
26
  mApi = api;
27
27
  getHolder().addCallback(this);
@@ -48,7 +48,7 @@ public class SurfaceView2 extends SurfaceView implements SurfaceHolder.Callback
48
48
  } else {
49
49
  SurfaceControl.Builder scb = new SurfaceControl.Builder();
50
50
  scb.setName("WebGPUView");
51
- scb.setOpaque(false);
51
+ scb.setOpaque(true);
52
52
  scb.setBufferSize(getWidth(), getHeight());
53
53
  scb.setParent(getSurfaceControl());
54
54
  scb.setFormat(PixelFormat.RGBA_8888);
@@ -5,37 +5,17 @@ import android.os.Build;
5
5
  import android.view.Surface;
6
6
  import android.view.View;
7
7
 
8
- import androidx.annotation.NonNull;
9
- import androidx.annotation.Nullable;
10
- import androidx.annotation.StringDef;
11
-
12
8
  import com.facebook.proguard.annotations.DoNotStrip;
13
9
  import com.facebook.react.uimanager.ThemedReactContext;
14
10
  import com.facebook.react.views.view.ReactViewGroup;
15
11
 
16
- import java.lang.annotation.Retention;
17
- import java.lang.annotation.RetentionPolicy;
18
-
19
12
  public class WebGPUView extends ReactViewGroup implements WebGPUAPI {
20
13
 
21
- public static final String SURFACE_VIEW = "SurfaceView";
22
- public static final String TEXTURE_VIEW = "TextureView";
23
- public static final String HARDWARE_BUFFER = "HardwareBuffer";
24
- public static final String SURFACE_VIEW2 = "SurfaceView2";
25
-
26
- @Retention(RetentionPolicy.SOURCE)
27
- @StringDef({
28
- SURFACE_VIEW,
29
- TEXTURE_VIEW,
30
- HARDWARE_BUFFER,
31
- SURFACE_VIEW2
32
- })
33
- public @interface ViewType {}
34
14
 
35
15
  private int mContextId;
36
- private @ViewType String mName = null;
16
+ private boolean mTransparent = false;
37
17
  private WebGPUModule mModule;
38
- private View mView;
18
+ private View mView = null;
39
19
 
40
20
  WebGPUView(Context context) {
41
21
  super(context);
@@ -51,28 +31,21 @@ public class WebGPUView extends ReactViewGroup implements WebGPUAPI {
51
31
  mContextId = contextId;
52
32
  }
53
33
 
54
- public void setView(@NonNull @ViewType String name) {
34
+ public void setTransparent(boolean value) {
55
35
  Context ctx = getContext();
56
- if (mName == null || !mName.equals(name)) {
57
- removeView(mView);
58
- mName = name;
59
- switch (name) {
60
- case TEXTURE_VIEW -> mView = new WebGPUTextureView(ctx, this);
61
- case HARDWARE_BUFFER -> {
62
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
63
- mView = new WebGPUAHBView(ctx, this);
64
- } else {
65
- throw new RuntimeException("HardwareBuffer Canvas implementation is only available on API Level 29 and above");
66
- }
67
- }
68
- case SURFACE_VIEW2 -> {
69
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
70
- mView = new SurfaceView2(ctx, this);
71
- } else {
72
- throw new RuntimeException("HardwareBuffer Canvas implementation is only available on API Level 29 and above");
73
- }
36
+ if (value != mTransparent || mView == null) {
37
+ if (mView != null) {
38
+ removeView(mView);
39
+ }
40
+ mTransparent = value;
41
+ if (mTransparent) {
42
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
43
+ mView = new WebGPUAHBView(ctx, this);
44
+ } else {
45
+ mView = new WebGPUTextureView(ctx, this);
74
46
  }
75
- default -> mView = new WebGPUSurfaceView(ctx, this);
47
+ } else {
48
+ mView = new WebGPUSurfaceView(ctx, this);
76
49
  }
77
50
  addView(mView);
78
51
  }
@@ -25,9 +25,9 @@ public class WebGPUViewManager extends WebGPUViewManagerSpec<WebGPUView> {
25
25
  }
26
26
 
27
27
  @Override
28
- @ReactProp(name = "androidView")
29
- public void setAndroidView(WebGPUView view, @Nullable String value) {
30
- view.setView(value == null ? WebGPUView.SURFACE_VIEW : value);
28
+ @ReactProp(name = "transparent")
29
+ public void setTransparent(WebGPUView view, boolean value) {
30
+ view.setTransparent(value);
31
31
  }
32
32
 
33
33
  @Override
@@ -8,5 +8,5 @@ import com.facebook.react.uimanager.SimpleViewManager;
8
8
 
9
9
  public abstract class WebGPUViewManagerSpec<T extends View> extends SimpleViewManager<T> {
10
10
  public abstract void setContextId(T view, int contextId);
11
- public abstract void setAndroidView(T view, @Nullable String name);
11
+ public abstract void setTransparent(T view, boolean transparency);
12
12
  }
@@ -11,7 +11,7 @@
11
11
 
12
12
  namespace rnwgpu {
13
13
 
14
- void isSimulatorWithAPIValidation() {
14
+ void checkIfUsingSimulatorWithAPIValidation() {
15
15
  #if TARGET_OS_SIMULATOR
16
16
  NSDictionary *environment = [[NSProcessInfo processInfo] environment];
17
17
  NSString *metalDeviceWrapperType = environment[@"METAL_DEVICE_WRAPPER_TYPE"];
@@ -25,12 +25,12 @@ void isSimulatorWithAPIValidation() {
25
25
  #endif
26
26
  }
27
27
 
28
- ApplePlatformContext::ApplePlatformContext() { isSimulatorWithAPIValidation(); }
28
+ ApplePlatformContext::ApplePlatformContext() { checkIfUsingSimulatorWithAPIValidation(); }
29
29
 
30
30
  wgpu::Surface ApplePlatformContext::makeSurface(wgpu::Instance instance,
31
31
  void *surface, int width,
32
32
  int height) {
33
- wgpu::SurfaceDescriptorFromMetalLayer metalSurfaceDesc;
33
+ wgpu::SurfaceSourceMetalLayer metalSurfaceDesc;
34
34
  metalSurfaceDesc.layer = surface;
35
35
  wgpu::SurfaceDescriptor surfaceDescriptor;
36
36
  surfaceDescriptor.nextInChain = &metalSurfaceDesc;
@@ -50,12 +50,20 @@ ImageData ApplePlatformContext::createImageBitmap(std::string blobId,
50
50
  throw std::runtime_error("Couldn't retrive blob data");
51
51
  }
52
52
 
53
+ #if !TARGET_OS_OSX
53
54
  UIImage *image = [UIImage imageWithData:blobData];
55
+ #else
56
+ NSImage *image = [[NSImage alloc] initWithData:blobData];
57
+ #endif
54
58
  if (!image) {
55
59
  throw std::runtime_error("Couldn't decode image");
56
60
  }
57
61
 
62
+ #if !TARGET_OS_OSX
58
63
  CGImageRef cgImage = image.CGImage;
64
+ #else
65
+ CGImageRef cgImage = [image CGImageForProposedRect:NULL context:NULL hints:NULL];
66
+ #endif
59
67
  size_t width = CGImageGetWidth(cgImage);
60
68
  size_t height = CGImageGetHeight(cgImage);
61
69
  size_t bitsPerComponent = 8;
package/apple/MetalView.h CHANGED
@@ -1,9 +1,9 @@
1
1
  #pragma once
2
2
 
3
3
  #import "WebGPUModule.h"
4
- #import <UIKit/UIKit.h>
4
+ #import "RNWGUIKit.h"
5
5
 
6
- @interface MetalView : UIView
6
+ @interface MetalView : RNWGPlatformView
7
7
 
8
8
  @property NSNumber *contextId;
9
9
 
@@ -9,9 +9,21 @@
9
9
  BOOL _isConfigured;
10
10
  }
11
11
 
12
+ #if !TARGET_OS_OSX
12
13
  + (Class)layerClass {
13
14
  return [CAMetalLayer class];
14
15
  }
16
+ #else // !TARGET_OS_OSX
17
+ - (instancetype)init
18
+ {
19
+ self = [super init];
20
+ if (self) {
21
+ self.wantsLayer = true;
22
+ self.layer = [CAMetalLayer layer];
23
+ }
24
+ return self;
25
+ }
26
+ #endif // !TARGET_OS_OSX
15
27
 
16
28
  - (void)configure {
17
29
  auto size = self.frame.size;
@@ -0,0 +1,11 @@
1
+ #if !TARGET_OS_OSX
2
+ #import <UIKit/UIKit.h>
3
+ #else
4
+ #import <Appkit/Appkit.h>
5
+ #endif
6
+
7
+ #if !TARGET_OS_OSX
8
+ typedef UIView RNWGPlatformView;
9
+ #else
10
+ typedef NSView RNWGPlatformView;
11
+ #endif
@@ -46,19 +46,19 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
46
46
  }
47
47
  RCTCxxBridge *cxxBridge = (RCTCxxBridge *)[RCTBridge currentBridge];
48
48
  if (!cxxBridge.runtime) {
49
- NSLog(@"Failed to install react-native-filament: RCTBridge is not a "
49
+ NSLog(@"Failed to install react-native-wgpu: RCTBridge is not a "
50
50
  @"RCTCxxBridge!");
51
51
  return [NSNumber numberWithBool:NO];
52
52
  }
53
53
 
54
54
  jsi::Runtime *runtime = (jsi::Runtime *)cxxBridge.runtime;
55
55
  if (!runtime) {
56
- NSLog(@"Failed to install react-native-filament: jsi::Runtime* was null!");
56
+ NSLog(@"Failed to install react-native-wgpu: jsi::Runtime* was null!");
57
57
  return [NSNumber numberWithBool:NO];
58
58
  }
59
59
  std::shared_ptr<react::CallInvoker> jsInvoker = cxxBridge.jsCallInvoker;
60
60
  if (!jsInvoker) {
61
- NSLog(@"Failed to install react-native-filament: react::CallInvoker was "
61
+ NSLog(@"Failed to install react-native-wgpu: react::CallInvoker was "
62
62
  @"null!");
63
63
  return [NSNumber numberWithBool:NO];
64
64
  }
@@ -74,15 +74,6 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
74
74
  return @true;
75
75
  }
76
76
 
77
- // RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createSurfaceContext
78
- // : (double)contextId) {
79
- // int contextIdInt = contextId;
80
- // RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
81
- // auto runtime = (jsi::Runtime *)cxxBridge.runtime;
82
-
83
- // return @true;
84
- // }
85
-
86
77
  #ifdef RCT_NEW_ARCH_ENABLED
87
78
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
88
79
  (const facebook::react::ObjCTurboModule::InitParams &)params {
@@ -1,5 +1,6 @@
1
1
  #import "MetalView.h"
2
2
  #import "RCTBridge.h"
3
+ #import "RNWGUIKit.h"
3
4
  #import "WebGPUModule.h"
4
5
  #import <React/RCTUIManager.h>
5
6
  #import <React/RCTViewManager.h>
@@ -11,11 +12,11 @@
11
12
 
12
13
  RCT_EXPORT_MODULE(WebGPUView)
13
14
 
14
- - (UIView *)view {
15
+ - (RNWGPlatformView *)view {
15
16
  return [MetalView new];
16
17
  }
17
18
 
18
- RCT_CUSTOM_VIEW_PROPERTY(contextId, NSNumber, UIView) {
19
+ RCT_CUSTOM_VIEW_PROPERTY(contextId, NSNumber, RNWGPlatformView) {
19
20
  NSNumber *contextId = [RCTConvert NSNumber:json];
20
21
  [(MetalView *)view setContextId:contextId];
21
22
  }
@@ -0,0 +1,50 @@
1
+ // Copyright 2019 The Dawn & Tint Authors
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without
4
+ // modification, are permitted provided that the following conditions are met:
5
+ //
6
+ // 1. Redistributions of source code must retain the above copyright notice, this
7
+ // list of conditions and the following disclaimer.
8
+ //
9
+ // 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ // this list of conditions and the following disclaimer in the documentation
11
+ // and/or other materials provided with the distribution.
12
+ //
13
+ // 3. Neither the name of the copyright holder nor the names of its
14
+ // contributors may be used to endorse or promote products derived from
15
+ // this software without specific prior written permission.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef INCLUDE_DAWN_DAWN_PROC_H_
29
+ #define INCLUDE_DAWN_DAWN_PROC_H_
30
+
31
+ #include <webgpu/webgpu.h>
32
+
33
+ #include "dawn/dawn_proc_table.h"
34
+
35
+ #ifdef __cplusplus
36
+ extern "C" {
37
+ #endif
38
+
39
+ // Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL
40
+ // for `procs` sets up the null proctable that contains only null function pointers. It is the
41
+ // default value of the proctable. Setting the proctable back to null is good practice when you
42
+ // are done using libdawn_proc since further usage will cause a segfault instead of calling an
43
+ // unexpected function.
44
+ WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
45
+
46
+ #ifdef __cplusplus
47
+ } // extern "C"
48
+ #endif
49
+
50
+ #endif // INCLUDE_DAWN_DAWN_PROC_H_