Skip to content

Commit fdedd6f

Browse files
Merge branch 'master' into develop
2 parents 772eaec + 16bf2f9 commit fdedd6f

File tree

5 files changed

+94
-108
lines changed

5 files changed

+94
-108
lines changed

dist/gpu-browser-core.js

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.8.5
8-
* @date Fri Mar 20 2020 08:27:36 GMT-0400 (Eastern Daylight Time)
8+
* @date Fri Mar 20 2020 08:38:27 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -1490,7 +1490,6 @@ class CPUKernel extends Kernel {
14901490
}
14911491

14921492
build() {
1493-
if (this.built) return;
14941493
this.setupConstants();
14951494
this.setupArguments(arguments);
14961495
this.validateSettings(arguments);
@@ -6526,6 +6525,7 @@ class Kernel {
65266525

65276526
static getSignature(kernel, argumentTypes) {
65286527
throw new Error(`"getSignature" not implemented on ${ this.name }`);
6528+
return argumentTypes.length > 0 ? ':' + argumentTypes.join(',') : '';
65296529
}
65306530

65316531
functionToIGPUFunction(source, settings = {}) {
@@ -10105,7 +10105,6 @@ class WebGLKernel extends GLKernel {
1010510105
}
1010610106

1010710107
build() {
10108-
if (this.built) return;
1010910108
this.initExtensions();
1011010109
this.validateSettings(arguments);
1011110110
this.setupConstants(arguments);
@@ -11002,7 +11001,6 @@ float integerCorrectionModulo(float number, float divisor) {
1100211001
}
1100311002

1100411003
destroy(removeCanvasReferences) {
11005-
if (!this.context) return;
1100611004
if (this.buffer) {
1100711005
this.context.deleteBuffer(this.buffer);
1100811006
}
@@ -11061,10 +11059,6 @@ float integerCorrectionModulo(float number, float divisor) {
1106111059
this.destroyExtensions();
1106211060
delete this.context;
1106311061
delete this.canvas;
11064-
if (!this.gpu) return;
11065-
const i = this.gpu.kernels.indexOf(this);
11066-
if (i === -1) return;
11067-
this.gpu.kernels.splice(i, 1);
1106811062
}
1106911063

1107011064
destroyExtensions() {
@@ -13210,15 +13204,15 @@ class GPU {
1321013204
return result;
1321113205
}
1321213206

13213-
function onRequestSwitchKernel(reasons, args, _kernel) {
13214-
if (_kernel.debug) {
13207+
function onRequestSwitchKernel(reasons, args, kernel) {
13208+
if (kernel.debug) {
1321513209
console.warn('Switching kernels');
1321613210
}
1321713211
let newOutput = null;
13218-
if (_kernel.signature && !switchableKernels[_kernel.signature]) {
13219-
switchableKernels[_kernel.signature] = _kernel;
13212+
if (kernel.signature && !switchableKernels[kernel.signature]) {
13213+
switchableKernels[kernel.signature] = kernel;
1322013214
}
13221-
if (_kernel.dynamicOutput) {
13215+
if (kernel.dynamicOutput) {
1322213216
for (let i = reasons.length - 1; i >= 0; i--) {
1322313217
const reason = reasons[i];
1322413218
if (reason.type === 'outputPrecisionMismatch') {
@@ -13227,42 +13221,42 @@ class GPU {
1322713221
}
1322813222
}
1322913223

13230-
const Constructor = _kernel.constructor;
13231-
const argumentTypes = Constructor.getArgumentTypes(_kernel, args);
13232-
const signature = Constructor.getSignature(_kernel, argumentTypes);
13224+
const Constructor = kernel.constructor;
13225+
const argumentTypes = Constructor.getArgumentTypes(kernel, args);
13226+
const signature = Constructor.getSignature(kernel, argumentTypes);
1323313227
const existingKernel = switchableKernels[signature];
1323413228
if (existingKernel) {
1323513229
return existingKernel;
1323613230
}
1323713231

1323813232
const newKernel = switchableKernels[signature] = new Constructor(source, {
1323913233
argumentTypes,
13240-
constantTypes: _kernel.constantTypes,
13241-
graphical: _kernel.graphical,
13242-
loopMaxIterations: _kernel.loopMaxIterations,
13243-
constants: _kernel.constants,
13244-
dynamicOutput: _kernel.dynamicOutput,
13245-
dynamicArgument: _kernel.dynamicArguments,
13246-
context: _kernel.context,
13247-
canvas: _kernel.canvas,
13248-
output: newOutput || _kernel.output,
13249-
precision: _kernel.precision,
13250-
pipeline: _kernel.pipeline,
13251-
immutable: _kernel.immutable,
13252-
optimizeFloatMemory: _kernel.optimizeFloatMemory,
13253-
fixIntegerDivisionAccuracy: _kernel.fixIntegerDivisionAccuracy,
13254-
functions: _kernel.functions,
13255-
nativeFunctions: _kernel.nativeFunctions,
13256-
injectedNative: _kernel.injectedNative,
13257-
subKernels: _kernel.subKernels,
13258-
strictIntegers: _kernel.strictIntegers,
13259-
debug: _kernel.debug,
13260-
gpu: _kernel.gpu,
13234+
constantTypes: kernel.constantTypes,
13235+
graphical: kernel.graphical,
13236+
loopMaxIterations: kernel.loopMaxIterations,
13237+
constants: kernel.constants,
13238+
dynamicOutput: kernel.dynamicOutput,
13239+
dynamicArgument: kernel.dynamicArguments,
13240+
context: kernel.context,
13241+
canvas: kernel.canvas,
13242+
output: newOutput || kernel.output,
13243+
precision: kernel.precision,
13244+
pipeline: kernel.pipeline,
13245+
immutable: kernel.immutable,
13246+
optimizeFloatMemory: kernel.optimizeFloatMemory,
13247+
fixIntegerDivisionAccuracy: kernel.fixIntegerDivisionAccuracy,
13248+
functions: kernel.functions,
13249+
nativeFunctions: kernel.nativeFunctions,
13250+
injectedNative: kernel.injectedNative,
13251+
subKernels: kernel.subKernels,
13252+
strictIntegers: kernel.strictIntegers,
13253+
debug: kernel.debug,
13254+
gpu: kernel.gpu,
1326113255
validate,
13262-
returnType: _kernel.returnType,
13263-
onIstanbulCoverageVariable: _kernel.onIstanbulCoverageVariable,
13264-
removeIstanbulCoverage: _kernel.removeIstanbulCoverage,
13265-
tactic: _kernel.tactic,
13256+
returnType: kernel.returnType,
13257+
onIstanbulCoverageVariable: kernel.onIstanbulCoverageVariable,
13258+
removeIstanbulCoverage: kernel.removeIstanbulCoverage,
13259+
tactic: kernel.tactic,
1326613260
onRequestFallback,
1326713261
onRequestSwitchKernel,
1326813262
});
@@ -13284,18 +13278,17 @@ class GPU {
1328413278
onRequestSwitchKernel
1328513279
}, settingsCopy);
1328613280

13287-
const kernel = new this.Kernel(source, mergedSettings);
13288-
const kernelRun = kernelRunShortcut(kernel);
13281+
const kernelRun = kernelRunShortcut(new this.Kernel(source, mergedSettings));
1328913282

1329013283
if (!this.canvas) {
13291-
this.canvas = kernel.canvas;
13284+
this.canvas = kernelRun.canvas;
1329213285
}
1329313286

1329413287
if (!this.context) {
13295-
this.context = kernel.context;
13288+
this.context = kernelRun.context;
1329613289
}
1329713290

13298-
this.kernels.push(kernel);
13291+
this.kernels.push(kernelRun);
1329913292

1330013293
return kernelRun;
1330113294
}

dist/gpu-browser-core.min.js

Lines changed: 2 additions & 2 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: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.8.5
8-
* @date Fri Mar 20 2020 08:27:36 GMT-0400 (Eastern Daylight Time)
8+
* @date Fri Mar 20 2020 08:38:27 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -5943,7 +5943,6 @@ class CPUKernel extends Kernel {
59435943
}
59445944

59455945
build() {
5946-
if (this.built) return;
59475946
this.setupConstants();
59485947
this.setupArguments(arguments);
59495948
this.validateSettings(arguments);
@@ -10979,6 +10978,7 @@ class Kernel {
1097910978

1098010979
static getSignature(kernel, argumentTypes) {
1098110980
throw new Error(`"getSignature" not implemented on ${ this.name }`);
10981+
return argumentTypes.length > 0 ? ':' + argumentTypes.join(',') : '';
1098210982
}
1098310983

1098410984
functionToIGPUFunction(source, settings = {}) {
@@ -14558,7 +14558,6 @@ class WebGLKernel extends GLKernel {
1455814558
}
1455914559

1456014560
build() {
14561-
if (this.built) return;
1456214561
this.initExtensions();
1456314562
this.validateSettings(arguments);
1456414563
this.setupConstants(arguments);
@@ -15455,7 +15454,6 @@ float integerCorrectionModulo(float number, float divisor) {
1545515454
}
1545615455

1545715456
destroy(removeCanvasReferences) {
15458-
if (!this.context) return;
1545915457
if (this.buffer) {
1546015458
this.context.deleteBuffer(this.buffer);
1546115459
}
@@ -15514,10 +15512,6 @@ float integerCorrectionModulo(float number, float divisor) {
1551415512
this.destroyExtensions();
1551515513
delete this.context;
1551615514
delete this.canvas;
15517-
if (!this.gpu) return;
15518-
const i = this.gpu.kernels.indexOf(this);
15519-
if (i === -1) return;
15520-
this.gpu.kernels.splice(i, 1);
1552115515
}
1552215516

1552315517
destroyExtensions() {
@@ -17663,15 +17657,15 @@ class GPU {
1766317657
return result;
1766417658
}
1766517659

17666-
function onRequestSwitchKernel(reasons, args, _kernel) {
17667-
if (_kernel.debug) {
17660+
function onRequestSwitchKernel(reasons, args, kernel) {
17661+
if (kernel.debug) {
1766817662
console.warn('Switching kernels');
1766917663
}
1767017664
let newOutput = null;
17671-
if (_kernel.signature && !switchableKernels[_kernel.signature]) {
17672-
switchableKernels[_kernel.signature] = _kernel;
17665+
if (kernel.signature && !switchableKernels[kernel.signature]) {
17666+
switchableKernels[kernel.signature] = kernel;
1767317667
}
17674-
if (_kernel.dynamicOutput) {
17668+
if (kernel.dynamicOutput) {
1767517669
for (let i = reasons.length - 1; i >= 0; i--) {
1767617670
const reason = reasons[i];
1767717671
if (reason.type === 'outputPrecisionMismatch') {
@@ -17680,42 +17674,42 @@ class GPU {
1768017674
}
1768117675
}
1768217676

17683-
const Constructor = _kernel.constructor;
17684-
const argumentTypes = Constructor.getArgumentTypes(_kernel, args);
17685-
const signature = Constructor.getSignature(_kernel, argumentTypes);
17677+
const Constructor = kernel.constructor;
17678+
const argumentTypes = Constructor.getArgumentTypes(kernel, args);
17679+
const signature = Constructor.getSignature(kernel, argumentTypes);
1768617680
const existingKernel = switchableKernels[signature];
1768717681
if (existingKernel) {
1768817682
return existingKernel;
1768917683
}
1769017684

1769117685
const newKernel = switchableKernels[signature] = new Constructor(source, {
1769217686
argumentTypes,
17693-
constantTypes: _kernel.constantTypes,
17694-
graphical: _kernel.graphical,
17695-
loopMaxIterations: _kernel.loopMaxIterations,
17696-
constants: _kernel.constants,
17697-
dynamicOutput: _kernel.dynamicOutput,
17698-
dynamicArgument: _kernel.dynamicArguments,
17699-
context: _kernel.context,
17700-
canvas: _kernel.canvas,
17701-
output: newOutput || _kernel.output,
17702-
precision: _kernel.precision,
17703-
pipeline: _kernel.pipeline,
17704-
immutable: _kernel.immutable,
17705-
optimizeFloatMemory: _kernel.optimizeFloatMemory,
17706-
fixIntegerDivisionAccuracy: _kernel.fixIntegerDivisionAccuracy,
17707-
functions: _kernel.functions,
17708-
nativeFunctions: _kernel.nativeFunctions,
17709-
injectedNative: _kernel.injectedNative,
17710-
subKernels: _kernel.subKernels,
17711-
strictIntegers: _kernel.strictIntegers,
17712-
debug: _kernel.debug,
17713-
gpu: _kernel.gpu,
17687+
constantTypes: kernel.constantTypes,
17688+
graphical: kernel.graphical,
17689+
loopMaxIterations: kernel.loopMaxIterations,
17690+
constants: kernel.constants,
17691+
dynamicOutput: kernel.dynamicOutput,
17692+
dynamicArgument: kernel.dynamicArguments,
17693+
context: kernel.context,
17694+
canvas: kernel.canvas,
17695+
output: newOutput || kernel.output,
17696+
precision: kernel.precision,
17697+
pipeline: kernel.pipeline,
17698+
immutable: kernel.immutable,
17699+
optimizeFloatMemory: kernel.optimizeFloatMemory,
17700+
fixIntegerDivisionAccuracy: kernel.fixIntegerDivisionAccuracy,
17701+
functions: kernel.functions,
17702+
nativeFunctions: kernel.nativeFunctions,
17703+
injectedNative: kernel.injectedNative,
17704+
subKernels: kernel.subKernels,
17705+
strictIntegers: kernel.strictIntegers,
17706+
debug: kernel.debug,
17707+
gpu: kernel.gpu,
1771417708
validate,
17715-
returnType: _kernel.returnType,
17716-
onIstanbulCoverageVariable: _kernel.onIstanbulCoverageVariable,
17717-
removeIstanbulCoverage: _kernel.removeIstanbulCoverage,
17718-
tactic: _kernel.tactic,
17709+
returnType: kernel.returnType,
17710+
onIstanbulCoverageVariable: kernel.onIstanbulCoverageVariable,
17711+
removeIstanbulCoverage: kernel.removeIstanbulCoverage,
17712+
tactic: kernel.tactic,
1771917713
onRequestFallback,
1772017714
onRequestSwitchKernel,
1772117715
});
@@ -17737,18 +17731,17 @@ class GPU {
1773717731
onRequestSwitchKernel
1773817732
}, settingsCopy);
1773917733

17740-
const kernel = new this.Kernel(source, mergedSettings);
17741-
const kernelRun = kernelRunShortcut(kernel);
17734+
const kernelRun = kernelRunShortcut(new this.Kernel(source, mergedSettings));
1774217735

1774317736
if (!this.canvas) {
17744-
this.canvas = kernel.canvas;
17737+
this.canvas = kernelRun.canvas;
1774517738
}
1774617739

1774717740
if (!this.context) {
17748-
this.context = kernel.context;
17741+
this.context = kernelRun.context;
1774917742
}
1775017743

17751-
this.kernels.push(kernel);
17744+
this.kernels.push(kernelRun);
1775217745

1775317746
return kernelRun;
1775417747
}

dist/gpu-browser.min.js

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

package-lock.json

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

0 commit comments

Comments
 (0)