You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gives you the flexibility of using parts of a single transformation without the performance penalty, resulting in much much _MUCH_ faster operation.
347
413
348
414
## Adding custom functions
349
-
Do you have a custom function you'd like to use on the gpu? Although limited, you can:
415
+
use `gpu.addFunction(function() {}, options)` for adding custom functions. Example:
416
+
417
+
350
418
```js
351
419
gpu.addFunction(functionmySuperFunction(a, b) {
352
420
return a - b;
@@ -360,6 +428,31 @@ const kernel = gpu.createKernel(function(a, b) {
360
428
}).setOutput([20]);
361
429
```
362
430
431
+
### Adding strongly typed functions
432
+
433
+
To strongly type a function you may use options. Options take an optional hash values:
434
+
`returnType`: optional, defaults to float, the value you'd like to return from the function
435
+
`paramTypes`: optional, defaults to float for each param, a hash of param names with values of the return types
436
+
437
+
Types: that may be used for `returnType` or for each property of `paramTypes`:
0 commit comments