Skip to content

Getting Started

Install the public core package:

Terminal window
pnpm add @volten/core

You can also use another package manager:

Terminal window
npm install @volten/core
yarn add @volten/core
bun add @volten/core

This example creates one GPU buffer, multiplies each value by a uniform, and reads the result back.

If the result contains [10, 20, 30, 40], Volten is working in your environment.

import { volten, Buffer, Kernel, Uniform } from '@volten/core';
const v = await volten();
const inout = new Buffer([1, 2, 3, 4], 'f32', 'rw');
const mult = new Uniform(10, 'f32');
const kernel = new Kernel(`
fn main(gid: vec3u) {
inout[gid.x] = inout[gid.x] * mult;
}
`);
const node = v.pass(kernel, { inout, mult });
v.run(node);
console.log(await v.read(inout));
// Float32Array [10, 20, 30, 40]

Volten needs WebGPU, and in a browser, that means navigator.gpu must be available.