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
Copy file name to clipboardExpand all lines: README.md
+33-4Lines changed: 33 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,8 +230,8 @@ Settings are an object used to create a `kernel` or `kernelMap`. Example: `gpu.
230
230
*`optimizeFloatMemory` or `kernel.setOptimizeFloatMemory(boolean)`**New in V2!**: boolean - causes a float32 texture to use all 4 channels rather than 1, using less memory, but consuming more GPU.
231
231
*`precision` or `kernel.setPrecision('unsigned' | 'single')`**New in V2!**: 'single' or 'unsigned' - if 'single' output texture uses float32 for each colour channel rather than 8
232
232
*`fixIntegerDivisionAccuracy` or `kernel.setFixIntegerDivisionAccuracy(boolean)` : boolean - some cards have accuracy issues dividing by factors of three and some other primes (most apple kit?). Default on for affected cards, disable if accuracy not required.
233
-
*`functions` or `kernel.setFunctions(object)`: array, array of functions to be used inside kernel. If undefined, inherits from `GPU` instance.
234
-
*`nativeFunctions` or `kernel.setNativeFunctions(object)`: object, defined as: `{ name: string, source: string, settings: object }`. This is generally set via using GPU.addNativeFunction()
233
+
*`functions` or `kernel.setFunctions(array)`: array, array of functions to be used inside kernel. If undefined, inherits from `GPU` instance. Can also be an array of `{ source: function, argumentTypes: object, returnType: string }`.
234
+
*`nativeFunctions` or `kernel.setNativeFunctions(array)`: object, defined as: `{ name: string, source: string, settings: object }`. This is generally set via using GPU.addNativeFunction()
235
235
* VERY IMPORTANT! - Use this to add special native functions to your environment when you need specific functionality is needed.
236
236
*`injectedNative` or `kernel.setInjectedNative(string)`**New in V2!**: string, defined as: `{ functionName: functionSource }`. This is for injecting native code before translated kernel functions.
237
237
*`subKernels` or `kernel.setSubKernels(array)`: array, generally inherited from `GPU` instance.
@@ -667,7 +667,8 @@ megaKernel(a, b, c);
667
667
This gives you the flexibility of using parts of a single transformation without the performance penalty, resulting in much much _MUCH_ faster operation.
668
668
669
669
## Adding custom functions
670
-
use `gpu.addFunction(function() {}, settings)`for adding custom functions. Example:
670
+
### To `GPU` instance
671
+
use `gpu.addFunction(function() {}, settings)`for adding custom functions to all kernels. Example:
671
672
672
673
673
674
```js
@@ -683,6 +684,23 @@ const kernel = gpu.createKernel(function(a, b) {
683
684
}).setOutput([20]);
684
685
```
685
686
687
+
### To `Kernel` instance
688
+
use `kernel.addFunction(function() {}, settings)`for adding custom functions to all kernels. Example:
689
+
690
+
691
+
```js
692
+
kernel.addFunction(function mySuperFunction(a, b) {
0 commit comments