@@ -225,15 +225,15 @@ Sometimes you want to do multiple math operations on the gpu without the round t
225
225
_ ** Note:** _ Kernels can have different output sizes.
226
226
``` js
227
227
const add = gpu .createKernel (function (a , b ) {
228
- return a[ this . thread . x ] + b[ this . thread . x ] ;
228
+ return a + b;
229
229
}).setOutput ([20 ]);
230
230
231
231
const multiply = gpu .createKernel (function (a , b ) {
232
- return a[ this . thread . x ] * b[ this . thread . x ] ;
232
+ return a * b;
233
233
}).setOutput ([20 ]);
234
234
235
235
const superKernel = gpu .combineKernels (add, multiply, function (a , b , c ) {
236
- return multiply (add (a, b), c);
236
+ return multiply (add (a[ this . thread . x ] , b[ this . thread . x ] ), c[ this . thread . x ] );
237
237
});
238
238
239
239
superKernel (a, b, c);
@@ -248,13 +248,13 @@ Sometimes you want to do multiple math operations in one kernel, and save the ou
248
248
``` js
249
249
const megaKernel = gpu .createKernelMap ({
250
250
addResult : function add (a , b ) {
251
- return a[ this . thread . x ] + b[ this . thread . x ] ;
251
+ return a + b;
252
252
},
253
253
multiplyResult : function multiply (a , b ) {
254
- return a[ this . thread . x ] * b[ this . thread . x ] ;
254
+ return a * b;
255
255
},
256
256
}, function (a , b , c ) {
257
- return multiply (add (a, b), c);
257
+ return multiply (add (a[ this . thread . x ] , b[ this . thread . x ] ), c[ this . thread . x ] );
258
258
});
259
259
260
260
megaKernel (a, b, c);
@@ -264,13 +264,13 @@ megaKernel(a, b, c);
264
264
``` js
265
265
const megaKernel = gpu .createKernelMap ([
266
266
function add (a , b ) {
267
- return a[ this . thread . x ] + b[ this . thread . x ] ;
267
+ return a + b;
268
268
},
269
269
function multiply (a , b ) {
270
- return a[ this . thread . x ] * b[ this . thread . x ] ;
270
+ return a * b;
271
271
}
272
272
], function (a , b , c ) {
273
- return multiply (add (a, b), c);
273
+ return multiply (add (a[ this . thread . x ] , b[ this . thread . x ] ), c[ this . thread . x ] );
274
274
});
275
275
276
276
megaKernel (a, b, c);
0 commit comments