Skip to content

Commit 58d77be

Browse files
fix: Remove erroneous channel and index division in getImage2D of webgl1
fix: Remove some debugging code fix: Build and beautify everything (was off whilst doing some mad debugging earlier)
1 parent ee7baf7 commit 58d77be

28 files changed

+172
-215
lines changed

bin/gpu-browser-core.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.6
8-
* @date Thu Apr 11 2019 18:06:53 GMT-0400 (Eastern Daylight Time)
8+
* @date Fri Apr 12 2019 14:06:34 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -3644,6 +3644,7 @@ class HeadlessGLKernel extends WebGLKernel {
36443644
module.exports = {
36453645
HeadlessGLKernel
36463646
};
3647+
36473648
},{"../web-gl/kernel":15,"gl":1}],11:[function(require,module,exports){
36483649
const {
36493650
utils
@@ -4077,8 +4078,6 @@ vec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x)
40774078
ivec3 xyz = ivec3(x, y, z);
40784079
__GET_WRAPAROUND__;
40794080
int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);
4080-
int channel = integerMod(index, 4);
4081-
index = index / 4;
40824081
int w = texSize.x;
40834082
vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;
40844083
return texture2D(tex, st / vec2(texSize));

bin/gpu-browser-core.min.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.6
8-
* @date Thu Apr 11 2019 18:06:55 GMT-0400 (Eastern Daylight Time)
8+
* @date Fri Apr 12 2019 14:06:36 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -18,7 +18,7 @@
1818
* GPU Accelerated JavaScript
1919
*
2020
* @version 2.0.0-rc.6
21-
* @date Thu Apr 11 2019 18:06:53 GMT-0400 (Eastern Daylight Time)
21+
* @date Fri Apr 12 2019 14:06:34 GMT-0400 (Eastern Daylight Time)
2222
*
2323
* @license MIT
2424
* The MIT License
@@ -3657,6 +3657,7 @@ class HeadlessGLKernel extends WebGLKernel {
36573657
module.exports = {
36583658
HeadlessGLKernel
36593659
};
3660+
36603661
},{"../web-gl/kernel":15,"gl":1}],11:[function(require,module,exports){
36613662
const {
36623663
utils
@@ -4090,8 +4091,6 @@ vec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x)
40904091
ivec3 xyz = ivec3(x, y, z);
40914092
__GET_WRAPAROUND__;
40924093
int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);
4093-
int channel = integerMod(index, 4);
4094-
index = index / 4;
40954094
int w = texSize.x;
40964095
vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;
40974096
return texture2D(tex, st / vec2(texSize));

bin/gpu-browser.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.6
8-
* @date Thu Apr 11 2019 18:06:54 GMT-0400 (Eastern Daylight Time)
8+
* @date Fri Apr 12 2019 14:06:34 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -8408,6 +8408,7 @@ class HeadlessGLKernel extends WebGLKernel {
84088408
module.exports = {
84098409
HeadlessGLKernel
84108410
};
8411+
84118412
},{"../web-gl/kernel":16,"gl":2}],12:[function(require,module,exports){
84128413
const {
84138414
utils
@@ -8841,8 +8842,6 @@ vec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x)
88418842
ivec3 xyz = ivec3(x, y, z);
88428843
__GET_WRAPAROUND__;
88438844
int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);
8844-
int channel = integerMod(index, 4);
8845-
index = index / 4;
88468845
int w = texSize.x;
88478846
vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;
88488847
return texture2D(tex, st / vec2(texSize));

bin/gpu-browser.min.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.6
8-
* @date Thu Apr 11 2019 18:06:55 GMT-0400 (Eastern Daylight Time)
8+
* @date Fri Apr 12 2019 14:06:36 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -18,7 +18,7 @@
1818
* GPU Accelerated JavaScript
1919
*
2020
* @version 2.0.0-rc.6
21-
* @date Thu Apr 11 2019 18:06:54 GMT-0400 (Eastern Daylight Time)
21+
* @date Fri Apr 12 2019 14:06:34 GMT-0400 (Eastern Daylight Time)
2222
*
2323
* @license MIT
2424
* The MIT License
@@ -8421,6 +8421,7 @@ class HeadlessGLKernel extends WebGLKernel {
84218421
module.exports = {
84228422
HeadlessGLKernel
84238423
};
8424+
84248425
},{"../web-gl/kernel":16,"gl":2}],12:[function(require,module,exports){
84258426
const {
84268427
utils
@@ -8854,8 +8855,6 @@ vec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x)
88548855
ivec3 xyz = ivec3(x, y, z);
88558856
__GET_WRAPAROUND__;
88568857
int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);
8857-
int channel = integerMod(index, 4);
8858-
index = index / 4;
88598858
int w = texSize.x;
88608859
vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;
88618860
return texture2D(tex, st / vec2(texSize));

src/backend/cpu/function-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,4 +621,4 @@ class CPUFunctionNode extends FunctionNode {
621621

622622
module.exports = {
623623
CPUFunctionNode
624-
};
624+
};

src/backend/cpu/kernel-string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ function cpuKernelString(cpuKernel, name) {
6969

7070
module.exports = {
7171
cpuKernelString
72-
};
72+
};

src/backend/cpu/kernel.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ class CPUKernel extends Kernel {
203203
if (this._kernelString !== null) return this._kernelString;
204204

205205
let kernel = null;
206-
let { translatedSources } = this;
206+
let {
207+
translatedSources
208+
} = this;
207209
if (translatedSources.length > 1) {
208210
translatedSources = translatedSources.filter(fn => {
209211
if (/^function/.test(fn)) return fn;
@@ -534,4 +536,4 @@ class CPUKernel extends Kernel {
534536

535537
module.exports = {
536538
CPUKernel
537-
};
539+
};

src/backend/function-builder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,4 @@ class FunctionBuilder {
511511

512512
module.exports = {
513513
FunctionBuilder
514-
};
514+
};

src/backend/function-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,4 +1250,4 @@ const typeLookupMap = {
12501250

12511251
module.exports = {
12521252
FunctionNode
1253-
};
1253+
};

src/backend/gl-kernel.js

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const {
66
Texture
77
} = require('../texture');
88

9-
const { utils } = require('../utils');
9+
const {
10+
utils
11+
} = require('../utils');
1012

1113
/**
1214
* @abstract
@@ -419,57 +421,79 @@ class GLKernel extends Kernel {
419421
* @abstract
420422
* @returns String[]
421423
*/
422-
getMainResultKernelNumberTexture() { throw new Error(`abstract method call`); }
424+
getMainResultKernelNumberTexture() {
425+
throw new Error(`abstract method call`);
426+
}
423427
/**
424428
* @abstract
425429
* @returns String[]
426430
*/
427-
getMainResultSubKernelNumberTexture() { throw new Error(`abstract method call`); }
431+
getMainResultSubKernelNumberTexture() {
432+
throw new Error(`abstract method call`);
433+
}
428434
/**
429435
* @abstract
430436
* @returns String[]
431437
*/
432-
getMainResultKernelArray2Texture() { throw new Error(`abstract method call`); }
438+
getMainResultKernelArray2Texture() {
439+
throw new Error(`abstract method call`);
440+
}
433441
/**
434442
* @abstract
435443
* @returns String[]
436444
*/
437-
getMainResultSubKernelArray2Texture() { throw new Error(`abstract method call`); }
445+
getMainResultSubKernelArray2Texture() {
446+
throw new Error(`abstract method call`);
447+
}
438448
/**
439449
* @abstract
440450
* @returns String[]
441451
*/
442-
getMainResultKernelArray3Texture() { throw new Error(`abstract method call`); }
452+
getMainResultKernelArray3Texture() {
453+
throw new Error(`abstract method call`);
454+
}
443455
/**
444456
* @abstract
445457
* @returns String[]
446458
*/
447-
getMainResultSubKernelArray3Texture() { throw new Error(`abstract method call`); }
459+
getMainResultSubKernelArray3Texture() {
460+
throw new Error(`abstract method call`);
461+
}
448462
/**
449463
* @abstract
450464
* @returns String[]
451465
*/
452-
getMainResultKernelArray4Texture() { throw new Error(`abstract method call`); }
466+
getMainResultKernelArray4Texture() {
467+
throw new Error(`abstract method call`);
468+
}
453469
/**
454470
* @abstract
455471
* @returns String[]
456472
*/
457-
getMainResultSubKernelArray4Texture() { throw new Error(`abstract method call`); }
473+
getMainResultSubKernelArray4Texture() {
474+
throw new Error(`abstract method call`);
475+
}
458476
/**
459477
* @abstract
460478
* @returns String[]
461479
*/
462-
getMainResultGraphical() { throw new Error(`abstract method call`); }
480+
getMainResultGraphical() {
481+
throw new Error(`abstract method call`);
482+
}
463483
/**
464484
* @abstract
465485
* @returns String[]
466486
*/
467-
getMainResultMemoryOptimizedFloats() { throw new Error(`abstract method call`); }
487+
getMainResultMemoryOptimizedFloats() {
488+
throw new Error(`abstract method call`);
489+
}
468490
/**
469491
* @abstract
470492
* @returns String[]
471493
*/
472-
getMainResultPackedPixels() { throw new Error(`abstract method call`); }
494+
getMainResultPackedPixels() {
495+
throw new Error(`abstract method call`);
496+
}
473497

474498
getMainResultString() {
475499
if (this.graphical) {
@@ -485,23 +509,23 @@ class GLKernel extends Kernel {
485509
}
486510

487511
getMainResultNumberTexture() {
488-
return utils.linesToString(this.getMainResultKernelNumberTexture())
489-
+ utils.linesToString(this.getMainResultSubKernelNumberTexture());
512+
return utils.linesToString(this.getMainResultKernelNumberTexture()) +
513+
utils.linesToString(this.getMainResultSubKernelNumberTexture());
490514
}
491515

492516
getMainResultArray2Texture() {
493-
return utils.linesToString(this.getMainResultKernelArray2Texture())
494-
+ utils.linesToString(this.getMainResultSubKernelArray2Texture());
517+
return utils.linesToString(this.getMainResultKernelArray2Texture()) +
518+
utils.linesToString(this.getMainResultSubKernelArray2Texture());
495519
}
496520

497521
getMainResultArray3Texture() {
498-
return utils.linesToString(this.getMainResultKernelArray3Texture())
499-
+ utils.linesToString(this.getMainResultSubKernelArray3Texture());
522+
return utils.linesToString(this.getMainResultKernelArray3Texture()) +
523+
utils.linesToString(this.getMainResultSubKernelArray3Texture());
500524
}
501525

502526
getMainResultArray4Texture() {
503-
return utils.linesToString(this.getMainResultKernelArray4Texture())
504-
+ utils.linesToString(this.getMainResultSubKernelArray4Texture());
527+
return utils.linesToString(this.getMainResultKernelArray4Texture()) +
528+
utils.linesToString(this.getMainResultSubKernelArray4Texture());
505529
}
506530

507531
getReturnTextureType() {
@@ -554,7 +578,10 @@ class GLKernel extends Kernel {
554578
});
555579
}
556580
readPackedPixelsToUint8Array() {
557-
const { texSize, context: gl } = this;
581+
const {
582+
texSize,
583+
context: gl
584+
} = this;
558585
const result = new Uint8Array(texSize[0] * texSize[1] * 4);
559586
gl.readPixels(0, 0, texSize[0], texSize[1], gl.RGBA, gl.UNSIGNED_BYTE, result);
560587
return result;
@@ -564,7 +591,10 @@ class GLKernel extends Kernel {
564591
}
565592
readFloatPixelsToFloat32Array() {
566593
if (!this.floatOutput) throw new Error('Requires this.floutOutput');
567-
const { texSize, context: gl } = this;
594+
const {
595+
texSize,
596+
context: gl
597+
} = this;
568598
const w = texSize[0];
569599
const h = texSize[1];
570600
const result = new Float32Array(w * h * 4);
@@ -573,7 +603,10 @@ class GLKernel extends Kernel {
573603
}
574604
readMemoryOptimizedFloatPixelsToFloat32Array() {
575605
if (!this.floatOutput) throw new Error('Requires this.floutOutput');
576-
const { texSize, context: gl } = this;
606+
const {
607+
texSize,
608+
context: gl
609+
} = this;
577610
const w = texSize[0];
578611
const h = texSize[1];
579612
const result = new Float32Array(w * h * 4);
@@ -839,4 +872,4 @@ const typeMap = {
839872
module.exports = {
840873
GLKernel,
841874
renderStrategy
842-
};
875+
};

0 commit comments

Comments
 (0)