Skip to content

Commit f78b032

Browse files
Merge pull request #420 from gpujs/gl-headless-experimental
Gl headless experimental
2 parents 3aba32e + 85eba0e commit f78b032

File tree

205 files changed

+55479
-37548
lines changed

Some content is hidden

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

205 files changed

+55479
-37548
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitattributes

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Built files
2-
doc/*
3-
41
# Logs
52
logs
63
*.log
@@ -17,15 +14,9 @@ lib-cov
1714
# Coverage directory used by tools like istanbul
1815
coverage
1916

20-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21-
.grunt
22-
2317
# node-waf configuration
2418
.lock-wscript
2519

26-
# Compiled binary addons (http://nodejs.org/api/addons.html)
27-
build/Release
28-
2920
# Dependency directory
3021
node_modules
3122

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2018 gpu.js Team
3+
Copyright (c) 2019 gpu.js Team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Or alternatively you can experiment around with the [kernel playground here](htt
3939
# Table of Contents
4040

4141
* [Installation](#installation)
42-
* [`GPU` Options](#gpu-options)
43-
* [`gpu.createKernel` Options](#gpu-createkernel-options)
42+
* [`GPU` Settings](#gpu-settings)
43+
* [`gpu.createKernel` Settings](#gpu-createkernel-settings)
4444
* [Creating and Running Functions](#creating-and-running-functions)
4545
* [Accepting Input](#accepting-input)
4646
* [Graphical Output](#graphical-output)
@@ -82,7 +82,7 @@ yarn add gpu.js
8282
Download the latest version of GPU.js and include the files in your HTML page using the following tags:
8383

8484
```html
85-
<script src="/path/to/js/gpu.min.js"></script>
85+
<script src="/path/to/js/gpu-browser.min.js"></script>
8686
```
8787

8888
In JavaScript, initialize the library:
@@ -91,17 +91,17 @@ In JavaScript, initialize the library:
9191
const gpu = new GPU();
9292
```
9393

94-
## `GPU` Options
95-
Options are an object used to create an instance of `GPU`. Example: `new GPU(options)`
94+
## `GPU` Settings
95+
Settings are an object used to create an instance of `GPU`. Example: `new GPU(settings)`
9696
* `canvas`: `HTMLCanvasElement`. Optional. For sharing canvas. Example: use THREE.js and GPU.js on same canvas.
9797
* `webGl`: `WebGL2RenderingContext` or `WebGLRenderingContext`. For sharing rendering context. Example: use THREE.js and GPU.js on same rendering context.
9898

99-
## `gpu.createKernel` Options
100-
Options are an object used to create a `kernel` or `kernelMap`. Example: `gpu.createKernel(options)`
99+
## `gpu.createKernel` Settings
100+
Settings are an object used to create a `kernel` or `kernelMap`. Example: `gpu.createKernel(settings)`
101101
* `output`: array or object that describes the output of kernel.
102102
* as array: `[width]`, `[width, height]`, or `[width, height, depth]`
103103
* as object: `{ x: width, y: height, z: depth }`
104-
* outputToTexture: boolean
104+
* pipeline: boolean
105105
* graphical: boolean
106106
* loopMaxIterations: number
107107
* constants: object
@@ -110,12 +110,12 @@ Options are an object used to create a `kernel` or `kernelMap`. Example: `gpu.c
110110
* floatTextures: boolean - input/working textures use float32 for each colour channel
111111
* floatOutput: boolean - output texture uses float32 for each colour channel
112112
* fixIntegerDivisionAccuracy: 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.
113-
* functions: array or boolean
113+
* functions: array or object
114114
* nativeFunctions: object
115115
* subKernels: array
116-
* outputImmutable: boolean
116+
* immutable: boolean
117117
* default to `false`
118-
118+
119119

120120

121121
## Creating and Running Functions
@@ -157,13 +157,13 @@ myFunc();
157157
// Result: [0, 1, 2, 3, ... 99]
158158
```
159159

160-
Note: Instead of creating an object, you can use the chainable shortcut methods as a neater way of specifying options.
160+
Note: Instead of creating an object, you can use the chainable shortcut methods as a neater way of specifying settings.
161161

162162
```js
163163
const myFunc = gpu.createKernel(function() {
164164
return this.thread.x;
165165
}).setOutput([100]);
166-
166+
167167
myFunc();
168168
// Result: [0, 1, 2, 3, ... 99]
169169
```
@@ -186,7 +186,7 @@ Numbers example:
186186
```
187187

188188
Array(2) examples:
189-
Using declaration
189+
Using declaration
190190
```js
191191
const myFunc = gpu.createKernel(function() {
192192
const array2 = [0.08, 2];
@@ -202,7 +202,7 @@ Directly returned
202202
```
203203

204204
Array(3) example:
205-
Using declaration
205+
Using declaration
206206
```js
207207
const myFunc = gpu.createKernel(function() {
208208
const array2 = [0.08, 2, 0.1];
@@ -218,7 +218,7 @@ Directly returned
218218
```
219219

220220
Array(4) example:
221-
Using declaration
221+
Using declaration
222222
```js
223223
const myFunc = gpu.createKernel(function() {
224224
const array2 = [0.08, 2, 0.1, 3];
@@ -248,7 +248,7 @@ To define an argument, simply add it to the kernel function like regular JavaScr
248248
const myFunc = gpu.createKernel(function(x) {
249249
return x;
250250
}).setOutput([100]);
251-
251+
252252
myFunc(42);
253253
// Result: [42, 42, 42, 42, ... 42]
254254
```
@@ -259,7 +259,7 @@ Similarly, with array inputs:
259259
const myFunc = gpu.createKernel(function(x) {
260260
return x[this.thread.x % 3];
261261
}).setOutput([100]);
262-
262+
263263
myFunc([1, 2, 3]);
264264
// Result: [1, 2, 3, 1, ... 1 ]
265265
```
@@ -324,10 +324,10 @@ const render = gpu.createKernel(function() {
324324
})
325325
.setOutput([20, 20])
326326
.setGraphical(true);
327-
327+
328328
render();
329329

330-
const canvas = render.getCanvas();
330+
const canvas = render.canvas;
331331
document.getElementsByTagName('body')[0].appendChild(canvas);
332332
```
333333

@@ -343,7 +343,7 @@ const gl = canvas.getContext('webgl2', { premultipliedAlpha: false });
343343

344344
const gpu = new GPU({
345345
canvas,
346-
webGl: gl
346+
context: gl
347347
});
348348
const krender = gpu.createKernel(function(x) {
349349
this.color(this.thread.x / 500, this.thread.y / 500, x[0], x[1]);
@@ -412,7 +412,7 @@ megaKernel(a, b, c);
412412
This gives you the flexibility of using parts of a single transformation without the performance penalty, resulting in much much _MUCH_ faster operation.
413413

414414
## Adding custom functions
415-
use `gpu.addFunction(function() {}, options)` for adding custom functions. Example:
415+
use `gpu.addFunction(function() {}, settings)` for adding custom functions. Example:
416416

417417

418418
```js
@@ -430,11 +430,11 @@ const kernel = gpu.createKernel(function(a, b) {
430430

431431
### Adding strongly typed functions
432432

433-
To strongly type a function you may use options. Options take an optional hash values:
433+
To strongly type a function you may use settings. Settings take an optional hash values:
434434
`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
435+
`argumentTypes`: optional, defaults to float for each param, a hash of param names with values of the return types
436436

437-
Types: that may be used for `returnType` or for each property of `paramTypes`:
437+
Types: that may be used for `returnType` or for each property of `argumentTypes`:
438438
* 'Array'
439439
* 'Array(2)'
440440
* 'Array(3)'
@@ -449,7 +449,7 @@ Example:
449449
```js
450450
gpu.addFunction(function mySuperFunction(a, b) {
451451
return [a - b[1], b[0] - a];
452-
}, { paramTypes: { a: 'Number', b: 'Array(2)'}, returnType: 'Array(2)' });
452+
}, { argumentTypes: { a: 'Number', b: 'Array(2)'}, returnType: 'Array(2)' });
453453
```
454454

455455

@@ -497,7 +497,7 @@ const matMult = gpu.createKernel(function(a, b) {
497497

498498
## Pipelining
499499
[Pipeline](https://en.wikipedia.org/wiki/Pipeline_(computing)) is a feature where values are sent directly from kernel to kernel via a texture.
500-
This results in extremely fast computing. This is achieved with the kernel option `outputToTexture: boolean` option or by calling `kernel.setOutputToTexture(true)`
500+
This results in extremely fast computing. This is achieved with the kernel option `pipeline: boolean` option or by calling `kernel.pipeline(true)`
501501

502502
## Offscreen Canvas
503503
GPU.js supports offscreen canvas where available. Here is an example of how to use it with two files, `gpu-worker.js`, and `index.js`:
@@ -508,17 +508,17 @@ importScripts('path/to/gpu.js');
508508
onmessage = function() {
509509
// define gpu instance
510510
const gpu = new GPU();
511-
511+
512512
// input values
513513
const a = [1,2,3];
514514
const b = [3,2,1];
515-
515+
516516
// setup kernel
517517
const kernel = gpu.createKernel(function(a, b) {
518518
return a[this.thread.x] - b[this.thread.x];
519519
})
520520
.setOutput([3]);
521-
521+
522522
// output some results!
523523
postMessage(kernel(a, b));
524524
};
@@ -574,7 +574,7 @@ log2
574574
max
575575
min
576576
round
577-
sign
577+
sign
578578
sin
579579
sqrt
580580
tan
@@ -590,7 +590,7 @@ You can find a [complete API reference here](https://doxdox.org/gpujs/gpu.js/1.2
590590
Documentation of the codebase is [automatically built](https://github.com/gpujs/gpu.js/wiki/Automatic-Documentation).
591591

592592
## Contributors
593-
593+
594594
* Fazli Sapuan
595595
* Eugene Cheah
596596
* Matthew Saw
@@ -600,26 +600,26 @@ Documentation of the codebase is [automatically built](https://github.com/gpujs/
600600
* Daniel X Moore
601601
* Mark Theng
602602
* Varun Patro
603-
603+
604604
## Contributing
605-
605+
606606
Contributors are welcome! Create a merge request to the `develop` branch and we
607607
will gladly review it. If you wish to get write access to the repository,
608608
please email us and we will review your application and grant you access to
609609
the `develop` branch.
610-
610+
611611
We promise never to pass off your code as ours.
612612

613613
## Terms Explained
614614
* Kernel - A function that is tightly coupled to program that runs on the Graphic Processor
615615
* Texture - A graphical artifact that is packed with data, in the case of GPU.js, bit shifted parts of a 32 bit floating point decimal
616616

617-
## License
617+
## License
618618

619619
The MIT License
620620

621621
Copyright (c) 2018 GPU.js Team
622-
622+
623623
Permission is hereby granted, free of charge, to any person obtaining a copy
624624
of this software and associated documentation files (the "Software"), to deal
625625
in the Software without restriction, including without limitation the rights

0 commit comments

Comments
 (0)