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
feat: Added features and fixes for the following issues:
...it kind of snowballed from some needs
Fixes#521 - If `tactic` is not set, check precision allowed from WebGL, and automatically change based off needs, otherwise use value from `tactic`.
Fixes#535 - Internally check if texture from argument is the same as output, if so, clone this texture, and then clean it up after the kernel runs.
Fixes#536 - Normalize all declarations to non-destructured, and then parse
Fixes#537 - Change logic
Fixes#538 - Found the GL script that would work, and reduced the methods to use it
Fixes#539 - Found a better way of testing random, and this gives me an error for 1 in 10 runs, acceptable
Some refactoring for less duplicate code and documentation
@@ -207,7 +208,7 @@ Settings are an object used to create a `kernel` or `kernelMap`. Example: `gpu.
207
208
*`strictIntegers` or `kernel.setStrictIntegers(boolean)`: boolean, default = `false` - allows undefined argumentTypes and function return values to use strict integer declarations.
208
209
*`useLegacyEncoder` or `kernel.setUseLegacyEncoder(boolean)`: boolean, default `false` - more info [here](https://github.com/gpujs/gpu.js/wiki/Encoder-details).
209
210
*`warnVarUsage` or `kernel.setWarnVarUsage(boolean)`: turn off var usage warnings, they can be irritating, and in transpiled environments, there is nothing we can do about it.
210
-
*`tactic` or `kernel.setTactic('speed' | 'balanced' | 'performance')`**New in V2!**: Set the kernel's tactic for compilation. Allows for compilation to better fit how GPU.js is being used (internally uses `lowp` for 'speed', `mediump` for 'balanced', and `highp` for 'precision'). Default is 'balanced'.
211
+
*`tactic` or `kernel.setTactic('speed' | 'balanced' | 'precision')`**New in V2!**: Set the kernel's tactic for compilation. Allows for compilation to better fit how GPU.js is being used (internally uses `lowp` for 'speed', `mediump` for 'balanced', and `highp` for 'precision'). Default is lowest resolution supported for output.
211
212
212
213
213
214
## Creating and Running Functions
@@ -947,6 +948,30 @@ To assist with mostly unit tests, but perhaps in scenarios outside of GPU.js, th
947
948
## Typescript Typings
948
949
Typescript is supported! Typings can be found [here](src/index.d.ts)!
949
950
951
+
## Destructured Assignments **New in V2!**
952
+
Destructured Objects and Arrays work in GPU.js.
953
+
* Object destructuring
954
+
```js
955
+
constgpu=newGPU();
956
+
constkernel=gpu.createKernel(function() {
957
+
const { thread: {x, y} } =this;
958
+
return x + y;
959
+
}, { output: [2] });
960
+
console.log(kernel());
961
+
```
962
+
* Array destructuring
963
+
```js
964
+
constgpu=newGPU();
965
+
constkernel=gpu.createKernel(function(array) {
966
+
const [first, second] = array;
967
+
return first + second;
968
+
}, {
969
+
output: [2],
970
+
argumentTypes: { array:'Array(2)' }
971
+
});
972
+
console.log(kernel([1, 2]));
973
+
```
974
+
950
975
## Dealing With Transpilation
951
976
Transpilation doesn't do the best job of keeping code beautiful. To aid in this endeavor GPU.js can handle some scenarios to still aid you harnessing the GPU in less than ideal circumstances.
952
977
Here is a list of a few things that GPU.js does to fix transpilation:
@@ -958,7 +983,9 @@ Here is a list of a few things that GPU.js does to fix transpilation:
0 commit comments