mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
Cleanup and add random support (seeded by... Math.random()!) I went through api and cleaned it up considerably
18 lines
422 B
JavaScript
18 lines
422 B
JavaScript
const { GPU } = require('../src');
|
|
|
|
const gpu = new GPU({ mode: 'gpu' });
|
|
|
|
// Look ma! I can javascript 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], [[1.5]]);
|
|
|
|
console.log(result[0]); // 3
|