mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
18 lines
427 B
JavaScript
18 lines
427 B
JavaScript
const { GPU } = require('../src');
|
|
|
|
const gpu = new GPU({ mode: 'gpu' });
|
|
|
|
// Look ma! I can typescript on my GPU!
|
|
function kernelFunction(anInt, anArray, aNestedArray) {
|
|
const x = .25 + anInt + anArray[this.thread.x] + aNestedArray[this.thread.x][this.thread.y];
|
|
return x;
|
|
};
|
|
|
|
const kernel = gpu.createKernel(kernelFunction, {
|
|
output: [1]
|
|
});
|
|
|
|
const result = kernel(1.25, [.25], [[1.25]]);
|
|
|
|
console.log(result[0]); // 3
|