Skip to content

Start5 of 5

Platforms

Browser and React Native requirements for running TypeGPU Kit.

On this page

The kit requires core WebGPU. The kit’s can read vertices from in the vertex stage. A compatibility-mode device can have a limit of zero for those buffers. A uses up to three of the four , as its limits say.

Use a browser with WebGPU enabled. WebGPU requires HTTPS outside localhost.

Safari compiles pipelines one at a time and builds Metal state at the first draw or . Compile the pipelines under a loading screen with initAsync or pipelines.compile. Then draw behind the loading screen until frame times settle. Wrap vec3 uniforms in structs to avoid Metal packing errors.

Reuse texture views and bind groups across frames because Firefox retains them until garbage collection.

Use react-native-webgpu. Setting up a project gives the versions, and the Babel, Metro and configuration for hosted scenes.

  • Hermes lacks Array.prototype.toSorted. Copy an array before sorting it.
  • Each draw costs JavaScript time on Hermes, so use fewer, larger draws. Set the pipeline on the pass once with pass.setPipeline(pipeline) and draw through the pass.
  • Import kit subpaths, such as @typegpu/kit/frames, since Metro keeps every file it reaches.
  • Pause GPU work while the app is in the background.
  • A device used across threads requires implicit-device-synchronization. react-native-webgpu requests it for every device unless you pass implicitDeviceSynchronization: false. A that runs its scene off the JS thread throws for a device without it.

that use firstInstance require the indirect-first-instance feature. Request it, and check device.features.has after creating the device. Live lists with firstInstance: true throw without it. Direct draws need no feature.

Shadow maps use comparison . On pre-A9 GPUs and the iOS simulator, they need Dawn built for iOS 16 or later. For an older deployment target, use textureGather and compare depth in the shader.

rendererA renderer draws one sort of thing, such as instances or particles, by handing a pass description a drawing.Every renderer is a drawing →
storage bufferA storage buffer is GPU memory that shaders read by index and kernels can write, which is where the kit keeps rows.Words →
pass descriptionA pass description says once which textures a pass draws into and what each holds, and builds the pipeline for every drawing added to it.Scenes and passes →
bind groupA bind group is a set of buffers, textures and samplers that a pipeline reads, and a pipeline has room for four.Words →
dispatchA dispatch runs a kernel once over a number of threads, inside a compute pass.Words →
frameA frame is one turn of the loop, and the object your function gets for it, which holds the encoder, the time and the time since the last frame.You own the frame →
workletA worklet is a function that react-native-worklets can run on a thread other than the main JavaScript thread.Words →
hostA host runs a scene for you, which means it makes the device, the surface and the frame loop and frees them in order.Hosting scenes →
indirect drawAn indirect draw reads how much to draw from a buffer, so a kernel can decide the count and the CPU never reads it.Indirect draws →
samplerA sampler tells the GPU how to read a texture between its texels and past its edges, such as smoothly or in blocks.Words →