Skip to content

Commit a3c930d

Browse files
fix: Memory recycling bug, and remove no longer needed renderStrategy
Also cleanup documentation a bit
1 parent 5738698 commit a3c930d

26 files changed

+788
-673
lines changed

dist/gpu-browser-core.js

Lines changed: 110 additions & 140 deletions
Large diffs are not rendered by default.

dist/gpu-browser-core.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gpu-browser.js

Lines changed: 111 additions & 141 deletions
Large diffs are not rendered by default.

dist/gpu-browser.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gpu.js",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"description": "GPU Accelerated JavaScript",
55
"engines": {
66
"node": ">=8.0.0"
@@ -45,7 +45,8 @@
4545
"scripts": {
4646
"test": "qunit",
4747
"setup": "npm i -g gulp-cli",
48-
"make": "gulp make"
48+
"make": "gulp make",
49+
"docs": "doxdox ./src --layout bootstrap --output docs.html"
4950
},
5051
"repository": {
5152
"type": "git",

src/backend/gl/kernel.js

Lines changed: 62 additions & 114 deletions
Large diffs are not rendered by default.

src/backend/gl/texture/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const { Texture } = require('../../../texture');
22

3+
/**
4+
* @class
5+
* @property framebuffer
6+
* @extends Texture
7+
*/
38
class GLTexture extends Texture {
49
/**
510
* @returns {Number}
@@ -52,7 +57,7 @@ class GLTexture extends Texture {
5257

5358
delete() {
5459
super.delete();
55-
if (this.framebuffer && this.texture && this.texture.refs < 1) {
60+
if (this.framebuffer) {
5661
this.context.deleteFramebuffer(this.framebuffer);
5762
}
5863
}

src/backend/kernel.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class Kernel {
1010
}
1111

1212
/**
13-
* @type {Boolean}
13+
* @abstract
14+
* @returns {Boolean}
1415
*/
1516
static isContextMatch(context) {
1617
throw new Error(`"isContextMatch" not implemented on ${ this.name }`);
@@ -42,7 +43,7 @@ class Kernel {
4243

4344
/**
4445
*
45-
* @param {string|IJSON} source
46+
* @param {string|IKernelJSON} source
4647
* @param [settings]
4748
*/
4849
constructor(source, settings) {
@@ -73,7 +74,7 @@ class Kernel {
7374

7475
/**
7576
* The function source
76-
* @type {String|IJSON}
77+
* @type {String|IKernelJSON}
7778
*/
7879
this.source = source;
7980

@@ -106,9 +107,29 @@ class Kernel {
106107
* @type {Object}
107108
*/
108109
this.constants = null;
110+
111+
/**
112+
*
113+
* @type {Object.<string, string>}
114+
*/
109115
this.constantTypes = null;
116+
117+
/**
118+
*
119+
* @type {Object.<string, number>}
120+
*/
110121
this.constantBitRatios = null;
122+
123+
/**
124+
*
125+
* @type {boolean}
126+
*/
111127
this.dynamicArguments = false;
128+
129+
/**
130+
*
131+
* @type {boolean}
132+
*/
112133
this.dynamicOutput = false;
113134

114135
/**
@@ -178,7 +199,7 @@ class Kernel {
178199
this.pipeline = false;
179200

180201
/**
181-
* Make GPU use single precison or unsigned. Acceptable values: 'single' or 'unsigned'
202+
* Make GPU use single precision or unsigned. Acceptable values: 'single' or 'unsigned'
182203
* @type {String|null}
183204
* @enum 'single' | 'unsigned'
184205
*/
@@ -759,7 +780,7 @@ class Kernel {
759780
}
760781

761782
/**
762-
* @return {IJSON}
783+
* @return {IKernelJSON}
763784
*/
764785
toJSON() {
765786
return {

src/backend/web-gl/kernel-value/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class WebGLKernelValue extends KernelValue {
1717
this.uploadValue = null;
1818
this.textureSize = null;
1919
this.bitRatio = null;
20+
this.prevArg = null;
2021
}
2122

2223
/**
@@ -144,6 +145,9 @@ class WebGLKernelValue extends KernelValue {
144145
}
145146

146147
destroy() {
148+
if (this.prevArg) {
149+
this.prevArg.delete();
150+
}
147151
this.context.deleteTexture(this.texture);
148152
}
149153
}

0 commit comments

Comments
 (0)