Skip to content

Commit 0735a56

Browse files
fix: Define uploadValue in constructor, and reuse
fix: toString handling, greatly simplified fix: Upgrade tests for toString fix: Add boolean to typeings fix: Move gl-kernel.js to new location feat: Add strictIntegers as option for Kernel and docs
1 parent 20ee1f7 commit 0735a56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3189
-2408
lines changed

Diff for: README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Matrix multiplication (perform matrix multiplication on 2 matrices of size 512 x
3131
}
3232
return sum;
3333
}).setOutput([512, 512]);
34-
34+
3535
const c = multiplyMatrix(a, b);
3636
</script>
3737
```
@@ -65,7 +65,7 @@ const multiplyMatrix = gpu.createKernel(function(a: number[][], b: number[][]) {
6565

6666
const c = multiplyMatrix(a, b) as number[][];
6767
```
68-
68+
6969
# Table of Contents
7070

7171
NOTE: documentation is slightly out of date for the upcoming release of v2. We will fix it! In the mean time, if you'd like to assist (PLEASE) let us know.
@@ -145,7 +145,7 @@ Settings are an object used to create an instance of `GPU`. Example: `new GPU(s
145145
* 'webgl2': Use the `WebGL2Kernel` for transpiling a kernel
146146
* 'headlessgl' **New in V2!**: Use the `HeadlessGLKernel` for transpiling a kernel
147147
* 'cpu': Use the `CPUKernel` for transpiling a kernel
148-
148+
149149
## `gpu.createKernel` Settings
150150
Settings are an object used to create a `kernel` or `kernelMap`. Example: `gpu.createKernel(settings)`
151151
* `output`: array or object that describes the output of kernel.
@@ -173,6 +173,7 @@ Settings are an object used to create a `kernel` or `kernelMap`. Example: `gpu.
173173
* VERY IMPORTANT! - Use this to add special native functions to your environment when you need specific functionality is needed.
174174
* `subKernels`: array, generally inherited from `GPU` instance.
175175
* `immutable`: boolean, default = `false`
176+
* `strictIntegers`: boolean, default = `false` - allows undefined argumentTypes and function return values to use strict integer declarations.
176177

177178

178179

@@ -310,7 +311,7 @@ Debugging can be done in a variety of ways, and there are different levels of de
310311
}, { output: [100, 100] });
311312
```
312313
* Debugging actual kernels on CPU with `debugger`:
313-
* This will cause "breakpoint" like behaviour, but in an actual CPU kernel. You'll peer into the compiled kernel here, for a CPU.
314+
* This will cause "breakpoint" like behaviour, but in an actual CPU kernel. You'll peer into the compiled kernel here, for a CPU.
314315
* Example:
315316
```js
316317
const gpu = new GPU({ mode: 'cpu' });
@@ -366,7 +367,7 @@ Debugging can be done in a variety of ways, and there are different levels of de
366367
* Example:
367368
```js
368369
const { input } = require('gpu.js');
369-
const value = input(flattenedArray, [width, height, depth]);
370+
const value = input(flattenedArray, [width, height, depth]);
370371
```
371372
* HTML Image
372373
* Array of HTML Images
@@ -467,7 +468,7 @@ Note: To animate the rendering, use `requestAnimationFrame` instead of `setTimeo
467468
To make it easier to get pixels from a context, use `kernel.getPixels()`, which returns a flat array similar to what you get from WebGL's `readPixels` method.
468469
A note on why: webgl's `readPixels` returns an array ordered differently from javascript's `getImageData`.
469470
This makes them behave similarly.
470-
While the values may be somewhat different, because of graphical precision available in the kernel, and alpha, this allows us to easily get pixel data in unified way.
471+
While the values may be somewhat different, because of graphical precision available in the kernel, and alpha, this allows us to easily get pixel data in unified way.
471472

472473
Example:
473474
```js
@@ -581,7 +582,7 @@ const kernel = gpu.createKernel(function(a, b) {
581582
To manually strongly type a function you may use settings.
582583
By setting this value, it makes the build step of the kernel less resource intensive.
583584
Settings take an optional hash values:
584-
* `returnType`: optional, defaults to inference from `FunctionBuilder`, the value you'd like to return from the function.
585+
* `returnType`: optional, defaults to inference from `FunctionBuilder`, the value you'd like to return from the function.
585586
* `argumentTypes`: optional, defaults to inference from `FunctionBuilder` for each param, a hash of param names with values of the return types.
586587

587588
Example:
@@ -787,7 +788,7 @@ This is a list of the supported ones:
787788
We then seed the subsequent randoms from the previous random value.
788789
So we seed from CPU, and generate from GPU.
789790
Which is still not as good as CPU, but closer.
790-
While this isn't perfect, it should suffice in most scenarios.
791+
While this isn't perfect, it should suffice in most scenarios.
791792
* `Math.round()`
792793
* `Math.sign()`
793794
* `Math.sin()`

0 commit comments

Comments
 (0)