Skip to content

Commit f3fb9fc

Browse files
Merge pull request #384 from gpujs/382-bad-constant
fix #382: Constant being set weirdly and conflicting with user variables
2 parents 0e4c049 + 3a55872 commit f3fb9fc

File tree

14 files changed

+77
-98
lines changed

14 files changed

+77
-98
lines changed

bin/gpu-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 1.9.0
8-
* @date Wed Oct 24 2018 14:09:46 GMT-0400 (EDT)
8+
* @date Wed Oct 24 2018 14:56:50 GMT-0400 (EDT)
99
*
1010
* @license MIT
1111
* The MIT License

bin/gpu-core.min.js

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

bin/gpu.js

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 1.9.0
8-
* @date Wed Oct 24 2018 14:09:46 GMT-0400 (EDT)
8+
* @date Wed Oct 24 2018 14:56:51 GMT-0400 (EDT)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -2683,15 +2683,11 @@ module.exports = function (_FunctionNodeBase) {
26832683
retArr.push('3.402823466e+38');
26842684
break;
26852685
default:
2686-
if (this.constants && this.constants.hasOwnProperty(idtNode.name)) {
2687-
this.pushParameter(retArr, 'constants_' + idtNode.name);
2686+
var userParamName = this.getUserParamName(idtNode.name);
2687+
if (userParamName !== null) {
2688+
this.pushParameter(retArr, 'user_' + userParamName);
26882689
} else {
2689-
var userParamName = this.getUserParamName(idtNode.name);
2690-
if (userParamName !== null) {
2691-
this.pushParameter(retArr, 'user_' + userParamName);
2692-
} else {
2693-
this.pushParameter(retArr, 'user_' + idtNode.name);
2694-
}
2690+
this.pushParameter(retArr, 'user_' + idtNode.name);
26952691
}
26962692
}
26972693

@@ -3642,7 +3638,7 @@ module.exports = function (_KernelBase) {
36423638
for (var p in this.constants) {
36433639
var value = this.constants[p];
36443640
var type = utils.getArgumentType(value);
3645-
if (type === 'Decimal' || type === 'Integer') {
3641+
if (type === 'Float' || type === 'Integer') {
36463642
continue;
36473643
}
36483644
gl.useProgram(this.program);
@@ -4160,12 +4156,6 @@ module.exports = function (_KernelBase) {
41604156
this.setUniform1i('constants_' + name, this.constantsLength);
41614157
break;
41624158
}
4163-
case 'Integer':
4164-
case 'Float':
4165-
{
4166-
this.setUniform1f('constants_' + name, value);
4167-
break;
4168-
}
41694159
case 'Input':
41704160
{
41714161
var input = value;
@@ -4240,6 +4230,8 @@ module.exports = function (_KernelBase) {
42404230
this.setUniform1i('constants_' + name, this.constantsLength);
42414231
break;
42424232
}
4233+
case 'Integer':
4234+
case 'Float':
42434235
default:
42444236
throw new Error('Input type not supported (WebGL): ' + value);
42454237
}
@@ -4919,15 +4911,11 @@ module.exports = function (_WebGLFunctionNode) {
49194911
retArr.push('intBitsToFloat(2139095039)');
49204912
break;
49214913
default:
4922-
if (this.constants && this.constants.hasOwnProperty(idtNode.name)) {
4923-
this.pushParameter(retArr, 'constants_' + idtNode.name);
4914+
var userParamName = this.getUserParamName(idtNode.name);
4915+
if (userParamName !== null) {
4916+
this.pushParameter(retArr, 'user_' + userParamName);
49244917
} else {
4925-
var userParamName = this.getUserParamName(idtNode.name);
4926-
if (userParamName !== null) {
4927-
this.pushParameter(retArr, 'user_' + userParamName);
4928-
} else {
4929-
this.pushParameter(retArr, 'user_' + idtNode.name);
4930-
}
4918+
this.pushParameter(retArr, 'user_' + idtNode.name);
49314919
}
49324920
}
49334921

@@ -5417,12 +5405,6 @@ module.exports = function (_WebGLKernel) {
54175405
this.setUniform1i('constants_' + name, this.constantsLength);
54185406
break;
54195407
}
5420-
case 'Integer':
5421-
case 'Float':
5422-
{
5423-
this.setUniform1f('constants_' + name, value);
5424-
break;
5425-
}
54265408
case 'Input':
54275409
{
54285410
var input = value;
@@ -5528,6 +5510,8 @@ module.exports = function (_WebGLKernel) {
55285510
this.setUniform1i('constants_' + name, this.constantsLength);
55295511
break;
55305512
}
5513+
case 'Integer':
5514+
case 'Float':
55315515
default:
55325516
throw new Error('Input type not supported (WebGL): ' + value);
55335517
}

bin/gpu.min.js

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

dist/backend/web-gl/function-node.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,11 @@ module.exports = function (_FunctionNodeBase) {
356356
retArr.push('3.402823466e+38');
357357
break;
358358
default:
359-
if (this.constants && this.constants.hasOwnProperty(idtNode.name)) {
360-
this.pushParameter(retArr, 'constants_' + idtNode.name);
359+
var userParamName = this.getUserParamName(idtNode.name);
360+
if (userParamName !== null) {
361+
this.pushParameter(retArr, 'user_' + userParamName);
361362
} else {
362-
var userParamName = this.getUserParamName(idtNode.name);
363-
if (userParamName !== null) {
364-
this.pushParameter(retArr, 'user_' + userParamName);
365-
} else {
366-
this.pushParameter(retArr, 'user_' + idtNode.name);
367-
}
363+
this.pushParameter(retArr, 'user_' + idtNode.name);
368364
}
369365
}
370366

dist/backend/web-gl/kernel.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ module.exports = function (_KernelBase) {
287287
for (var p in this.constants) {
288288
var value = this.constants[p];
289289
var type = utils.getArgumentType(value);
290-
if (type === 'Decimal' || type === 'Integer') {
290+
if (type === 'Float' || type === 'Integer') {
291291
continue;
292292
}
293293
gl.useProgram(this.program);
@@ -942,12 +942,6 @@ module.exports = function (_KernelBase) {
942942
this.setUniform1i('constants_' + name, this.constantsLength);
943943
break;
944944
}
945-
case 'Integer':
946-
case 'Float':
947-
{
948-
this.setUniform1f('constants_' + name, value);
949-
break;
950-
}
951945
case 'Input':
952946
{
953947
var input = value;
@@ -1023,6 +1017,8 @@ module.exports = function (_KernelBase) {
10231017
this.setUniform1i('constants_' + name, this.constantsLength);
10241018
break;
10251019
}
1020+
case 'Integer':
1021+
case 'Float':
10261022
default:
10271023
throw new Error('Input type not supported (WebGL): ' + value);
10281024
}

dist/backend/web-gl2/function-node.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,11 @@ module.exports = function (_WebGLFunctionNode) {
172172
retArr.push('intBitsToFloat(2139095039)');
173173
break;
174174
default:
175-
if (this.constants && this.constants.hasOwnProperty(idtNode.name)) {
176-
this.pushParameter(retArr, 'constants_' + idtNode.name);
175+
var userParamName = this.getUserParamName(idtNode.name);
176+
if (userParamName !== null) {
177+
this.pushParameter(retArr, 'user_' + userParamName);
177178
} else {
178-
var userParamName = this.getUserParamName(idtNode.name);
179-
if (userParamName !== null) {
180-
this.pushParameter(retArr, 'user_' + userParamName);
181-
} else {
182-
this.pushParameter(retArr, 'user_' + idtNode.name);
183-
}
179+
this.pushParameter(retArr, 'user_' + idtNode.name);
184180
}
185181
}
186182

dist/backend/web-gl2/kernel.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,6 @@ module.exports = function (_WebGLKernel) {
555555
this.setUniform1i('constants_' + name, this.constantsLength);
556556
break;
557557
}
558-
case 'Integer':
559-
case 'Float':
560-
{
561-
this.setUniform1f('constants_' + name, value);
562-
break;
563-
}
564558
case 'Input':
565559
{
566560
var input = value;
@@ -668,6 +662,8 @@ module.exports = function (_WebGLKernel) {
668662
this.setUniform1i('constants_' + name, this.constantsLength);
669663
break;
670664
}
665+
case 'Integer':
666+
case 'Float':
671667
default:
672668
throw new Error('Input type not supported (WebGL): ' + value);
673669
}

src/backend/web-gl/function-node.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,11 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase {
354354
retArr.push('3.402823466e+38');
355355
break;
356356
default:
357-
if (this.constants && this.constants.hasOwnProperty(idtNode.name)) {
358-
this.pushParameter(retArr, 'constants_' + idtNode.name);
357+
const userParamName = this.getUserParamName(idtNode.name);
358+
if (userParamName !== null) {
359+
this.pushParameter(retArr, 'user_' + userParamName);
359360
} else {
360-
const userParamName = this.getUserParamName(idtNode.name);
361-
if (userParamName !== null) {
362-
this.pushParameter(retArr, 'user_' + userParamName);
363-
} else {
364-
this.pushParameter(retArr, 'user_' + idtNode.name);
365-
}
361+
this.pushParameter(retArr, 'user_' + idtNode.name);
366362
}
367363
}
368364

src/backend/web-gl/kernel.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ module.exports = class WebGLKernel extends KernelBase {
264264
for (let p in this.constants) {
265265
const value = this.constants[p]
266266
const type = utils.getArgumentType(value);
267-
if (type === 'Decimal' || type === 'Integer') {
267+
if (type === 'Float' || type === 'Integer') {
268268
continue;
269269
}
270270
gl.useProgram(this.program);
@@ -904,12 +904,6 @@ module.exports = class WebGLKernel extends KernelBase {
904904
this.setUniform1i(`constants_${name}`, this.constantsLength);
905905
break;
906906
}
907-
case 'Integer':
908-
case 'Float':
909-
{
910-
this.setUniform1f(`constants_${name}`, value);
911-
break;
912-
}
913907
case 'Input':
914908
{
915909
const input = value;
@@ -990,6 +984,8 @@ module.exports = class WebGLKernel extends KernelBase {
990984
this.setUniform1i(`constants_${name}`, this.constantsLength);
991985
break;
992986
}
987+
case 'Integer':
988+
case 'Float':
993989
default:
994990
throw new Error('Input type not supported (WebGL): ' + value);
995991
}

0 commit comments

Comments
 (0)