It's hard for frontend engineers to write compute shaders in GPGPU scenarios. So we create a TypeScript-liked language in our GWebGPU project.
For more information, refer to our docs: https://gwebgpu.antv.vision/zh/docs/api/syntax.
It's an example to add 2 vectors writing with our syntax.
@numthreads(8, 1, 1)
class Add2Vectors {
@in @out
vectorA: float[];
@in
vectorB: float[];
sum(a: float, b: float): float {
return a + b;
}
@main
compute() {
const a = this.vectorA[globalInvocationID.x];
const b = this.vectorB[globalInvocationID.x];
this.vectorA[globalInvocationID.x] = this.sum(a, b);
}
}
- syntax highlight with TextMate grammars
- syntax highlight with TextMate grammars