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
const v = arg1[this.thread.y][this.thread.x * time];
320
+
return v;
321
+
}, { output: [100, 100] });
322
+
```
323
+
* Debugging an actual GPU kernel:
324
+
* There are no breakpoints available on the GPU, period. By providing the same level of abstraction and logic, the above methods should give you enough insight to debug, but sometimes we just need to see what is on the GPU.
325
+
* Be VERY specific and deliberate, and use the kernel to your advantage, rather than just getting frustrated or giving up.
In this example, we return early the value of x, to see exactly what it is. The rest of the logic is ignored, but now you can see the value that is calculated from `x`, and debug it.
337
+
This is an overly simplified problem.
338
+
* Sometimes you need to solve graphical problems, that can be done similarly.
Here we are making the canvas red or green depending on the value of `x`.
295
359
296
360
## Accepting Input
297
361
### Supported Input Types
@@ -514,25 +578,11 @@ const kernel = gpu.createKernel(function(a, b) {
514
578
515
579
### Adding strongly typed functions
516
580
517
-
To strongly type a function you may use settings. Settings take an optional hash values:
518
-
`returnType`: optional, defaults to inference from `FunctionNode`, the value you'd like to return from the function. By setting this value, it makes the build step of the kernel less resource intensive.
519
-
`argumentTypes`: optional, defaults to inference from `FunctionNode` for each param, a hash of param names with values of the return types. By setting this value, it makes the build step of the kernel less resource intensive.
520
-
521
-
Types: that may be used for `returnType` or for each property of `argumentTypes`:
522
-
* 'Array'
523
-
* 'Array(2)'
524
-
* 'Array(3)'
525
-
* 'Array(4)'
526
-
* 'HTMLImage'
527
-
* 'HTMLImageArray'
528
-
* 'Number'
529
-
* 'Float'
530
-
* 'Integer'
531
-
* 'NumberTexture'
532
-
* 'ArrayTexture(1)'
533
-
* 'ArrayTexture(2)'
534
-
* 'ArrayTexture(3)'
535
-
* 'ArrayTexture(4)'
581
+
To manually strongly type a function you may use settings.
582
+
By setting this value, it makes the build step of the kernel less resource intensive.
583
+
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
+
* `argumentTypes`: optional, defaults to inference from `FunctionBuilder` for each param, a hash of param names with values of the return types.
536
586
537
587
Example:
538
588
```js
@@ -555,6 +605,44 @@ const kernel = gpu.createKernel(function(a, b) {
555
605
556
606
```
557
607
608
+
609
+
## Types
610
+
GPU.js does type inference when types are not defined, so even if you code weak type, you are typing strongly typed.
611
+
This is needed because c++, which glsl is a subset of, is, of course, strongly typed.
612
+
Types that can be used with GPU.js are as follows:
613
+
614
+
### Argument Types
615
+
Types: that may be used for `returnType` or for each property of `argumentTypes`:
616
+
* 'Array'
617
+
* 'Array(2)'
618
+
* 'Array(3)'
619
+
* 'Array(4)'
620
+
* 'HTMLImage'
621
+
* 'HTMLImageArray'
622
+
* 'Number'
623
+
* 'Float'
624
+
* 'Integer'
625
+
* 'Boolean' **New in V2!**
626
+
627
+
### Return Types
628
+
Types: that may be used for `returnType` or for each property of `argumentTypes`:
629
+
* 'Array(2)'
630
+
* 'Array(3)'
631
+
* 'Array(4)'
632
+
* 'HTMLImage'
633
+
* 'HTMLImageArray'
634
+
* 'Number'
635
+
* 'Float'
636
+
* 'Integer'
637
+
638
+
### Internal Types
639
+
Types generally used in the `Texture` class, for #pipelining or for advanced usage.
640
+
* 'NumberTexture'
641
+
* 'ArrayTexture(1)' **New in V2!**
642
+
* 'ArrayTexture(2)' **New in V2!**
643
+
* 'ArrayTexture(3)' **New in V2!**
644
+
* 'ArrayTexture(4)' **New in V2!**
645
+
558
646
## Loops
559
647
* Any loops defined inside the kernel must have a maximum iteration count defined by the loopMaxIterations setting.
560
648
* Other than defining the iterations by a constant or fixed value as shown [Dynamic sized via constants](dynamic-sized-via-constants), you can also simply pass the number of iterations as a variable to the kernel
0 commit comments