Skip to content

Commit f46a50d

Browse files
fix: Correct wording for validateSettings errors and use Error instance in CPU Kernel
fix: Add missing precision for `sampler2DArray` in WebGL2 fragment shader fix: Add validateSettings in typings file fix: offscreen-canvas.js broken test from bin to dist move fix: Fix typings Kernel hierarchy fix: Bump and build
1 parent 8aac6ab commit f46a50d

File tree

11 files changed

+117
-99
lines changed

11 files changed

+117
-99
lines changed

dist/gpu-browser-core.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 2.0.0-rc.18
8-
* @date Sat Jun 29 2019 10:06:59 GMT-0400 (Eastern Daylight Time)
7+
* @version 2.0.0-rc.19
8+
* @date Tue Jul 02 2019 12:17:44 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -1223,19 +1223,19 @@ class CPUKernel extends Kernel {
12231223
return [];
12241224
}
12251225

1226-
validateSettings() {
1226+
validateSettings(args) {
12271227
if (!this.output || this.output.length === 0) {
1228-
if (arguments.length !== 1) {
1229-
throw 'Auto dimensions only supported for kernels with only one input';
1228+
if (args.length !== 1) {
1229+
throw new Error('Auto output only supported for kernels with only one input');
12301230
}
12311231

1232-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
1232+
const argType = utils.getVariableType(args[0], this.strictIntegers);
12331233
if (argType === 'Array') {
12341234
this.output = utils.getDimensions(argType);
12351235
} else if (argType === 'NumberTexture' || argType === 'ArrayTexture(4)') {
1236-
this.output = arguments[0].output;
1236+
this.output = args[0].output;
12371237
} else {
1238-
throw 'Auto dimensions not supported for input type: ' + argType;
1238+
throw new Error('Auto output not supported for input type: ' + argType);
12391239
}
12401240
}
12411241

@@ -1270,7 +1270,7 @@ class CPUKernel extends Kernel {
12701270
build() {
12711271
this.setupConstants();
12721272
this.setupArguments(arguments);
1273-
this.validateSettings();
1273+
this.validateSettings(arguments);
12741274
this.translateSource();
12751275

12761276
if (this.graphical) {
@@ -8462,7 +8462,7 @@ class WebGLKernel extends GLKernel {
84628462
};
84638463
}
84648464

8465-
validateSettings() {
8465+
validateSettings(args) {
84668466
if (!this.validate) {
84678467
this.texSize = utils.getKernelTextureSize({
84688468
optimizeFloatMemory: this.optimizeFloatMemory,
@@ -8493,15 +8493,15 @@ class WebGLKernel extends GLKernel {
84938493
this.checkOutput();
84948494

84958495
if (!this.output || this.output.length === 0) {
8496-
if (arguments.length !== 1) {
8496+
if (args.length !== 1) {
84978497
throw new Error('Auto output only supported for kernels with only one input');
84988498
}
84998499

8500-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
8500+
const argType = utils.getVariableType(args[0], this.strictIntegers);
85018501
if (argType === 'Array') {
85028502
this.output = utils.getDimensions(argType);
85038503
} else if (argType === 'NumberTexture' || argType === 'ArrayTexture(4)') {
8504-
this.output = arguments[0].output;
8504+
this.output = args[0].output;
85058505
} else {
85068506
throw new Error('Auto output not supported for input type: ' + argType);
85078507
}
@@ -8683,7 +8683,7 @@ class WebGLKernel extends GLKernel {
86838683

86848684
build() {
86858685
this.initExtensions();
8686-
this.validateSettings();
8686+
this.validateSettings(arguments);
86878687
this.setupConstants(arguments);
86888688
if (this.fallbackRequested) return;
86898689
this.setupArguments(arguments);
@@ -9611,6 +9611,7 @@ __HEADER__;
96119611
precision highp float;
96129612
precision highp int;
96139613
precision highp sampler2D;
9614+
precision highp sampler2DArray;
96149615
96159616
const int LOOP_MAX = __LOOP_MAX__;
96169617
@@ -10619,7 +10620,7 @@ class WebGL2Kernel extends WebGLKernel {
1061910620
};
1062010621
}
1062110622

10622-
validateSettings() {
10623+
validateSettings(args) {
1062310624
if (!this.validate) {
1062410625
this.texSize = utils.getKernelTextureSize({
1062510626
optimizeFloatMemory: this.optimizeFloatMemory,
@@ -10644,11 +10645,11 @@ class WebGL2Kernel extends WebGLKernel {
1064410645
this.checkOutput();
1064510646

1064610647
if (!this.output || this.output.length === 0) {
10647-
if (arguments.length !== 1) {
10648+
if (args.length !== 1) {
1064810649
throw new Error('Auto output only supported for kernels with only one input');
1064910650
}
1065010651

10651-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
10652+
const argType = utils.getVariableType(args[0], this.strictIntegers);
1065210653
switch (argType) {
1065310654
case 'Array':
1065410655
this.output = utils.getDimensions(argType);
@@ -10659,7 +10660,7 @@ class WebGL2Kernel extends WebGLKernel {
1065910660
case 'ArrayTexture(2)':
1066010661
case 'ArrayTexture(3)':
1066110662
case 'ArrayTexture(4)':
10662-
this.output = arguments[0].output;
10663+
this.output = args[0].output;
1066310664
break;
1066410665
default:
1066510666
throw new Error('Auto output not supported for input type: ' + argType);

dist/gpu-browser-core.min.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 2.0.0-rc.18
8-
* @date Sat Jun 29 2019 10:07:01 GMT-0400 (Eastern Daylight Time)
7+
* @version 2.0.0-rc.19
8+
* @date Tue Jul 02 2019 12:17:46 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -17,8 +17,8 @@
1717
*
1818
* GPU Accelerated JavaScript
1919
*
20-
* @version 2.0.0-rc.18
21-
* @date Sat Jun 29 2019 10:06:59 GMT-0400 (Eastern Daylight Time)
20+
* @version 2.0.0-rc.19
21+
* @date Tue Jul 02 2019 12:17:44 GMT-0400 (Eastern Daylight Time)
2222
*
2323
* @license MIT
2424
* The MIT License
@@ -1236,19 +1236,19 @@ class CPUKernel extends Kernel {
12361236
return [];
12371237
}
12381238

1239-
validateSettings() {
1239+
validateSettings(args) {
12401240
if (!this.output || this.output.length === 0) {
1241-
if (arguments.length !== 1) {
1242-
throw 'Auto dimensions only supported for kernels with only one input';
1241+
if (args.length !== 1) {
1242+
throw new Error('Auto output only supported for kernels with only one input');
12431243
}
12441244

1245-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
1245+
const argType = utils.getVariableType(args[0], this.strictIntegers);
12461246
if (argType === 'Array') {
12471247
this.output = utils.getDimensions(argType);
12481248
} else if (argType === 'NumberTexture' || argType === 'ArrayTexture(4)') {
1249-
this.output = arguments[0].output;
1249+
this.output = args[0].output;
12501250
} else {
1251-
throw 'Auto dimensions not supported for input type: ' + argType;
1251+
throw new Error('Auto output not supported for input type: ' + argType);
12521252
}
12531253
}
12541254

@@ -1283,7 +1283,7 @@ class CPUKernel extends Kernel {
12831283
build() {
12841284
this.setupConstants();
12851285
this.setupArguments(arguments);
1286-
this.validateSettings();
1286+
this.validateSettings(arguments);
12871287
this.translateSource();
12881288

12891289
if (this.graphical) {
@@ -8475,7 +8475,7 @@ class WebGLKernel extends GLKernel {
84758475
};
84768476
}
84778477

8478-
validateSettings() {
8478+
validateSettings(args) {
84798479
if (!this.validate) {
84808480
this.texSize = utils.getKernelTextureSize({
84818481
optimizeFloatMemory: this.optimizeFloatMemory,
@@ -8506,15 +8506,15 @@ class WebGLKernel extends GLKernel {
85068506
this.checkOutput();
85078507

85088508
if (!this.output || this.output.length === 0) {
8509-
if (arguments.length !== 1) {
8509+
if (args.length !== 1) {
85108510
throw new Error('Auto output only supported for kernels with only one input');
85118511
}
85128512

8513-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
8513+
const argType = utils.getVariableType(args[0], this.strictIntegers);
85148514
if (argType === 'Array') {
85158515
this.output = utils.getDimensions(argType);
85168516
} else if (argType === 'NumberTexture' || argType === 'ArrayTexture(4)') {
8517-
this.output = arguments[0].output;
8517+
this.output = args[0].output;
85188518
} else {
85198519
throw new Error('Auto output not supported for input type: ' + argType);
85208520
}
@@ -8696,7 +8696,7 @@ class WebGLKernel extends GLKernel {
86968696

86978697
build() {
86988698
this.initExtensions();
8699-
this.validateSettings();
8699+
this.validateSettings(arguments);
87008700
this.setupConstants(arguments);
87018701
if (this.fallbackRequested) return;
87028702
this.setupArguments(arguments);
@@ -9624,6 +9624,7 @@ __HEADER__;
96249624
precision highp float;
96259625
precision highp int;
96269626
precision highp sampler2D;
9627+
precision highp sampler2DArray;
96279628
96289629
const int LOOP_MAX = __LOOP_MAX__;
96299630
@@ -10632,7 +10633,7 @@ class WebGL2Kernel extends WebGLKernel {
1063210633
};
1063310634
}
1063410635

10635-
validateSettings() {
10636+
validateSettings(args) {
1063610637
if (!this.validate) {
1063710638
this.texSize = utils.getKernelTextureSize({
1063810639
optimizeFloatMemory: this.optimizeFloatMemory,
@@ -10657,11 +10658,11 @@ class WebGL2Kernel extends WebGLKernel {
1065710658
this.checkOutput();
1065810659

1065910660
if (!this.output || this.output.length === 0) {
10660-
if (arguments.length !== 1) {
10661+
if (args.length !== 1) {
1066110662
throw new Error('Auto output only supported for kernels with only one input');
1066210663
}
1066310664

10664-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
10665+
const argType = utils.getVariableType(args[0], this.strictIntegers);
1066510666
switch (argType) {
1066610667
case 'Array':
1066710668
this.output = utils.getDimensions(argType);
@@ -10672,7 +10673,7 @@ class WebGL2Kernel extends WebGLKernel {
1067210673
case 'ArrayTexture(2)':
1067310674
case 'ArrayTexture(3)':
1067410675
case 'ArrayTexture(4)':
10675-
this.output = arguments[0].output;
10676+
this.output = args[0].output;
1067610677
break;
1067710678
default:
1067810679
throw new Error('Auto output not supported for input type: ' + argType);

dist/gpu-browser.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 2.0.0-rc.18
8-
* @date Sat Jun 29 2019 10:06:59 GMT-0400 (Eastern Daylight Time)
7+
* @version 2.0.0-rc.19
8+
* @date Tue Jul 02 2019 12:17:44 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -5987,19 +5987,19 @@ class CPUKernel extends Kernel {
59875987
return [];
59885988
}
59895989

5990-
validateSettings() {
5990+
validateSettings(args) {
59915991
if (!this.output || this.output.length === 0) {
5992-
if (arguments.length !== 1) {
5993-
throw 'Auto dimensions only supported for kernels with only one input';
5992+
if (args.length !== 1) {
5993+
throw new Error('Auto output only supported for kernels with only one input');
59945994
}
59955995

5996-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
5996+
const argType = utils.getVariableType(args[0], this.strictIntegers);
59975997
if (argType === 'Array') {
59985998
this.output = utils.getDimensions(argType);
59995999
} else if (argType === 'NumberTexture' || argType === 'ArrayTexture(4)') {
6000-
this.output = arguments[0].output;
6000+
this.output = args[0].output;
60016001
} else {
6002-
throw 'Auto dimensions not supported for input type: ' + argType;
6002+
throw new Error('Auto output not supported for input type: ' + argType);
60036003
}
60046004
}
60056005

@@ -6034,7 +6034,7 @@ class CPUKernel extends Kernel {
60346034
build() {
60356035
this.setupConstants();
60366036
this.setupArguments(arguments);
6037-
this.validateSettings();
6037+
this.validateSettings(arguments);
60386038
this.translateSource();
60396039

60406040
if (this.graphical) {
@@ -13226,7 +13226,7 @@ class WebGLKernel extends GLKernel {
1322613226
};
1322713227
}
1322813228

13229-
validateSettings() {
13229+
validateSettings(args) {
1323013230
if (!this.validate) {
1323113231
this.texSize = utils.getKernelTextureSize({
1323213232
optimizeFloatMemory: this.optimizeFloatMemory,
@@ -13257,15 +13257,15 @@ class WebGLKernel extends GLKernel {
1325713257
this.checkOutput();
1325813258

1325913259
if (!this.output || this.output.length === 0) {
13260-
if (arguments.length !== 1) {
13260+
if (args.length !== 1) {
1326113261
throw new Error('Auto output only supported for kernels with only one input');
1326213262
}
1326313263

13264-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
13264+
const argType = utils.getVariableType(args[0], this.strictIntegers);
1326513265
if (argType === 'Array') {
1326613266
this.output = utils.getDimensions(argType);
1326713267
} else if (argType === 'NumberTexture' || argType === 'ArrayTexture(4)') {
13268-
this.output = arguments[0].output;
13268+
this.output = args[0].output;
1326913269
} else {
1327013270
throw new Error('Auto output not supported for input type: ' + argType);
1327113271
}
@@ -13447,7 +13447,7 @@ class WebGLKernel extends GLKernel {
1344713447

1344813448
build() {
1344913449
this.initExtensions();
13450-
this.validateSettings();
13450+
this.validateSettings(arguments);
1345113451
this.setupConstants(arguments);
1345213452
if (this.fallbackRequested) return;
1345313453
this.setupArguments(arguments);
@@ -14375,6 +14375,7 @@ __HEADER__;
1437514375
precision highp float;
1437614376
precision highp int;
1437714377
precision highp sampler2D;
14378+
precision highp sampler2DArray;
1437814379

1437914380
const int LOOP_MAX = __LOOP_MAX__;
1438014381

@@ -15383,7 +15384,7 @@ class WebGL2Kernel extends WebGLKernel {
1538315384
};
1538415385
}
1538515386

15386-
validateSettings() {
15387+
validateSettings(args) {
1538715388
if (!this.validate) {
1538815389
this.texSize = utils.getKernelTextureSize({
1538915390
optimizeFloatMemory: this.optimizeFloatMemory,
@@ -15408,11 +15409,11 @@ class WebGL2Kernel extends WebGLKernel {
1540815409
this.checkOutput();
1540915410

1541015411
if (!this.output || this.output.length === 0) {
15411-
if (arguments.length !== 1) {
15412+
if (args.length !== 1) {
1541215413
throw new Error('Auto output only supported for kernels with only one input');
1541315414
}
1541415415

15415-
const argType = utils.getVariableType(arguments[0], this.strictIntegers);
15416+
const argType = utils.getVariableType(args[0], this.strictIntegers);
1541615417
switch (argType) {
1541715418
case 'Array':
1541815419
this.output = utils.getDimensions(argType);
@@ -15423,7 +15424,7 @@ class WebGL2Kernel extends WebGLKernel {
1542315424
case 'ArrayTexture(2)':
1542415425
case 'ArrayTexture(3)':
1542515426
case 'ArrayTexture(4)':
15426-
this.output = arguments[0].output;
15427+
this.output = args[0].output;
1542715428
break;
1542815429
default:
1542915430
throw new Error('Auto output not supported for input type: ' + argType);

0 commit comments

Comments
 (0)