installWebGPU
Install WebGPU flag constants on a worklet runtime.
On a worklet runtime, the WebGPU constants are not available by default.
Call installWebGPU() once at the top of a worklet to install the needed globals for that runtime.
On the main JS thread these are already installed when the native module loads; calling installWebGPU() there is a safe no-op.
Usage
UI thread worklet
import { } from "react-native-webgpu";
import { } from "react-native-worklets";
const = (
: GPUDevice,
: ,
: GPURenderPipeline,
) => {
"worklet";
();
const = .();
const = .({
: [{
: .().(),
: [0, 0, 0, 1],
: "clear",
: "store",
}],
});
.();
.(3);
.();
..([.()]);
.();
};
// Create device on the main thread, pass handles to the worklet
()(, , );Dedicated worklet runtime
import { , } from "react-native-worklets";
import { } from "react-native-webgpu";
const = ({ : "gpu" });
const = (: GPUDevice) => {
"worklet";
();
const = .({
: 256,
: . | .,
});
// …
};
(, )();