software-mansion/TypeGPU

A modular and open-ended toolkit for WebGPU, with advanced type inference and the ability to write shaders in TypeScript

What it solves

TypeGPU simplifies the development of WebGPU applications by providing a type-safe toolkit that allows developers to write shaders in TypeScript instead of the standard WebGPU Shading Language (WGSL). It removes common hurdles associated with WebGPU, such as complex data serialization, manual WGSL generation, and the lack of type inference for GPU buffers.

How it works

TypeGPU mirrors the WGSL syntax within TypeScript. It uses a modular abstraction layer that can generate WGSL code from TypeScript functions (marked with 'use gpu') and execute them on the GPU. It also provides a type-safe API for managing GPU buffers and resources, allowing developers to pass typed values between different libraries without copying data back to the CPU.

Who it’s for

  • WebGPU Developers: Those looking to reduce friction and leverage TypeScript's type system for GPU programming.
  • Library Authors: Developers creating WebGPU-based libraries who need a standardized, type-safe interoperability layer to ensure their tools can work together seamlessly.

Highlights

  • TypeScript Shaders: Write GPU logic directly in TypeScript with advanced type inference.
  • Zero Lock-in: Ability to granularly eject into vanilla WebGPU at any point.
  • Interoperability Layer: Enables different WebGPU libraries to share typed buffers without CPU-side copying.
  • Modular Design: APIs can be used together or in isolation for partial integration into existing apps.

Related

  • Project
  • Project
  • Project
  • Project
  • Project